oxmol.molecule module

Representation of a whole molecule.

This is a thin wrapper around the PyO3 base class: it calls the base class’ __new__ constructor and return an instance of the base class.

At present, it doesn’t seem to be possible to truly subclass PyO3 classes from Python, so this is all we are able to do on the Python end.

class oxmol.molecule.Molecule

Bases: oxmol.oxmol.PyDefaultMolecule

A molecular representation. This class is ultimately a representation of chemcore::molecule::DefaultMolecule.

Parameters:
  • atoms – a list of PyAtomSpec
  • bonds – a list of PyBondSpec

Attributes

  • nodes - a list of the atom indices
  • edges - a list of tuple of two atom indices, representing the bonds
atom_parity(atom_id: int) → Optional[oxmol.oxmol.PyParity]

Given an atom ID, return the atom’s tetrahedral chirality.

Parameters:atom_id – the atom index
Returns:the tetrahedral chirality of the atom.
bond_order(sid: int, tid: int) → oxmol.oxmol.PyBondOrder

Given a start atom ID and target atom ID, return the order of the bond between the two atoms.

Parameters:
  • sid – the atom index of the start of the bond
  • tid – the atom index of the target of the bond
Returns:

the order of the bond between the atoms.

bond_parity(sid: int, tid: int) → Optional[oxmol.oxmol.PyParity]

Given a start atom ID and target atom ID, return the stereochemistry of the bond between the two atoms.

Parameters:
  • sid – the atom index of the start of the bond
  • tid – the atom index of the target of the bond
Returns:

the stereochemistry of the bond between the atoms.

charge(atom_id: int) → int

Given an atom ID, return the atom’s formal charge.

Parameters:atom_id – the atom index
Returns:the atom’s formal charge
degree(atom_id: int) → int

Given an atom ID, return the number of explicit connections the atom has.

Parameters:atom_id – the atom index
Returns:the number of connections that the atom has.
electrons(atom_id: int) → int

Given an atom ID, return the number of nonbonding electrons the atom has in its valence shell.

Parameters:atom_id – the atom index
Returns:the number of nonbonding electrons in the atom’s valence shell
element(atom_id: int) → oxmol.oxmol.PyElement

Given an atom ID, return the element of that atom.

Parameters:atom_id – the atom index
Returns:the element of the atom
has_edge(sid: int, tid: int) → bool

Given a start atom ID and target atom ID, return a bool indicating whether a bond exists between the two atoms.

Parameters:
  • sid – the atom index of the start of the bond
  • tid – the atom index of the target of the bond
Returns:

whether the bond exists in the molecule

has_node(atom_id: int) → bool

Given an atom ID, return a bool indicating whether the atom exists in the molecule.

Parameters:atom_id – the atom index
Returns:whether the atom exists in this molecule
hydrogens(atom_id: int) → int

Given an atom ID, return the number of virtual hydrogens the atom has.

Parameters:atom_id – the atom index
Returns:the number of virtual hydrogens on the atom
is_empty() → bool

Return whether the molecule contains atoms.

isotope(atom_id: int) → Optional[int]

Given an atom ID, return the isotope of that atom if it has been ascribed one. Otherwise, return None.

Parameters:atom_id – the atom index
Returns:the isotope, if it has been set, otherwise None
neighbors(atom_id: int) → List[int]

Given an atom ID, return the indices of the atom’s neighbors.

Parameters:atom_id – the atom index
Returns:a list of indices of the atom’s direct connections
order() → int

Return how many atoms are in the molecule.

size() → int

Return how many bonds are in the molecule.