# getting the center of mass of each part of a molecule

```On 05/15/2017 01:29 PM, qasimpars at gmail.com wrote:
> Hi,
>
> I need to get the center of mass (COM) of each half of the ligand shown in the figure (https://i.stack.imgur.com/dtdul.png). I get the main COM all the ligand, lets say it is close to C1 atom. In addition to the main COM of all the ligand, I need to find the COM of each half of the ligand. The atoms of the first part/half according to the main COM of the ligand are C2, C7, C8 and C9. As for the second part they are C3, C4, C5 and C6 atoms. The question is how can I divide the ligand in two parts according to the main COM and calculate the COM of each divided part (except for the atom closest to the main COM, C1)? By the way I have multiple ligands. The code should be user firendly.
>
> A short part of the input file is here:
>
> 1LIG     C1    1   4.434   5.366   1.780
> 1LIG     C2    2   4.317   5.301   1.940
> 1LIG     C3    3   4.430   5.286   1.888
> 1LIG     C4    4   4.380   4.942   2.467
> 1LIG     C5    5   4.148   4.929   2.443
>
> A short snippet of the code used to get the main COM is here:
>
> def heavy_atoms(atoms, xyz, ligand="LIG"):
>      ids   = np.arange(len(atoms))
>      names = [(i[10:15].strip(),i[5:10].strip()) for i,j in atoms]
>
>      # Ligand atoms
>      lig_atoms = np.array([ rname == ligand and not aname.startswith('H') for aname,rname in names ])
>      lig_xyz = xyz[lig_atoms,:]
>
>      # The main COM
>      lig_com = xyz[lig_atoms, :].mean(axis=0)

You seem to be asking a chemistry or biochemistry question on this
Python programming list.  We're a diverse group, but still, that seems
to be a vast mismatch.   Do you have any hint of an algorithm that will
do what you want?  Can you find one somewhere, or define one yourself?
Once you have an algorithm, it would be appropriate to ask here for help
in translating it into a Python program.

Gary Herron

--
Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418

```