rmgpy.molecule.translator

This module provides methods for translating to and from common molecule representation formats, e.g. SMILES, InChI, SMARTS.

rmgpy.molecule.translator.from_augmented_inchi(mol, aug_inchi, raise_atomtype_exception)

Creates a Molecule object from the augmented inchi.

First, the inchi is converted into a Molecule using the backend parsers.

Next, the multiplicity and unpaired electron information is used to fix a number of parsing errors made by the backends.

Finally, the atom types of the corrected molecule are perceived.

Returns a Molecule object

rmgpy.molecule.translator.from_inchi(mol, inchistr, backend, raise_atomtype_exception)

Convert an InChI string inchistr to a molecular structure. Uses a user-specified backend for conversion, currently supporting ‘openbabel-first’ (default), rdkit-first, rdkit, and openbabel.

rmgpy.molecule.translator.from_smarts(mol, smartsstr, backend, raise_atomtype_exception)

Convert a SMARTS string smartsstr to a molecular structure. Uses RDKit to perform the conversion. This Kekulizes everything, removing all aromatic atom types.

rmgpy.molecule.translator.from_smiles(mol, smilesstr, backend, raise_atomtype_exception)

Convert a SMILES string smilesstr to a molecular structure. Uses a user-specified backend for conversion, currently supporting openbabel-first (default), rdkit-first, rdkit and openbabel.

rmgpy.molecule.translator.to_inchi(mol, backend, aug_level)

Convert a molecular structure to an InChI string. For aug_level=0, generates the canonical InChI. For aug_level=1, appends the molecule multiplicity. For aug_level=2, appends positions of unpaired and paired electrons.

Uses RDKit or OpenBabel for conversion.

Parameters:
  • backend (backend choice of) –

  • 'rdkit-first' (default) –

  • augmentation (aug_level level of) –

  • 0

  • 1

  • 2 (or) –

rmgpy.molecule.translator.to_inchi_key(mol, backend, aug_level)

Convert a molecular structure to an InChI Key string. For aug_level=0, generates the canonical InChI. For aug_level=1, appends the molecule multiplicity. For aug_level=2, appends positions of unpaired and paired electrons.

Uses RDKit or OpenBabel for conversion.

Parameters:
  • backend (backend choice of) –

  • 'rdkit-first' (default) –

  • augmentation (aug_level level of) –

  • 0

  • 1

  • 2 (or) –

rmgpy.molecule.translator.to_smarts(mol, backend)

Convert a molecular structure to an SMARTS string. Uses RDKit to perform the conversion. Perceives aromaticity and removes Hydrogen atoms.

rmgpy.molecule.translator.to_smiles(mol, backend)

Convert a molecular structure to an SMILES string.

If there is a Nitrogen/Sulfur atom present it uses OpenBabel to perform the conversion, and the SMILES may or may not be canonical.

Otherwise, it uses RDKit to perform the conversion, so it will be canonical SMILES. While converting to an RDMolecule it will perceive aromaticity and removes Hydrogen atoms.