pymatgen.analysis.molecule_matcher module¶
This module provides classes to perform fitting of molecule with arbitrary atom orders. This module is supposed to perform exact comparisons without the atom order correspondence prerequisite, while molecule_structure_comparator is supposed to do rough comparisons with the atom order correspondence prerequisite.
-
class
AbstractMolAtomMapper[source]¶ Bases:
monty.json.MSONableAbstract molecular atom order mapping class. A mapping will be able to find the uniform atom order of two molecules that can pair the geometrically equivalent atoms.
-
abstract
get_molecule_hash(mol)[source]¶ Defines a hash for molecules. This allows molecules to be grouped efficiently for comparison.
- Parameters
mol – The molecule. OpenBabel OBMol or pymatgen Molecule object
- Returns
A hashable object. Examples can be string formulas, etc.
-
abstract
uniform_labels(mol1, mol2)[source]¶ Pair the geometrically equivalent atoms of the molecules.
- Parameters
mol1 – First molecule. OpenBabel OBMol or pymatgen Molecule object.
mol2 – Second molecule. OpenBabel OBMol or pymatgen Molecule object.
- Returns
(list1, list2) if uniform atom order is found. list1 and list2 are for mol1 and mol2, respectively. Their length equal to the number of atoms. They represents the uniform atom order of the two molecules. The value of each element is the original atom index in mol1 or mol2 of the current atom in uniform atom order. (None, None) if unform atom is not available.
-
abstract
-
class
InchiMolAtomMapper(angle_tolerance=10.0)[source]¶ Bases:
pymatgen.analysis.molecule_matcher.AbstractMolAtomMapperPair atoms by inchi labels.
- Parameters
angle_tolerance (float) – Angle threshold to assume linear molecule. In degrees.
-
class
IsomorphismMolAtomMapper[source]¶ Bases:
pymatgen.analysis.molecule_matcher.AbstractMolAtomMapperPair atoms by isomorphism permutations in the OpenBabel::OBAlign class
-
classmethod
from_dict(d)[source]¶ - Parameters
d (dict) – Dict representation
- Returns
IsomorphismMolAtomMapper
-
uniform_labels(mol1, mol2)[source]¶ Pair the geometrically equivalent atoms of the molecules. Calculate RMSD on all possible isomorphism mappings and return mapping with the least RMSD
- Parameters
mol1 – First molecule. OpenBabel OBMol or pymatgen Molecule object.
mol2 – Second molecule. OpenBabel OBMol or pymatgen Molecule object.
- Returns
(list1, list2) if uniform atom order is found. list1 and list2 are for mol1 and mol2, respectively. Their length equal to the number of atoms. They represents the uniform atom order of the two molecules. The value of each element is the original atom index in mol1 or mol2 of the current atom in uniform atom order. (None, None) if unform atom is not available.
-
classmethod
-
class
MoleculeMatcher(tolerance=0.01, mapper=<pymatgen.analysis.molecule_matcher.InchiMolAtomMapper object>)[source]¶ Bases:
monty.json.MSONableClass to match molecules and identify whether molecules are the same.
- Parameters
tolerance (float) – RMSD difference threshold whether two molecules are different
mapper (AbstractMolAtomMapper) – MolAtomMapper object that is able to map the atoms of two molecule to uniform order
-
fit(mol1, mol2)[source]¶ Fit two molecules.
- Parameters
mol1 – First molecule. OpenBabel OBMol or pymatgen Molecule object
mol2 – Second molecule. OpenBabel OBMol or pymatgen Molecule object
- Returns
A boolean value indicates whether two molecules are the same.