schrodinger.thirdparty.rdkit_adapter module¶
Conversions between Schrodinger structure objects (mmct) and RDKit mol objects.
There are some structural/philosophic differences between these two formats, stemming from their distinct origins (RDKit being originally used for chemiformatics, and schrodinger/mmct being originally used for molecular modeling.)
Notably: Schrodinger wants all atoms to have positions in space. RDKit allows unspecified position, or multiple conformers.
Schrodinger wants all Hydrogens to be fully specified (position and bonding). My understanding is that RDKit has three types of hydrogens:
* Implicit - calculated based on valence. These are not shown in SMILES.
* Explicit - as a property of the associated heavy atom. These are shown in
SMILES like [cH]
* Included in connectivity graph - (only these can have coordinates or
other properties). These are show in SMILES like c([H]).
There are other distinctions, for instance Schrodinger is aware of dative, or zero-order bonds, whereas RDKit is aware of aromatic and conjugated bonds.
-
exception
schrodinger.thirdparty.rdkit_adapter.
InconsistentStructureError
¶ Bases:
ValueError
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
schrodinger.thirdparty.rdkit_adapter.
UnsupportedStructureError
¶ Bases:
NotImplementedError
For structures that can’t be translated between RDKit and Schrodinger yet
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
schrodinger.thirdparty.rdkit_adapter.
to_rdkit
(st, implicitH=False, include_properties=True, include_coordinates=True)¶ Create a RdKit molecule from a Schrodinger structure (aka mmct).
Parameters: - st (schrodinger.structure.Structure) – The schrodinger structure to be translated to RDKit. The input structure remains unmodified.
- implicitH (bool) – Should hydrogens be listed implicitly? If False, hydrogens will be included in the connectivity graph, and 3D coordinates and properties of the hydrogens will be translated. Some pattern matching in RDKit requires implicit hydrogens, however.
- include_properties (bool) – Should atom and structure level properties be copied from the schrodinger structure to the RDKit mol?
- include_coordinates – Should the coordinates of the structure be copied to a conformer associated with the RDKit mol?
Returns: An rdkit mol representing the same structure as the input st
Return type: rdkit.Mol
Raises: InconsistentStructureError – if the input structure has inconsistent or incorrect stereochemical labels.
-
schrodinger.thirdparty.rdkit_adapter.
from_rdkit
(mol, include_properties=True, generate_coordinates=False, conformer=None)¶ Create a Schrodinger structure from an RdKit molecule.
For correct behavoir, requires that the RdKit molecule be sanitized beforehand.
If the RDKit molecule does not have 3d structure, one can be generated using fast3d.
Parameters: - mol (rdkit.Mol) – RDKit mol to be converted to Schrodinger space. It will not be modified.
- include_properties (bool) – Should atom and molecule properties be copied from the RDKit mol?
- generate_coordinates (bool) – Should 3D coordinates be generated if the RDKit mol does not have associated coordinates? Uses fast3d.
- conformer (NoneType or int) – If the RDKit mol has more than one associated conformer, choose one to turn into a Schrodinger structure.
Returns: A schrodinger.Structure representing the same molecule as the input mol
Return type: schrodinger.Structure
Raises: ValueError – If there is more than one conformer associated with the structure or if a specific conformer is requested and is unavailable.
-
schrodinger.thirdparty.rdkit_adapter.
translate_rdkit_props_dict
(props)¶ Make a copy of a property dict like the one returned by mol.GetPropsAsDict, in which property names that don’t look like mmct properties are prefixed with <typechar>_rdkit_.
Parameters: props (dict) – property dictionary Returns: new property dictionary Return type: dict
-
schrodinger.thirdparty.rdkit_adapter.
annotate
(mol)¶ Annotate atoms with index to allow mapping back and forth.
-
schrodinger.thirdparty.rdkit_adapter.
copy_lewis_structure_and_hydrogens
(st, mol, kekulize=True)¶ Applies bond orders and charges from st to mol. Updates #implicitH to match
Assumes st includes all hydrogens. Adds implicit and explicit hydrogens to the mol, but does not add any graph hydrogens. May remove graph hydrogens.