rdkit.Chem package

Subpackages

Submodules

Module contents

A module for molecules and stuff

see Chem/index.html in the doc tree for documentation

rdkit.Chem.CanonSmiles(smi, useChiral=1)

A convenience function for canonicalizing SMILES

Parameters:
  • smi (-) – the SMILES to canonicalize

  • useChiral (-) – (optional) determines whether or not chiral information is included in the canonicalization and SMILES

Returns:

the canonical SMILES

rdkit.Chem.FindMolChiralCenters(mol, force=True, includeUnassigned=False, includeCIP=True, useLegacyImplementation=None)

returns information about the chiral centers in a molecule

Parameters:
  • mol (-) – the molecule to work with

  • force (-) – (optional) if True, stereochemistry will be assigned even if it has been already

  • includeUnassigned (-) – (optional) if True, unassigned stereo centers will be included in the output

  • includeCIP (-) – (optional) if True, the CIP code for each chiral center will be included in the output

  • useLegacyImplementation (-) – (optional) if True, the legacy stereochemistry perception code will be used

Returns:

a list of tuples of the form (atomId, CIPCode)

>>> from rdkit import Chem
>>> mol = Chem.MolFromSmiles('[C@H](Cl)(F)Br')
>>> Chem.FindMolChiralCenters(mol)
[(0, 'R')]
>>> mol = Chem.MolFromSmiles('[C@@H](Cl)(F)Br')
>>> Chem.FindMolChiralCenters(mol)
[(0, 'S')]
>>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('CCC'))
[]

By default unassigned stereo centers are not reported:

>>> mol = Chem.MolFromSmiles('C[C@H](F)C(F)(Cl)Br')
>>> Chem.FindMolChiralCenters(mol,force=True)
[(1, 'S')]

but this can be changed:

>>> Chem.FindMolChiralCenters(mol,force=True,includeUnassigned=True)
[(1, 'S'), (3, '?')]

The handling of unassigned stereocenters for dependent stereochemistry is not correct using the legacy implementation:

>>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1CC(C)C(C)C(C)C1'),includeUnassigned=True)
[(2, '?'), (6, '?')]
>>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1C[C@H](C)C(C)[C@H](C)C1'),includeUnassigned=True)
[(2, 'S'), (4, '?'), (6, 'R')]

But works with the new implementation:

>>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1CC(C)C(C)C(C)C1'),includeUnassigned=True, useLegacyImplementation=False)
[(2, '?'), (4, '?'), (6, '?')]

Note that the new implementation also gets the correct descriptors for para-stereochemistry:

>>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1C[C@H](C)[C@H](C)[C@H](C)C1'),useLegacyImplementation=False)
[(2, 'S'), (4, 's'), (6, 'R')]

With the new implementation, if you don’t care about the CIP labels of stereocenters, you can save some time by disabling those:

>>> Chem.FindMolChiralCenters(Chem.MolFromSmiles('C1C[C@H](C)[C@H](C)[C@H](C)C1'), includeCIP=False, useLegacyImplementation=False)
[(2, 'Tet_CCW'), (4, 'Tet_CCW'), (6, 'Tet_CCW')]

rdkit.Chem.QuickSmartsMatch(smi, sma, unique=True, display=False)

A convenience function for quickly matching a SMARTS against a SMILES

Parameters:
  • smi (-) – the SMILES to match

  • sma (-) – the SMARTS to match

  • unique (-) – (optional) determines whether or not only unique matches are returned

  • display (-) – (optional) IGNORED

Returns:

a list of list of the indices of the atoms in the molecule that match the SMARTS

rdkit.Chem.SupplierFromFilename(fileN, delim='', **kwargs)

A convenience function for creating a molecule supplier from a filename

Parameters:
  • fileN (-) – the name of the file to read from

  • delim (-) – (optional) the delimiter to use for reading the file (only for csv and txt files)

  • kwargs (-) – additional keyword arguments to be passed to the supplier constructor

Returns:

a molecule supplier