spindry.SupraMolecule

class spindry.SupraMolecule(atoms, bonds, position_matrix, cid=None, potential=None)[source]

Bases: Molecule

Representation of a supramolecule containing atoms and positions.

Parameters:
  • atoms (tuple[mch.Atom, ...]) – iterable of Atom Atoms that define the molecule.

  • bonds (tuple[mch.Bond, ...]) – iterable of Bond Bonds between atoms that define the molecule.

  • position_matrix (np.ndarray) – numpy.ndarray A (n, 3) matrix holding the position of every atom in the Molecule.

  • cid (int | None) – int, optional Conformer id of supramolecule.

  • potential (float | None) – float, optional Potential energy of Supramolecule.

Methods

get_cid

Get conformer id.

get_components

Yields each molecular component.

get_potential

Get potential energy.

init_from_components

Initialize a Supramolecule instance from components.

with_displacement

Return a displaced clone Molecule.

with_position_matrix

Return clone SupraMolecule with new position matrix.

write_xyz_content

Write basic .xyz file content of Molecule.

Attributes

cid

potential

atoms

bonds

position_matrix

classmethod init_from_components(components, cid=None, potential=None)[source]

Initialize a Supramolecule instance from components.

Parameters:
  • components (list[Molecule]) – Molecular components that define the supramolecule.

  • cid (int | None) – Conformer id of supramolecule.

  • potential (float | None) – Potential energy of Supramolecule.

Return type:

Self

get_atoms()

Yield the atoms in the molecule, ordered as input.

Return type:

abc.Iterable[Atom]

get_bonds()

Yield the bonds in the molecule, ordered as input.

Return type:

abc.Iterable[Bond]

get_centroid(atom_ids=None)

Return the centroid.

Parameters:

atom_ids (tuple | set | None) – iterable of int, optional The ids of atoms which are used to calculate the centroid. Can be a single int, if a single atom is to be used, or None if all atoms are to be used.

Returns:

The centroid of atoms specified by atom_ids.

Raises:

If atom_ids has a length of 0.

Return type:

float

get_cid()[source]

Get conformer id.

Return type:

int | None

get_components()[source]

Yields each molecular component.

Return type:

abc.Iterable[mch.Molecule]

get_num_atoms()

Return the number of atoms in the molecule.

Return type:

int

get_position_matrix()

Return a matrix holding the atomic positions.

Returns:

The array has the shape (n, 3). Each row holds the x, y and z coordinates of an atom.

Return type:

ndarray

get_potential()[source]

Get potential energy.

Return type:

float | None

get_subunits(bond_pair_ids)

Get connected graphs based on Molecule separated by bonds.

Parameters:

bond_pair_ids (tuple) – iterable of tuple of ints Iterable of pairs of atom ids with bond between them to optimize.

Returns:

The subunits of mol split by bonds defined by bond_pair_ids. Key is subunit identifier, Value is iterable of atom ids in subunit.

Return type:

subunits

with_displacement(displacement)[source]

Return a displaced clone Molecule.

Parameters:

displacement (ndarray) – The displacement vector to be applied.

Return type:

SupraMolecule

with_position_matrix(position_matrix)[source]

Return clone SupraMolecule with new position matrix.

Parameters:

position_matrix (ndarray) – A position matrix of the clone. The shape of the matrix is (n, 3).

Return type:

SupraMolecule

write_pdb_file(path)

Write basic .pdb file of Molecule to path.

Parameters:

path (str)

Return type:

None

write_xyz_content()[source]

Write basic .xyz file content of Molecule.

Return type:

list[str]

write_xyz_file(path)

Write basic .xyz file of Molecule to path.

Connectivity is not maintained in this file type!

Parameters:

path (str)

Return type:

None

atoms: tuple[mch.Atom, ...]
bonds: tuple[mch.Bond, ...]
cid: int | None = None
position_matrix: np.ndarray
potential: float | None = None