layout: post title: VMD建模示例 categories:
toc {:toc}
2020-03-25 09:48:58
上篇文章中我们整理了VMD中的向量与矩阵操作说明, 这篇文章中我们来具体示例一下如何使用这些函数对分子坐标进行变换, 以创建一些特殊的构型.
我们使用的示例分子如下, xyz格式:
<table class="highlighttable"><th colspan="2" style="text-align:left">mol.xyz</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #666666">24</span> mol C <span style="color: #666666">-1.615</span> <span style="color: #666666">-0.739</span> <span style="color: #666666">-3.043</span> C <span style="color: #666666">-0.076</span> <span style="color: #666666">-0.706</span> <span style="color: #666666">-3.045</span> H <span style="color: #666666">-1.963</span> <span style="color: #666666">-1.227</span> <span style="color: #666666">-3.929</span> H <span style="color: #666666">-1.959</span> <span style="color: #666666">-1.275</span> <span style="color: #666666">-2.183</span> C <span style="color: #666666">0.469</span> <span style="color: #666666">-2.145</span> <span style="color: #666666">-3.087</span> H <span style="color: #666666">0.268</span> <span style="color: #666666">-0.169</span> <span style="color: #666666">-3.905</span> H <span style="color: #666666">0.272</span> <span style="color: #666666">-0.218</span> <span style="color: #666666">-2.159</span> H <span style="color: #666666">1.539</span> <span style="color: #666666">-2.122</span> <span style="color: #666666">-3.089</span> H <span style="color: #666666">0.126</span> <span style="color: #666666">-2.682</span> <span style="color: #666666">-2.227</span> H <span style="color: #666666">0.122</span> <span style="color: #666666">-2.633</span> <span style="color: #666666">-3.974</span> C <span style="color: #666666">-2.160</span> <span style="color: #666666">0.701</span> <span style="color: #666666">-3.001</span> C <span style="color: #666666">-3.700</span> <span style="color: #666666">0.667</span> <span style="color: #666666">-2.999</span> H <span style="color: #666666">-1.817</span> <span style="color: #666666">1.237</span> <span style="color: #666666">-3.861</span> H <span style="color: #666666">-1.812</span> <span style="color: #666666">1.188</span> <span style="color: #666666">-2.114</span> C <span style="color: #666666">-4.245</span> <span style="color: #666666">2.107</span> <span style="color: #666666">-2.957</span> H <span style="color: #666666">-4.047</span> <span style="color: #666666">0.179</span> <span style="color: #666666">-3.885</span> H <span style="color: #666666">-4.043</span> <span style="color: #666666">0.131</span> <span style="color: #666666">-2.139</span> H <span style="color: #666666">-3.897</span> <span style="color: #666666">2.594</span> <span style="color: #666666">-2.070</span> H <span style="color: #666666">-3.901</span> <span style="color: #666666">2.643</span> <span style="color: #666666">-3.817</span> C <span style="color: #666666">-5.784</span> <span style="color: #666666">2.073</span> <span style="color: #666666">-2.955</span> O <span style="color: #666666">-6.394</span> <span style="color: #666666">1.131</span> <span style="color: #666666">-3.525</span> N <span style="color: #666666">-6.541</span> <span style="color: #666666">3.141</span> <span style="color: #666666">-2.286</span> H <span style="color: #666666">-7.407</span> <span style="color: #666666">2.773</span> <span style="color: #666666">-1.946</span> H <span style="color: #666666">-6.007</span> <span style="color: #666666">3.500</span> <span style="color: #666666">-1.521</span></pre></div> </td></tr></table>三种方式:
file.tcl
, 放到与分子坐标文件相同的路径下, 然后在VMD的命令行窗口中执行source file.tcl
, 或者Extensions -> TkConsole
打开分子坐标文件mol.xyz
, 使用自定义的函数显示坐标轴(showaxis
)和原子序号(labelatom
), 便于查看原子和操作后的效果.
我们首先将分子整体平移, 使N22位于原点.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中整个分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得N22的坐标</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定平移值为N22坐标的负值</span> <span style="color: #AA22FF; font-weight: bold">set</span> m0 <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #008800; font-style: italic"># 施加矩阵变换</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #B8860B">$m0</span></pre></div> </td></tr></table>上面的操作示例了坐标变换的基本流程, 根据需要获得变换矩阵, 然后对分子施加变换矩阵.
示例中的最后两步操作也可以使用$mol moveby [vecinvert $vN]
命令代替, 效果相同. 我们这里使用矩阵操作, 因为使用矩阵便于后面的联合操作.
接下来, 我们以N22-C5为分子轴, 变换后使得N22-C5平行于x轴
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中整个分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得N22的坐标</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定矩阵偏移值为N22坐标的负值</span> <span style="color: #AA22FF; font-weight: bold">set</span> m0 <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #008800; font-style: italic"># 施加矩阵变换</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #B8860B">$m0</span> <span style="color: #008800; font-style: italic"># 选中C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得C5的坐标</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得将 N-->C 变换为x轴所需的矩阵</span> <span style="color: #AA22FF; font-weight: bold">set</span> m1 <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 施加矩阵</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #B8860B">$m1</span></pre></div> </td></tr></table>上面进行了三次矩阵操作, 每次施加是单独进行的, 这样方便查看效果, 但写起来不方便, 效率也不好. 我们可以先计算出这些矩阵的乘积, 然后只施加一次操作就好了. 值得注意的是矩阵相乘的顺序.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22, C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得N22, C5的坐标</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定矩阵偏移值为N22坐标的负值</span> <span style="color: #AA22FF; font-weight: bold">set</span> m0 <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #008800; font-style: italic"># 获得将 N-->C 变换为x轴所需的矩阵</span> <span style="color: #AA22FF; font-weight: bold">set</span> m1 <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 沿x轴平移 5A, 以便随后的旋转</span> <span style="color: #AA22FF; font-weight: bold">set</span> m2 <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">5</span> <span style="color: #666666">0</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #008800; font-style: italic"># 所有操作, 注意矩阵顺序.</span> <span style="color: #AA22FF; font-weight: bold">set</span> m <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transmult</span> <span style="color: #B8860B">$m2</span> <span style="color: #B8860B">$m1</span> <span style="color: #B8860B">$m0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #B8860B">$m</span></pre></div> </td></tr></table>如果你十分清楚自己在做什么, 可以不使用临时矩阵, 直接一步到位.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22, C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得N22, C5的坐标</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 偏移值为N22坐标的负值</span> <span style="color: #008800; font-style: italic"># 将 N-->C 变换为x轴</span> <span style="color: #008800; font-style: italic"># 沿x轴平移 5A</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transmult</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">5</span> <span style="color: #666666">0</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #AA22FF; font-weight: bold">]</span></pre></div> </td></tr></table>在前一步结构的基础上, 我们对分子进行旋转, 旋转时需要确定旋转中心, 旋转轴, 旋转角度. 默认的旋转中心是原点, 旋转轴可以是x, y, z轴, 或任意轴. 我们进行前面的变换就是为了旋转方便, 如果不介意, 可以直接在原坐标的基础上进行旋转, 但那种情况下确定旋转轴会比较麻烦.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22, C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 获得N22, C5的坐标</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 设定分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 偏移值为N22坐标的负值</span> <span style="color: #008800; font-style: italic"># 将 N-->C 变换为x轴</span> <span style="color: #008800; font-style: italic"># 沿x轴平移 5A</span> <span style="color: #008800; font-style: italic"># 绕z轴旋转30度</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transmult</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transaxis</span> z <span style="color: #666666">30</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">5</span> <span style="color: #666666">0</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #AA22FF; font-weight: bold">]</span></pre></div> </td></tr></table>利用循环, 我们可以进行多次旋转, 同时保存每次旋转后的构型. 注意循环添加的位置.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22, C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 旋转, 每次30度</span> <span style="color: #AA22FF; font-weight: bold">for</span> <span style="color: #AA22FF; font-weight: bold">{set</span> t <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$t</span> <span style="color: #666666"><=</span> <span style="color: #B8860B">360</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #AA22FF">incr</span> t <span style="color: #666666">30</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span> <span style="color: #008800; font-style: italic"># 获得N22, C5的坐标, 分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 偏移值为N22坐标的负值</span> <span style="color: #008800; font-style: italic"># 将 N-->C 变换为x轴</span> <span style="color: #008800; font-style: italic"># 沿x轴平移 5A</span> <span style="color: #008800; font-style: italic"># 绕z轴旋转 t</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transmult</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transaxis</span> z <span style="color: #B8860B">$t</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">5</span> <span style="color: #666666">0</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 保存xyz文件</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">writexyz</span> <span style="color: #BB4444">"mol_$t.xyz"</span> <span style="color: #AA22FF; font-weight: bold">}</span></pre></div> </td></tr></table>我们可以得到的所有xyz文件合并到一起, cat mol_*.xyz >mol~.xyz
, 除去不需要的原子数目行和标题行, 并修改总原子数就可以使用了.
一边旋转, 一边平移, 就是螺旋了.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22, C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 旋转, 每次30度</span> <span style="color: #AA22FF; font-weight: bold">set</span> dt <span style="color: #666666">30</span> <span style="color: #AA22FF; font-weight: bold">set</span> n <span style="color: #AA22FF; font-weight: bold">[expr</span> <span style="color: #666666">3*360/</span><span style="color: #B8860B">$dt</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">for</span> <span style="color: #AA22FF; font-weight: bold">{set</span> i <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$i</span> <span style="color: #666666"><=</span> <span style="color: #B8860B">$n</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #AA22FF">incr</span> i<span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span> <span style="color: #008800; font-style: italic"># 获得N22, C5的坐标, 分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 偏移值为N22坐标的负值</span> <span style="color: #008800; font-style: italic"># 将 N-->C 变换为x轴</span> <span style="color: #008800; font-style: italic"># 沿x轴平移 5A</span> <span style="color: #008800; font-style: italic"># 绕z轴旋转 t</span> <span style="color: #008800; font-style: italic"># 沿z轴平移 z, 注意使用方式</span> <span style="color: #AA22FF; font-weight: bold">set</span> t <span style="color: #AA22FF; font-weight: bold">[expr</span> <span style="color: #B8860B">$i</span><span style="color: #666666">*</span><span style="color: #B8860B">$dt</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> z <span style="color: #AA22FF; font-weight: bold">[expr</span> <span style="color: #B8860B">$i</span><span style="color: #666666">*2</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transmult</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #BB4444">"0 0 $z"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transaxis</span> z <span style="color: #B8860B">$t</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">5</span> <span style="color: #666666">0</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 保存为xyz文件</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">writexyz</span> <span style="color: #BB4444">"mol_$z-$t.xyz"</span> <span style="color: #AA22FF; font-weight: bold">}</span></pre></div> </td></tr></table>如果平移和旋转相互独立, 得到圆柱构型.
<table class="highlighttable"><th colspan="2" style="text-align:left">tcl</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</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic"># 选中分子</span> <span style="color: #AA22FF; font-weight: bold">set</span> mol <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top all<span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 选中N22, C5</span> <span style="color: #AA22FF; font-weight: bold">set</span> N <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 22"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> C <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">atomselect</span> top <span style="color: #BB4444">"serial 5"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 旋转, 每次30度</span> <span style="color: #AA22FF; font-weight: bold">set</span> dt <span style="color: #666666">30</span> <span style="color: #AA22FF; font-weight: bold">set</span> n <span style="color: #AA22FF; font-weight: bold">[expr</span> <span style="color: #666666">3*360/</span><span style="color: #B8860B">$dt</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">for</span> <span style="color: #AA22FF; font-weight: bold">{set</span> z <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$z</span> <span style="color: #666666"><=</span> <span style="color: #B8860B">30</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #AA22FF">incr</span> z <span style="color: #666666">5</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span> <span style="color: #AA22FF; font-weight: bold">for</span> <span style="color: #AA22FF; font-weight: bold">{set</span> i <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">$i</span> <span style="color: #666666"><=</span> <span style="color: #B8860B">$n</span><span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #AA22FF">incr</span> i <span style="color: #AA22FF; font-weight: bold">}</span> <span style="color: #AA22FF; font-weight: bold">{</span> <span style="color: #008800; font-style: italic"># 获得N22, C5的坐标, 分子轴 N-->C</span> <span style="color: #AA22FF; font-weight: bold">set</span> vN <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$N</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #AA22FF">lindex</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">$C</span> <span style="color: #B8860B">get</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">x</span> y z<span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">set</span> vNC <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecsub</span> <span style="color: #B8860B">$vC</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 偏移值为N22坐标的负值</span> <span style="color: #008800; font-style: italic"># 将 N-->C 变换为x轴</span> <span style="color: #008800; font-style: italic"># 沿x轴平移 5A</span> <span style="color: #008800; font-style: italic"># 绕z轴旋转 t</span> <span style="color: #008800; font-style: italic"># 沿z轴平移 z, 注意使用方式</span> <span style="color: #AA22FF; font-weight: bold">set</span> t <span style="color: #AA22FF; font-weight: bold">[expr</span> <span style="color: #B8860B">$i</span><span style="color: #666666">*</span><span style="color: #B8860B">$dt</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">move</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transmult</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #BB4444">"0 0 $z"</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transaxis</span> z <span style="color: #B8860B">$t</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">{</span><span style="color: #B8860B">5</span> <span style="color: #666666">0</span> <span style="color: #666666">0</span><span style="color: #AA22FF; font-weight: bold">}]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transvecinv</span> <span style="color: #B8860B">$vNC</span><span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">transoffset</span> <span style="color: #AA22FF; font-weight: bold">[</span><span style="color: #B8860B">vecinvert</span> <span style="color: #B8860B">$vN</span><span style="color: #AA22FF; font-weight: bold">]]</span> <span style="color: #AA22FF; font-weight: bold">]</span> <span style="color: #008800; font-style: italic"># 保存为xyz文件</span> <span style="color: #B8860B">$mol</span> <span style="color: #B8860B">writexyz</span> <span style="color: #BB4444">"mol_$z-$t.xyz"</span> <span style="color: #AA22FF; font-weight: bold">} }</span></pre></div> </td></tr></table>使用VMD的矩阵操作进行建模, 总体而言比自己写代码方便, 但tcl语言 太 差 了, 坑很多, 需要熟悉, 熟悉了之后也会很快忘记, 每次用的时候都要查语法. 详细的语法可以参考我整理的TCL培训教程.