<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">If there’s some reason that setting the angle back with “angle adjust” won’t work in your scheme, you can explicitly disable the caching by doing this after the “angle adjust”:<div class=""><br class=""></div><div class="">import BuildStructure</div><div class="">BuildStructure._bondAngleCache = {}</div><div class=""><br class=""></div><div class="">—Eric</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 23, 2016, at 10:08 AM, Jiying Jia <<a href="mailto:jiajiyingxibei@gmail.com" class="">jiajiyingxibei@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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" class="">criterion</a>.</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">------------------</div><div class="">Best Wishes!</div><div class="">Jiying Jia</div></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Wed, Nov 23, 2016 at 6:51 PM, Jiying Jia <span dir="ltr" class=""><<a href="mailto:jiajiyingxibei@gmail.com" target="_blank" class="">jiajiyingxibei@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi,<div class="">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 class="">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 class="">I hope anyone can solve my problem..</div><div class="">Below is the python script and init.mol2.</div><div class=""><br class=""></div><div class="">PYTHON SCRIPT:</div><div class=""><div class="">import os</div><div class="">import time</div><div class="">import chimera</div><div class="">import random</div><div class="">from chimera import runCommand as rc</div><div class="">from chimera.tkgui import saveReplyLog</div><div class="">import MoleculeTransform</div><div class="">from MoleculeTransform import transform_atom_coordinates</div><div class="">import numpy as np</div><div class="">import sys</div><div class="">import re</div><div class="">#open initial conformation init.mol2</div><div class="">opened = chimera.openModels.open("init.<wbr class="">mol2")# opened as model 0 in chimera</div><div class="">chimera.openModels.open("init.<wbr class="">mol2") # opened as model 1 in chimera, used to store old conformation in monte carlo simulation</div><div class="">rho = opened[0]</div><div class="">print "angleold anglenew angle_after_adjust"</div><div class="">for pdbi in range(0,20):</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>random_atom = 1</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>an0 = rho.atoms[random_atom-1]</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>an1 = rho.atoms[random_atom]</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>an2 = rho.atoms[random_atom+1]</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>angleold = chimera.angle(an0.xformCoord()<wbr class="">,an1.xformCoord(),an2.<wbr class="">xformCoord())</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>anglenew = random.random()*180</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>rc("adjust angle %f %s %s %s"%(anglenew,an0.oslIdent(),<wbr class="">an1.oslIdent(),an2.oslIdent())<wbr class="">)</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>angleafter = chimera.angle(an0.xformCoord()<wbr class="">,an1.xformCoord(),an2.<wbr class="">xformCoord())</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>print str(angleold)+" "+str(anglenew)+" "+str(angleafter)</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>if anglenew>angleold:</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>rc("mcopy #0 #1 settings x")</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>else:</div><div class=""><span class="m_-5357638827228720657gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>rc("mcopy #1 #0 settings x")</div><div class="">rc("close all")</div><div class="">rc("stop now")</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">INIT.MOL2:</div><div class=""><div class="">@<TRIPOS>MOLECULE</div><div class="">init.mol2</div><div class="">3 2 3 0 0</div><div class="">NUCLEIC_ACID</div><div class="">NO_CHARGES</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">@<TRIPOS>ATOM</div><div class=""> 1 C 1.7324 -0.5083 0.8663 C.3 1 DA 0.0000</div><div class=""> 2 C -0.6180 0.4940 -0.0060 C.3 2 DA 0.0000</div><div class=""> 3 C 1.2450 0.9460 1.8950 C.3 3 DA 0.0000</div><div class="">@<TRIPOS>BOND</div><div class=""> 1 1 2 1</div><div class=""> 2 2 3 1</div><div class="">@<TRIPOS>SUBSTRUCTURE</div><div class=""> 1 DA 1 RESIDUE 4 A DA 1 ROOT</div><div class=""> 2 DA 2 RESIDUE 4 A DA 2</div><div class=""> 3 DA 3 RESIDUE 4 A DA 1</div></div><div class=""><div class=""><div class="m_-5357638827228720657gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""></div></div></div></div></div>
</div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">Chimera-users mailing list: <a href="mailto:Chimera-users@cgl.ucsf.edu" class="">Chimera-users@cgl.ucsf.edu</a><br class="">Manage subscription: <a href="http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users" class="">http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users</a><br class=""></div></blockquote></div><br class=""></div></body></html>