[chimera-dev] Rotating models using python scripting in chimera
Kavya Shankar
kavshank at umail.iu.edu
Tue Oct 25 13:45:21 PDT 2016
Hi,
I am new to chimera and I am attempting to write a python script that would
rotate the models by some angle and then writing it to another pdb file
with changed coordinates.
import chimera
import os
from cStringIO import StringIO
for filename in os.listdir("test_python"):
print filename
model = chimera.openModels.open('test_python/'+filename)
mol = model[0]
axis = chimera.Vector(1,1,1)
angle = 180
xf = chimera.Xform.rotation(axis,angle)
matrix = chimera.Xform.getOpenGLMatrix(xf)
print mol.openState.xform
mol.openState.localXform(xf)
print mol.openState.xform
mem =StringIO()
chimera.pdbWrite(model,mol.openState.xform,mem)
print mol.openState.xform
with open('converted.pdb','w') as f:
f.write(mem.getvalue())
This is my code so far. When I run it, the converted.pdb file does not
contain any changed coordinates. The coordinates of the atoms are same as
before.
Am I making some mistake? Is there any other way of doing this easily?
Thanks.
Regards,
Kavya Shankar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20161025/d734a80f/attachment.html>
More information about the Chimera-dev
mailing list