Question: How to calculate the center of mass
gravatar for M.O.L.S
10 months ago by
M.O.L.S30 wrote:

Please can I have some ideas as I just don't get it. We usually come here, after countless Google searches, not as a first resort =)

What is the center of mass of an atomic coordinate of protein? I'd like to program it using biopython

Is there a formula for it? Why is this important? How is it related to the mean?

ADD COMMENTlink modified 4 days ago by copoiuliviu0 • written 10 months ago by M.O.L.S30

With all due respect, I am not convinced that you have done countless Google searches. A single Google search with "center of mass protein biopython" returned this as a first hit. There is a section "Coarse Grain Structure" towards the end that shows a simple Biopython solution:

from Bio.Struct.Geometry import center_of_mass
ADD REPLYlink written 10 months ago by Mensur Dlakic7.3k

There is no guarantee that that function is correct...

ADD REPLYlink written 10 months ago by M.O.L.S30

Biopython is quite a mature library at this point, why would you assume that it is incorrect? (I haven't looked at the source myself)

ADD REPLYlink written 10 months ago by Joe18k

what version of biopython are u using ? I am using 1.78 and i get: 'Structure' object has no attribute 'center_of_mass'. Also I cannot find anything in the documentation of biopython.

ADD REPLYlink written 4 days ago by copoiuliviu0

If you take a look here:

the centre_of_mass function is currently not in the main development branch of the biopython repository. You would need to clone and use Joao's fork of the repo where you can see the code here:

ADD REPLYlink written 3 days ago by Joe18k
gravatar for zachschmitz97
6 months ago by
zachschmitz9710 wrote:

I had the same issue with biopython in finding the centre of mass. Although as Mensurj Dlakic suggested, there is a Struct class within Bio, this is an experimental class from JoaoRodrigues which does not appear to be implemented in any of the current versions of biopython: you can't simply "conda/pip install biopython" to access this module, but rather define it within your directory to use it.

The file which will enable you to call center_of_mass is here. Once you download this file in your directory, you can write a separate file which calls:

from Geometry import *

and proceed to call center_of_mass on any "structural object" such as the model/chain/residue of interest.

Although you can read through how Geometry does the center-of-mass calculation yourself, a summary is: Find all the atoms of the structure, create a list of the atom masses, define the center of mass=(sum each set of xyz coordinate * respective atom mass)/(sum of each atomic mass), just as you would expect per a center of mass calculation in three dimensions.

ADD COMMENTlink modified 6 months ago • written 6 months ago by zachschmitz9710
gravatar for JoaoRodrigues
5 weeks ago by
Stanford University, Stanford, USA
JoaoRodrigues10 wrote:

My GSOC branch was never fully merged in the main branch.

As of September 2020, Biopython has a native center of mass function. You can use it on any Entity (Structure, Chain, Residue, DisorderedAtom) and it returns either the center of mass or of geometry:

from Bio.PDB import PDBParser

parser = PDBParser()
structure = parser.get_structure('foo', '1abc.pdb')
com = structure.center_of_mass()

# For each chain
for chain in structure.get_chains():
ADD COMMENTlink written 5 weeks ago by JoaoRodrigues10
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1119 users visited in the last hour