On Nov 23, 2016, at 10:08 AM, Jiying Jia <jiajiyingxibei@gmail.com> wrote:By the way, I use the "if" after adjustment of angle because in my whole program there're another criterion._______________________________________________------------------Best Wishes!Jiying JiaOn Wed, Nov 23, 2016 at 6:51 PM, Jiying Jia <jiajiyingxibei@gmail.com> wrote:Hi,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.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.I hope anyone can solve my problem..Below is the python script and init.mol2.PYTHON SCRIPT:import osimport timeimport chimeraimport randomfrom chimera import runCommand as rcfrom chimera.tkgui import saveReplyLogimport MoleculeTransformfrom MoleculeTransform import transform_atom_coordinatesimport numpy as npimport sysimport re#open initial conformation init.mol2opened = chimera.openModels.open("init.mol2")# opened as model 0 in chimera chimera.openModels.open("init.mol2") # opened as model 1 in chimera, used to store old conformation in monte carlo simulation rho = opened[0]print "angleold anglenew angle_after_adjust"for pdbi in range(0,20):random_atom = 1an0 = rho.atoms[random_atom-1]an1 = rho.atoms[random_atom]an2 = rho.atoms[random_atom+1]angleold = chimera.angle(an0.xformCoord(),an1.xformCoord(),an2. xformCoord()) anglenew = random.random()*180rc("adjust angle %f %s %s %s"%(anglenew,an0.oslIdent(),an1.oslIdent(),an2.oslIdent()) ) angleafter = chimera.angle(an0.xformCoord(),an1.xformCoord(),an2. xformCoord()) print str(angleold)+" "+str(anglenew)+" "+str(angleafter)if anglenew>angleold:rc("mcopy #0 #1 settings x")else:rc("mcopy #1 #0 settings x")rc("close all")rc("stop now")INIT.MOL2:@<TRIPOS>MOLECULEinit.mol23 2 3 0 0NUCLEIC_ACIDNO_CHARGES@<TRIPOS>ATOM1 C 1.7324 -0.5083 0.8663 C.3 1 DA 0.00002 C -0.6180 0.4940 -0.0060 C.3 2 DA 0.00003 C 1.2450 0.9460 1.8950 C.3 3 DA 0.0000@<TRIPOS>BOND1 1 2 12 2 3 1@<TRIPOS>SUBSTRUCTURE1 DA 1 RESIDUE 4 A DA 1 ROOT2 DA 2 RESIDUE 4 A DA 23 DA 3 RESIDUE 4 A DA 1
Chimera-users mailing list: Chimera-users@cgl.ucsf.edu
Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users