[chimera-dev] Rotating models using python scripting in chimera

Eric Pettersen pett at cgl.ucsf.edu
Tue Oct 25 16:30:18 PDT 2016


Hi Kavya,
	The trouble is here:

chimera.pdbWrite(model,mol.openState.xform,mem)

By providing the molecule’s own transform as the second argument, you are having pdbWrite output the model’s coordinates relative to it’s own transformation — essentially undoing any rotations or translations that have been applied to the model.  You want to provide the identity matrix as the second argument, e.g. “chimera.Xform.identity()”.

—Eric

	Eric Pettersen
	UCSF Computer Graphics Lab


> On Oct 25, 2016, at 1:45 PM, Kavya Shankar <kavshank at umail.iu.edu> wrote:
> 
> 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
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20161025/6cb484c9/attachment.html>


More information about the Chimera-dev mailing list