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='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.
str
getStandardizedSmiles(self, struc)
Get a SMILES string representing the standardized version of a structure by neutralizing the structure first.
 
getUniqueOrder(self, struct)
Returns a canonicalized ordering of atoms in the given structure.
 
canonicalize(self, pattern)
Return canonicalized (unique) version of the specified SMILES string.
Method Details [hide private]

__init__(self, stereo='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().

getStandardizedSmiles(self, struc)

 

Get a SMILES string representing the standardized version of a structure by neutralizing the structure first. This ensures different ionization states of the same compound produce the same SMILES. Different tautomers will still generate different SMILES. To check whether different input structures are tautomers of each other, analyze.generate_tautomer_code() can be used.

Parameters:
  • struc (schrodinger.strucgture.Structure) - Structure to get the standardized SMILES string for.
Returns: str
Standardized SMILES string

getUniqueOrder(self, struct)

 

Returns a canonicalized ordering of atoms in the given structure.
NOTE: Structure MUST contain all hydrogens.
NOTE: Uniqueness process does not consider atom coordinates, so
      symmetrically equivalent atoms will have arbitrarily assigned
      ordering. In other words, identical conformers are likely to
      have a >0 RMSD after renumbering.

@type struct: L{structure.Structure}
@param struct: The Structure object from which to generate the
    SMILES string.

@rtype: list
@return: List of canonically ordered atom indices, which can be
    passed directly to build.reorder_atoms().