scm.reactmap.Molecule

class scm.reactmap.Molecule(atoms=None, bonds=None, smiles=None, graph=None, plams_mol=None, active_atoms=None, active_bonds=None)

The main class for inputing/using reactants and products.

There are four possible ways of initializing the molecule:

  • by explicitly specifying atoms and bonds

  • using a SMILES string

  • using a networkx graph

  • using a PLAMS molecule

Keyword Arguments
  • atoms (list(str)) – a list of atomic symbols. The order in the list corresponds to the index and will be used with the bonds argument.

  • bonds (list(tuple)) – a list of pairs (e1,e2) where e1 and e2 correspond to atom indices (integers) between which there is a bond

  • smiles (str) – a SMILES string for inputting molecular structure(s)

  • graph (networkx.graph) – a networkx graph representing the molecular structure(s)

  • plams_mol (scm.plams.Molecule) – a PLAMS molecule. If bonds are not specified in the plams molecule, they will be automatically guessed.

  • active_atoms (list(int)) – a subset of the atom indices which are allowed to be mapped to an atom with a different index. Atoms outside this set will automatically be mapped using the identity function on the indices (e.g., if atom 5 is not in the active set, atom 5 in the reactants will be mapped to atom 5 in the products).

  • active_bonds (list(int)) – a subset of the bonds that are allowed to be broken (reactant) or formed (product) in a reaction. Bonds outside this set will be preserved but not necessarily mapped to atoms with the same indices.

Examples

Let’s input acetone first using the atoms and bonds arguments:

import scm.reactmap as rm
reactant = rm.Molecule(atoms=['C','C','C','O','H','H','H','H','H','H'],bonds=[(0,1),(1,2),(1,3),(0,4),(0,5),(0,6),(3,7),(3,8),(3,9)])

And now as a SMILES sting using the smiles keyword argument:

reactant = rm.Molecule(smiles="CC(=O)C")

Attributes

H2_count

The number of H2 molecules in this Molecule object.

active_atoms

A list of the indices of the active atoms for the Molecule instance

active_bonds

A list of the active bonds for the Molecule instance

assignable_atoms

Atoms which can be assigned to a different (non-identity) index.

implicitH_valid

True if the Molecule object can be used with the implicitH description of the system; Otherwise, False (e.g., if there are hypervalent Hydrogens).

neigh

A list of lists containing neighbor atom indices.

neigh_type

A list of lists containing neighbor atom types

Methods

get_atom_implicitH(a: int)

This function returns the number of implicit Hydrogens for the atom with index a. If implicit Hydrogens are not being used, this function returns 0.

Parameters

a (int) – the index of the atom

Returns

the number of implicit Hydrogens bonded to atom a

Return type

int

get_graph(implicitH: Optional[bool] = None)

The networkx graph representation of the chemical structure(s).

Note

The graph instance will only be calculated a single time as it is assumed that the reactant/product molecules will not change after input. This prevents redundant computations if the graph is needed in multiple places.

Keyword Arguments

implicitH (bool) – whether or not to return the graph with implicit Hydrogens

Returns

a networkx.graph instance