schrodinger.structutils.smiles module

A module for generating SMILES and unique SMILES strings.

Provides python access to the classes in the canvaslibs_ext directory.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.structutils.smiles.get_property_name(stereo)

Return the default m2io property name for the unique SMILES string with the type of stereochemistry given in ‘stereo’.

Parameters:stereo – Any of the module level variables NO_STEREO, STEREO_FROM_GEOMETRY, STEREO_FROM_ANNOTATION, or STEREO_FROM_ANNOTATION_AND_GEOM, or values from the actual enum in the ChmMmctAdaptor class.
schrodinger.structutils.smiles.remove_stereo_annotation(struct)

There is no current option in the SmilesGenerator that can be used to determine stereochemical information from the 3d geometry only. The STEREO_FROM_3D option does not override any stereochemical annotations that are already present in a structure.

If you want the stereochemistry to be determined by the 3d geometry only, use this function to remove any existing stereochemical annotations.

This is a recognized issue that will be addressed in future releases in a backwards compatible way.

class schrodinger.structutils.smiles.SmilesGenerator(stereo='annotation_and_geom', unique=True, safe=True, wantAllH=False, forceAllBondOrders=False, wildcardAllAtoms=False)

Bases: object

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

This is just a thin wrapper to the canvaslibs_ext classes.

__init__(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.

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(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(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.
Return type:(str, list)
Returns:SMILES string, and a list of new atom indices, which can be passed directly to build.reorder_atoms().
getStandardizedSmiles(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:Standardized SMILES string
Return type:str
getUniqueOrder(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.

Parameters:struct (structure.Structure) – The Structure object from which to generate the SMILES string.
Return type:list(int)
Returns:List of canonically ordered atom indices, which can be passed directly to build.reorder_atoms().
canonicalize(pattern)

Return canonicalized (unique) version of the specified SMILES string.

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.structutils.smiles', '__doc__': '\n A class to generate a SMILES string from a Structure object.\n\n This is just a thin wrapper to the canvaslibs_ext classes.\n\n ', '__init__': <function SmilesGenerator.__init__>, 'getSmiles': <function SmilesGenerator.getSmiles>, 'getSmilesAndMap': <function SmilesGenerator.getSmilesAndMap>, 'getStandardizedSmiles': <function SmilesGenerator.getStandardizedSmiles>, 'getUniqueOrder': <function SmilesGenerator.getUniqueOrder>, 'canonicalize': <function SmilesGenerator.canonicalize>, '__dict__': <attribute '__dict__' of 'SmilesGenerator' objects>, '__weakref__': <attribute '__weakref__' of 'SmilesGenerator' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.structutils.smiles'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)