spyrmsd.molecule module

class spyrmsd.molecule.Molecule(atomicnums: Union[ndarray, List[int]], coordinates: Union[ndarray, List[List[float]]], adjacency_matrix: Optional[Union[ndarray, List[List[int]]]] = None)[source]

Bases: object

center_of_geometry() ndarray[source]

Center of geometry.

Returns

Center of geometry

Return type

np.ndarray

center_of_mass() ndarray[source]

Center of mass.

Returns

Center of mass

Return type

np.ndarray

Notes

Atomic masses are cached.

classmethod from_obabel(obmol, adjacency: bool = True)[source]

Constructor from OpenBabel molecule.

Parameters
  • obmol – OpenBabel molecule

  • adjacency – Flag to compute the adjacency matrix

Returns

spyrmsd Molecule

Return type

spyrmsd.molecule.Molecule

classmethod from_rdkit(rdmol, adjacency: bool = True)[source]

Constructor from RDKit molecule.

Parameters
  • rdmol – RDKit molecule

  • adjacency – Flag to compute the adjacency matrix

Returns

spyrmsd Molecule

Return type

spyrmsd.molecule.Molecule

rotate(angle: float, axis: Union[ndarray, List[float]], units: str = 'rad') None[source]

Rotate molecule.

Parameters
  • angle (float) – Rotation angle

  • axis (np.ndarray) – Axis of rotation (in 3D)

  • units ({“rad”, “deg”}) – Units of the angle (radians rad or degrees deg)

strip() None[source]

Strip hydrogen atoms.

to_graph()[source]

Convert molecule to graph.

Returns

Molecular graph.

Return type

Graph

Notes

If the molecule does not have an associated adjacency matrix, a simple bond perception is used.

The molecular graph is cached per backend.

translate(vector: Union[ndarray, List[float]]) None[source]

Translate molecule.

Parameters

vector (np.ndarray) – Translation vector (in 3D)

spyrmsd.molecule.coords_from_molecule(mol: Molecule, center: bool = False) ndarray[source]

Atomic coordinates from molecule.

Parameters
  • mol (molecule.Molecule) – Molecule

  • center (bool) – Center flag

Returns

Atomic coordinates (possibly centred)

Return type

np.ndarray

Notes

Atomic coordinates are centred according to the center of geometry, not the center of mass.