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(Molecule mol, aug_inchi, bool raise_atomtype_exception=True) Molecule

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(Molecule mol, unicode inchistr, backend=u'try-all', bool raise_atomtype_exception=True) Molecule

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

rmgpy.molecule.translator.from_smarts(Molecule mol, unicode smartsstr, unicode backend=u'rdkit', bool raise_atomtype_exception=True) Molecule

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(Molecule mol, unicode smilesstr, unicode backend=u'try-all', bool raise_atomtype_exception=True) Molecule

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

rmgpy.molecule.translator.to_inchi(Molecule mol, unicode backend=u'rdkit-first', int aug_level=0) unicode

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) –

  • 'try-all'

  • 'rdkit'

  • 'openbabel' (or) –

  • augmentation (aug_level level of) –

  • 0

  • 1

  • 2 (or) –

rmgpy.molecule.translator.to_inchi_key(Molecule mol, unicode backend=u'rdkit-first', int aug_level=0) unicode

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) –

  • 'try-all'

  • 'rdkit'

  • 'openbabel' (or) –

  • augmentation (aug_level level of) –

  • 0

  • 1

  • 2 (or) –

rmgpy.molecule.translator.to_smarts(Molecule mol, backend=u'rdkit') unicode

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(Molecule mol, backend=u'default') unicode

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.