Hi Kavya, You can get the centroid of your model with:
from StructMeasure import centroid
c = centroid([a.xformCoord() for a in model.atoms])
(… possibly coord() instead of xformCoord() if you want the centroid in the model’s original coordinate frame). The centroid() function returns a chimera.Point object. Point has .x(), .y(), and .z() methods, or a .data() method to get a 3-tuple of floats. You can get a translation matrix with:
xf = chimera.Xform.translate(*c.data())
It’s a weakness of Chimera that there isn’t really good documentation for these kind of manipulation functions (one of the things we will remedy in ChimeraX). You either have to find code in Chimera which does the same kind of things and adapt that, or open the IDLE shell (in General Controls) and use Python inspection to see the capabilities of various classes (e.g. help(chimera.Xform) would have revealed the ‘translate’ method). Don’t be shy about asking questions on chimera-dev if you have problems; it’s what it’s for!
—Eric
Eric Pettersen
UCSF Computer Graphics Lab
Hi,
I am attempting to find the centroid of a protein and then translating it based on the output. Is there any function that does this?
model = chimera.openModels.open('test_python/'+filename)
mol = model[0]
axis = chimera.Vector(1,1,1)
angle = 180
xf = chimera.Xform.rotation(axis,angle)
I am using chimera.Xform functions for my implementation.
Also, Is there a documentation that lists down all functions that are currently available to manipulate proteins?
Thank you.
Regards,
Kavya Shankar
_______________________________________________
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.eduhttp://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev