moleculekit.tools.graphalignment module#

moleculekit.tools.graphalignment.compareGraphs(G, H, fields=('element',), tolerance=0.5, returnmatching=False)#
moleculekit.tools.graphalignment.createProductGraph(G, H, tolerance, fields)#
moleculekit.tools.graphalignment.makeMolGraph(mol, sel, fields)#
moleculekit.tools.graphalignment.maximalSubstructureAlignment(mol1, mol2, sel1='all', sel2='all', fields=('element',), tolerance=0.5, visualize=False)#

Aligns two molecules on the largest common substructure

Parameters:
  • mol1 (Molecule) – The reference molecule on which to align

  • mol2 (Molecule) – The second molecule which will be rotated and translated to align on mol1

  • sel1 (str) – Atom selection string of the atoms of mol1 to align. See more here

  • sel2 (str) – Atom selection string of the atoms of mol2 to align. See more here

  • fields (tuple) – A tuple of the fields that are used to match atoms

  • tolerance (float) – How different can distances be between to atom pairs for them to match in the product graph

  • visualize (bool) – If set to True it will visualize the alignment

Returns:

newmol – A copy of mol2 aligned on mol1

Return type:

Molecule

moleculekit.tools.graphalignment.mcsAtomMatching(mol1, mol2, atomCompare='elements', bondCompare='any', _logger=True)#

Maximum common substructure atom matching.

Given two molecules it will find their maximum common substructure using rdkit and return the atoms in both molecules which matched.

Parameters:
  • mol1 (Molecule) – The first molecule

  • mol2 (Molecule) – The second molecule

  • atomCompare (str) – Which features of the atoms to compare. Can be either: “any”, “elements” or “isotopes”

  • bondCompare (str) – Which features of the bonds to compare. Can be either: “any”, “order” or “orderexact”

Returns:

  • atm1 (list) – A list of atom indexes of the first molecule which matched to the second

  • atm2 (list) – A list of atom indexes of the second molecule which matched to the first

Examples

>>> mol1 = Molecule("OIC.cif")
>>> mol1.atomtype = mol1.element
>>> mol2 = Molecule("5vbl")
>>> mol2.filter("resname OIC")
>>> atm1, atm2 = mcsAtomMatching(mol1, mol2, bondCompare="any")
>>> print(mol1.name[atm1], mol2.name[atm2])
['N' 'CA' 'C' 'O' 'CB' 'CG' 'CD' 'C7' 'C6' 'C5' 'C4'] ['N' 'CA' 'C' 'O' 'CB' 'CG' 'CD' 'C7' 'C6' 'C5' 'C4']