Get center#
Getting the geometric center or center of mass of a molecular system.
The function molsysmt.structure.get_center() computes the geometric center, center of mass, or custom weighted center of a molecular system across all structures or frames.
Added in version 1.0.0.
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function: molsysmt.structure.get_center().
Basic usage#
Let’s show how to calculate the center of geometry of a pentalanine trajectory:
import molsysmt as msm
import numpy as np
molsys = msm.convert(msm.systems['pentalanine']['traj_pentalanine.h5'], to_form='molsysmt.MolSys')
Note
Demo Systems Catalog
This tutorial uses demonstration datasets provided by MolSysMT. To explore the full catalog of bundled systems, forms, and file paths, visit the Demo Systems guide.
By default, molsysmt.structure.get_center() computes the unweighted geometric center of all atoms:
center = msm.structure.get_center(molsys)
center.shape
(5000, 1, 3)
center[0]
| Magnitude | [[0.8281487274554468 1.1086905834174925 -0.007842551886795028]] |
|---|---|
| Units | nanometer |
Getting the center of mass#
Setting weights='masses' weights atom coordinates by their respective atomic masses to compute the physical center of mass:
center_of_mass = msm.structure.get_center(molsys, selection='group_index==0', weights='masses')
center_of_mass[0]
| Magnitude | [[0.8584538969155568 0.3675186564482274 0.029710175156011744]] |
|---|---|
| Units | nanometer |
Custom weighted center#
Explicit non-negative weights can be supplied as an array or list:
ca_atoms = msm.select(molsys, selection='atom_name=="CA"')
weights_ca = np.ones(len(ca_atoms))
ca_center = msm.structure.get_center(molsys, selection=ca_atoms, weights=weights_ca)
ca_center[0]
| Magnitude | [[0.7867356538772583 1.1155330538749695 0.047727906703948976]] |
|---|---|
| Units | nanometer |
See also
Related Tools & References
Convert: Convert molecular systems between different forms with
molsysmt.basic.convert().Center: Translate coordinates so that the center of geometry coincides with the origin with
molsysmt.structure.center().Select: Query atom or group indices with selection syntax using
molsysmt.basic.select().Get distances: Measure distances between centers or atoms with
molsysmt.structure.get_distances().