<div dir="ltr">By the way, I use the "if" after adjustment of angle because in my whole program there're another <a target="_blank" href="http://www.baidu.com/link?url=y10dPHkFYzBREucobuDAs73RgoMsopt2igSS2z1gFoRQdH8p_0rDvcC35wzy5wYkxaCY8B6_PKjkhyJalktpwbPcXofDXlxlm6QUKk36GtPrcGqeBqh7C0_f2gL5Gi6C" style="color:rgb(51,51,51);text-decoration:none;font-size:13px;font-family:arial">criterion</a>.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>------------------</div><div>Best Wishes!</div><div>Jiying Jia</div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Nov 23, 2016 at 6:51 PM, Jiying Jia <span dir="ltr"><<a href="mailto:jiajiyingxibei@gmail.com" target="_blank">jiajiyingxibei@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div>I want to use python script to adjust the bond angle randomly and only accept the case if the random new angle is larger than old one. </div><div>I use "mcopy" to recover the old angle if the new is smaller. But I encounter a problem: if I use "mcopy #old #new setting a" or "x" or "y", the after "adjust angle anglenew" command, the angle adjusted is not the anglenew, but a different one. I don't know why. </div><div>I hope anyone can solve my problem..</div><div>Below is the python script and init.mol2.</div><div><br></div><div>PYTHON SCRIPT:</div><div><div>import os</div><div>import time</div><div>import chimera</div><div>import random</div><div>from chimera import runCommand as rc</div><div>from chimera.tkgui import saveReplyLog</div><div>import MoleculeTransform</div><div>from MoleculeTransform import transform_atom_coordinates</div><div>import numpy as np</div><div>import sys</div><div>import re</div><div>#open initial conformation init.mol2</div><div>opened = chimera.openModels.open("init.<wbr>mol2")# opened as model 0 in chimera</div><div>chimera.openModels.open("init.<wbr>mol2") # opened as model 1 in chimera, used to store old conformation in monte carlo simulation</div><div>rho = opened[0]</div><div>print "angleold anglenew angle_after_adjust"</div><div>for pdbi in range(0,20):</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>random_atom = 1</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>an0 = rho.atoms[random_atom-1]</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>an1 = rho.atoms[random_atom]</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>an2 = rho.atoms[random_atom+1]</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>angleold = chimera.angle(an0.xformCoord()<wbr>,an1.xformCoord(),an2.<wbr>xformCoord())</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>anglenew = random.random()*180</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>rc("adjust angle %f %s %s %s"%(anglenew,an0.oslIdent(),<wbr>an1.oslIdent(),an2.oslIdent())<wbr>)</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>angleafter = chimera.angle(an0.xformCoord()<wbr>,an1.xformCoord(),an2.<wbr>xformCoord())</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>print str(angleold)+" "+str(anglenew)+" "+str(angleafter)</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>if anglenew>angleold:</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>rc("mcopy #0 #1 settings x")</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>else:</div><div><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>rc("mcopy #1 #0 settings x")</div><div>rc("close all")</div><div>rc("stop now")</div></div><div><br></div><div><br></div><div>INIT.MOL2:</div><div><div>@<TRIPOS>MOLECULE</div><div>init.mol2</div><div>3 2 3 0 0</div><div>NUCLEIC_ACID</div><div>NO_CHARGES</div><div><br></div><div><br></div><div>@<TRIPOS>ATOM</div><div> 1 C 1.7324 -0.5083 0.8663 C.3 1 DA 0.0000</div><div> 2 C -0.6180 0.4940 -0.0060 C.3 2 DA 0.0000</div><div> 3 C 1.2450 0.9460 1.8950 C.3 3 DA 0.0000</div><div>@<TRIPOS>BOND</div><div> 1 1 2 1</div><div> 2 2 3 1</div><div>@<TRIPOS>SUBSTRUCTURE</div><div> 1 DA 1 RESIDUE 4 A DA 1 ROOT</div><div> 2 DA 2 RESIDUE 4 A DA 2</div><div> 3 DA 3 RESIDUE 4 A DA 1</div></div><div><div><div class="m_-5357638827228720657gmail_signature"><div dir="ltr"><div><div dir="ltr"></div></div></div></div></div>
</div></div>
</blockquote></div><br></div>