[Chimera-users] Calculating the center of mass of a ligand

Eric Pettersen pett at cgl.ucsf.edu
Tue Nov 13 11:14:27 PST 2007

Hi JD,
	There is no built-in center of mass method in Chimera.  If you've  
selected the atoms beforehand, then the below Python code will  
calculate the center of mass:

from chimera import selection, Vector
sum = 0
center = Vector(0, 0, 0)
for a in selection.currentAtoms():
	sum += a.element.mass
	center += a.element.mass * Vector(*a.coord().data())
print "center of mass:", center / sum

I've also attached it as a file that you can just use File...Open (or  
"open") to run.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: com.py
Type: text/x-python-script
Size: 221 bytes
Desc: not available
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20071113/00c0e86b/attachment.bin>
-------------- next part --------------

On Nov 13, 2007, at 7:18 AM, Jean-Didier Mar?chal wrote:

> Hi everyone,
> I have another question: what would be the easiest way to calculate  
> the
> center of mass of a given set of atoms? In particular, is there a  
> python
> module that already has this function implemented?
> I am interested in particular to find the center of mass of a ligand
> bound to a protein.
> Thanks a lot,
> JD
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users

More information about the Chimera-users mailing list