仓库源文站点原文


layout: post title: 我使用的VMD初始化脚本 categories:


我一直不喜欢用VMD, 除了其界面复杂, 鼠标操作模式老旧以外, 初始的显示模式也很简陋. 话虽这样说, 但有时还不得不用, 因为目前看来使用VMD查看轨迹还是最高效的. 毕竟, 人家名字就是 VVVVVVVV MD.

其实, 我们可以自定义VMD的初始显示模式, 让它变得友好一些. 这些设置可以放在和vmd.exe相同的目录下, 文件名称一般是vmd.rc. 这是VMD用于初始化的脚本, 我们可以在里面加上自己的tcl脚本, 满足自己的需要.

下面是我使用的VMD初始化脚本, 和原先的相比, 主要改动有三点:

  1. 使用正视图而不是默认的透视图
  2. 有盒子大小信息时, 自动显示盒子
  3. 增加了一段tcl脚本, 根据分子情况决定其显示模式

在这种模式下, 载入结构后看起来很清晰, 大多时候也无须自己再手动添加不同的表示模式, 方便不少.

<table class="highlighttable"><th colspan="2" style="text-align:left">vmd.rc</th><tr><td><div class="linenodiv" style="background-color: #f0f0f0; padding-right: 10px"><pre style="line-height: 125%"> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118</pre></div></td><td class="code"><div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008800; font-style: italic">############################################################################</span> <span style="color: #008800; font-style: italic">#cr</span> <span style="color: #008800; font-style: italic">#cr (C) Copyright 1995-2007 The Board of Trustees of the</span> <span style="color: #008800; font-style: italic">#cr University of Illinois</span> <span style="color: #008800; font-style: italic">#cr All Rights Reserved</span> <span style="color: #008800; font-style: italic">#cr</span> <span style="color: #008800; font-style: italic">############################################################################</span>

<span style="color: #008800; font-style: italic">############################################################################</span> <span style="color: #008800; font-style: italic"># RCS INFORMATION:</span> <span style="color: #008800; font-style: italic">#</span> <span style="color: #008800; font-style: italic"># $RCSfile: .vmdrc,v $</span> <span style="color: #008800; font-style: italic"># $Author: johns $ $Locker: $ $State: Exp $</span> <span style="color: #008800; font-style: italic"># $Revision: 1.9 $ $Date: 2007/01/12 20:12:44 $</span> <span style="color: #008800; font-style: italic">#</span> <span style="color: #008800; font-style: italic">############################################################################</span> <span style="color: #008800; font-style: italic"># DESCRIPTION:</span> <span style="color: #008800; font-style: italic">#</span> <span style="color: #008800; font-style: italic"># VMD startup script. The commands here are executed as soon as VMD starts up</span> <span style="color: #008800; font-style: italic">############################################################################</span>

<span style="color: #008800; font-style: italic"># turn on lights 0 and 1</span> <span style="color: #B8860B">light</span> <span style="color: #666666">0</span> on <span style="color: #B8860B">light</span> <span style="color: #666666">1</span> on <span style="color: #B8860B">light</span> <span style="color: #666666">2</span> off <span style="color: #B8860B">light</span> <span style="color: #666666">3</span> off

<span style="color: #008800; font-style: italic"># position the stage and axes</span> <span style="color: #B8860B">axes</span> location lowerleft <span style="color: #B8860B">stage</span> location off

<span style="color: #008800; font-style: italic"># position and turn on menus</span> <span style="color: #B8860B">menu</span> main move <span style="color: #666666">5</span> <span style="color: #666666">225</span> <span style="color: #B8860B">menu</span> display move <span style="color: #666666">395</span> <span style="color: #666666">30</span> <span style="color: #B8860B">menu</span> graphics move <span style="color: #666666">395</span> <span style="color: #666666">500</span> <span style="color: #B8860B">menu</span> color move <span style="color: #666666">125</span> <span style="color: #666666">225</span> <span style="color: #B8860B">menu</span> files move <span style="color: #666666">125</span> <span style="color: #666666">325</span> <span style="color: #B8860B">menu</span> labels move <span style="color: #666666">125</span> <span style="color: #666666">525</span> <span style="color: #B8860B">menu</span> render move <span style="color: #666666">125</span> <span style="color: #666666">525</span>

<span style="color: #B8860B">menu</span> main on <span style="color: #008800; font-style: italic">#menu display on</span> <span style="color: #008800; font-style: italic">#menu graphics on</span> <span style="color: #008800; font-style: italic">#menu color on</span> <span style="color: #008800; font-style: italic">#menu labels on</span> <span style="color: #008800; font-style: italic">#menu render on</span> <span style="color: #008800; font-style: italic">#menu files on</span>

<span style="color: #008800; font-style: italic"># start the scene a-rockin'</span> <span style="color: #008800; font-style: italic"># rock y by 1</span>

<span style="color: #008800; font-style: italic"># User's default values for newly loaded molecules/reps, etc</span> <span style="color: #008800; font-style: italic"># mol default color {colorID 5}</span> <span style="color: #008800; font-style: italic"># mol default style {NewCartoon 0.300000 6.000000 4.100000 0}</span> <span style="color: #008800; font-style: italic"># mol default selection {name CA}</span> <span style="color: #008800; font-style: italic"># mol default material {Transparent}</span>

<span style="color: #B8860B">display</span> projection orthographic <span style="color: #AA22FF; font-weight: bold">after</span> idle <span style="color: #AA22FF; font-weight: bold">{</span> <span style="color: #AA22FF; font-weight: bold">foreach</span> molid <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">molinfo</span> list<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">{</span> <span style="color: #B8860B">mol</span> delrep <span style="color: #666666">0</span> <span style="color: #B8860B">$molid</span>

    <span style="color: #AA22FF; font-weight: bold">set</span> sel <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> <span style="color: #B8860B">$molid</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">protein</span><span style="color: #AA22FF; font-weight: bold">}]</span>
    <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{[</span><span style="color: #B8860B">$sel</span> <span style="color: #B8860B">num</span><span style="color: #AA22FF; font-weight: bold">]}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
        <span style="color: #B8860B">mol</span> selection <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">protein</span><span style="color: #AA22FF; font-weight: bold">}</span>
        <span style="color: #B8860B">mol</span> representation newcartoon
        <span style="color: #B8860B">mol</span> addrep <span style="color: #B8860B">$molid</span>
        <span style="color: #B8860B">mol</span> modcolor <span style="color: #666666">0</span> <span style="color: #B8860B">$molid</span> structure

        <span style="color: #B8860B">mol</span> selection <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">protein</span> and <span style="color: #AA22FF; font-weight: bold">(</span><span style="color: #B8860B">name</span> CA or not backbone<span style="color: #AA22FF; font-weight: bold">)}</span>
        <span style="color: #B8860B">mol</span> representation lines
        <span style="color: #B8860B">mol</span> addrep <span style="color: #B8860B">$molid</span>
        <span style="color: #B8860B">mol</span> modcolor <span style="color: #666666">1</span> <span style="color: #B8860B">$molid</span> resid
    <span style="color: #AA22FF; font-weight: bold">}</span>

    <span style="color: #AA22FF; font-weight: bold">set</span> sel <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> <span style="color: #B8860B">$molid</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">nucleic</span><span style="color: #AA22FF; font-weight: bold">}]</span>
    <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{[</span><span style="color: #B8860B">$sel</span> <span style="color: #B8860B">num</span><span style="color: #AA22FF; font-weight: bold">]}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
        <span style="color: #B8860B">mol</span> selection <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">nucleic</span><span style="color: #AA22FF; font-weight: bold">}</span>
        <span style="color: #B8860B">mol</span> representation newribbons
        <span style="color: #B8860B">mol</span> addrep <span style="color: #B8860B">$molid</span>
        <span style="color: #B8860B">mol</span> modcolor <span style="color: #666666">0</span> <span style="color: #B8860B">$molid</span> resid
    <span style="color: #AA22FF; font-weight: bold">}</span>

    <span style="color: #AA22FF; font-weight: bold">set</span> sel <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> <span style="color: #B8860B">$molid</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">water</span><span style="color: #AA22FF; font-weight: bold">}]</span>
    <span style="color: #AA22FF; font-weight: bold">set</span> num <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$sel</span> <span style="color: #B8860B">num</span><span style="color: #AA22FF; font-weight: bold">]</span>
    <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$num</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
        <span style="color: #B8860B">mol</span> selection <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">water</span><span style="color: #AA22FF; font-weight: bold">}</span>
        <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$num</span> <span style="color: #666666">&lt;</span><span style="color: #B8860B">900</span> <span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
            <span style="color: #B8860B">mol</span> representation Lines
        <span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">else</span> <span style="color: #AA22FF; font-weight: bold">{</span>
            <span style="color: #B8860B">mol</span> representation Points
        <span style="color: #AA22FF; font-weight: bold">}</span>
        <span style="color: #B8860B">mol</span> addrep <span style="color: #B8860B">$molid</span>
    <span style="color: #AA22FF; font-weight: bold">}</span>

    <span style="color: #AA22FF; font-weight: bold">set</span> txt <span style="color: #BB4444">&quot;not(numbonds=0 or water or resname DA or resname DG or resname DT or resname DC or resname ALA or resname ARG or resname ASN or resname ASP or resname CYS or resname GLN or resname GLU or resname GLY or resname HIS or resname HOH or resname ILE or resname LEU or resname LYS or resname MET or resname PHE or resname PRO or resname SER or resname THR or resname TRP or resname TYR or resname VAL)&quot;</span>
    <span style="color: #AA22FF; font-weight: bold">set</span> sel <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> <span style="color: #B8860B">$molid</span> <span style="color: #BB4444">&quot;$txt&quot;</span><span style="color: #AA22FF; font-weight: bold">]</span>
    <span style="color: #AA22FF; font-weight: bold">set</span> num <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$sel</span> <span style="color: #B8860B">num</span><span style="color: #AA22FF; font-weight: bold">]</span>
    <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$num</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
        <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$num</span> <span style="color: #666666">&lt;</span><span style="color: #B8860B">500</span> <span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
            <span style="color: #B8860B">mol</span> representation CPK
        <span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">else</span> <span style="color: #AA22FF; font-weight: bold">{</span>
            <span style="color: #B8860B">mol</span> representation Lines
        <span style="color: #AA22FF; font-weight: bold">}</span>
        <span style="color: #B8860B">mol</span> selection <span style="color: #BB4444">&quot;$txt&quot;</span>
        <span style="color: #B8860B">mol</span> addrep <span style="color: #B8860B">$molid</span>
    <span style="color: #AA22FF; font-weight: bold">}</span>

    <span style="color: #AA22FF; font-weight: bold">set</span> txt <span style="color: #BB4444">&quot;numbonds=0&quot;</span>
    <span style="color: #AA22FF; font-weight: bold">set</span> sel <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> <span style="color: #B8860B">$molid</span> <span style="color: #BB4444">&quot;$txt&quot;</span><span style="color: #AA22FF; font-weight: bold">]</span>
    <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #AA22FF; font-weight: bold">{[</span><span style="color: #B8860B">$sel</span> <span style="color: #B8860B">num</span><span style="color: #AA22FF; font-weight: bold">]}</span> <span style="color: #AA22FF; font-weight: bold">{</span>
        <span style="color: #B8860B">mol</span> selection <span style="color: #BB4444">&quot;$txt&quot;</span>
        <span style="color: #B8860B">mol</span> representation VDW
        <span style="color: #B8860B">mol</span> addrep <span style="color: #B8860B">$molid</span>
    <span style="color: #AA22FF; font-weight: bold">}</span>
<span style="color: #AA22FF; font-weight: bold">}</span>
<span style="color: #B8860B">pbc</span> box

<span style="color: #AA22FF; font-weight: bold">}</span> </pre></div> </td></tr></table> 当然, 这个初始化脚本只有在命令行中启动VMD时才会自动加载的. 如果你是使用界面来载入分子, 那它是不会起作用的. 建议大家还是习惯使用命令行来启动VMD吧, 毕竟可以节省不少时间, 且有助于预防鼠标手.

命令行启动VMD加载分子没有你想象得那么高深. 对Windows 7及以后的系统, 将vmd.exe所在的目录添加到Path环境变量后, 到分子结构文件所在的目录下, 不要选中任何东西, 按住Shift键, 在界面空白处鼠标右键, 选择在此处打开命令窗口打开CMD, 然后在其中输入vmd file.pdb就可以直接打开file.pdb了. 查看GROMACS的轨迹文件, 则可以使用vmd conf.gro traj.trr或者vmd conf.gro traj.xtc. 其他格式的文件, 也是类似.

评论