Package schrodinger :: Package structutils :: Module smiles :: Class SmilesGenerator
[hide private]
[frames] | no frames]

Class SmilesGenerator

A class to generate a SMILES string from a Structure object.

This is just a thin wrapper to the canvaslibs_ext classes.

Instance Methods [hide private]
 
__init__(self, stereo=STEREO_FROM_ANNOTATION_AND_GEOM, unique=True, safe=True, wantAllH=False, forceAllBondOrders=False, wildcardAllAtoms=False)
Construct a SmilesGenerator with specific behavior for stereochemistry and unique smiles.
 
getSmiles(self, struct)
Returns a SMILES string for a structure.
(str, list)
getSmilesAndMap(self, struct)
Returns a SMILES string and index mapping of the atoms in a structure.
 
canonicalize(self, pattern)
Return canonicalized (unique) version of the specified SMILES string.
Method Details [hide private]

__init__(self, stereo=STEREO_FROM_ANNOTATION_AND_GEOM, unique=True, safe=True, wantAllH=False, forceAllBondOrders=False, wildcardAllAtoms=False)
(Constructor)

 

Construct a SmilesGenerator with specific behavior for stereochemistry and unique smiles.

Parameters:
  • stereo - This should be set to one of the module level constants and will specify behavior in the getSmiles method. Can be one of the following (default is STEREO_FROM_ANNOTATION_AND_GEOM):
    • STEREO_FROM_ANNOTATION_AND_GEOM - Derive stereochemistry from annotations, but use the 3D coordinates when no annotation is present. This is the same behavior as the old STEREO_FROM_3D option, which is deprecated.
    • STEREO_FROM_ANNOTATION - Derive stereochemistry from pre-existing mmstereo properties (faster, so useful when structures are known to be 2D).
    • STEREO_FROM_GEOMETRY - Derive stereochemistry from the 3D coordinates only (for 3D structures). Annotations are used for 2D structures.
    • NO_STEREO - Don't include stereochemistry.
  • unique (bool) - If True, generate unique (a.k.a. canonical) SMILES.
  • safe (bool) - If True, use only stereochemistry from mmstereo that is deemed "safe" by the Canvas libraries. If False, use all stereochemistry info from mmstereo. This is relevant for the STEREO_FROM_GEOMETRY, STEREO_FROM_ANNOTATION, and STEREO_FROM_ANNOTATION_AND_GEOM options of the stereo argument.
  • wantAllH (bool) - If True, each hydrogen receives its own SMILES token
  • forceAllBondOrders (bool) - If True, all bond orders in the SMILES will be explicit. By default, aromatic and single bond orders (C-C, c:c) are suppressed.
  • wildcardAllAtoms (bool) - If True, all heavy atoms will appear as asterisks when calling getSmiles(). Ignored when calling getSmilesAndMap()

getSmiles(self, struct)

 

Returns a SMILES string for a structure. Use the wantAllH option when initializing the SmilesGenerator instance if hydrogens are needed.

Parameters:
  • struct - The Structure object from which to generate the SMILES string.

getSmilesAndMap(self, struct)

 

Returns a SMILES string and index mapping of the atoms in a structure. Use the wantAllH option when initializing the SmilesGenerator instance to speicify whether hydrogens should be included (default is to include heavy atoms only).

Parameters:
  • struct - The Structure object from which to generate the SMILES string.
Returns: (str, list)
SMILES string, and a list of new atom indices, which can be passed directly to build.reorder_atoms().