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.
Thanks.