schrodinger.analysis.reaction module¶
A module to support chemical reactions, retrosynthetic analysis, and reaction enumeration.
Examples:
# run one reaction
rxn_smarts = "[C:8][N:7][C:2]([C:1])=[O:4]>>[C:1][C:2](O)=[O:4].[N:7][C:8]"
rxn = Reaction("Amide coupling", rxn_smarts)
amide = Chem.MolFromSmiles('CC(=O)NC')
for acid, amine in rxn.apply((amide,)):
print Chem.MolToSmiles(acid)
print Chem.MolToSmiles(amine)
reverse_rxn = rxn.inverse()
# retrosynthetic analysis
reactions = read_reactions_file('reactions.json')
retrosynthesis = retrosynthesize(amide, reactions)
print retrosynthesis.asString()
for route in retrosynthesis.getRoutes():
print route.asString()
print "Starting materials:"
for sm in route.getStartingNodes():
print "-", sm
route.write('route.json')
# combinatorial enumeration from a route file
route = read_route('route.json')
synthesizer = Synthesizer(route)
for product in synthesizer.synthesizeCombinations([acids, amines]):
print Chem.MolToSmiles(product)
-
class
schrodinger.analysis.reaction.
Node
(mol=None, reagent_class=None)¶ Bases:
object
Base class for a node in a synthetic route or a retrosynthetic tree. A node is associated with a molecule and with a reagent class (both of which may be None). It is also associated with zero or more reaction instances, but the base class does not implement an API to add reaction instances because each subclass has a different policy concerning the number of reaction instances allowed.
-
__init__
(mol=None, reagent_class=None)¶
-
treeAsString
(products=True, starting_materials=True, indexes=True)¶ Return a recursive string representation of the tree (unlike __str__, which is a short representation of the current node). The reaction names are always shown; starting materials and products are optional.
Parameters: - products (bool) – include reaction product SMILES
- starting_materials (bool) – include starting material SMILES
Return type: str
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n Base class for a node in a synthetic route or a retrosynthetic tree.\n A node is associated with a molecule and with a reagent class (both of\n which may be None). It is also associated with zero or more reaction\n instances, but the base class does not implement an API to add reaction\n instances because each subclass has a different policy concerning the\n number of reaction instances allowed.\n ', '__init__': <function Node.__init__>, 'treeAsString': <function Node.treeAsString>, '_asStringList': <function Node._asStringList>, '__dict__': <attribute '__dict__' of 'Node' objects>, '__weakref__': <attribute '__weakref__' of 'Node' 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.analysis.reaction'¶
-
__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)
-
-
class
schrodinger.analysis.reaction.
RetroSynthesisNode
(*a, frozen=False, **d)¶ Bases:
schrodinger.analysis.reaction.Node
A node in a retrosynthetic analysis tree. A node may have one or more reaction instances, which represent the ways of synthesizing the node in a single step.
-
__init__
(*a, frozen=False, **d)¶ Parameters: frozen (bool) – The molecule associated with the current node has frozen atoms. When generating a route, ReagentNode’s derived from the current node won’t have a reagent class, so they won’t be enumerated by default.
-
__str__
()¶ Return str(self).
-
addReactionInstance
(reaction, precursors)¶ Add a reaction instance to the current node. This represents a one-step synthesis of the node from a list of precursor nodes.
-
getRoutes
(require=None, seen=None, full_dedup=False)¶ Generate the routes from a retrosynthesis tree.
Parameters: - require (set of str) – reaction tags or names to require in each route
- seen (set of str) – set of routes that have already been seen and shouldn’t be generated again. Modified in place. This can be used to prevent duplicates when generating routes from multiple retrosynthesis trees.
- full_dedup (bool) – “full deduplication”: do not generate routes consisting of the same reaction path but with different molecules
Returns: generator of routes (RouteNode)
Return type: generator
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A node in a retrosynthetic analysis tree. A node may have one or more\n reaction instances, which represent the ways of synthesizing the node\n in a single step.\n ', '__init__': <function RetroSynthesisNode.__init__>, '__str__': <function RetroSynthesisNode.__str__>, 'addReactionInstance': <function RetroSynthesisNode.addReactionInstance>, '_getRoutes': <function RetroSynthesisNode._getRoutes>, 'getRoutes': <function RetroSynthesisNode.getRoutes>})¶
-
__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.analysis.reaction'¶
-
__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
-
__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)
-
treeAsString
(products=True, starting_materials=True, indexes=True)¶ Return a recursive string representation of the tree (unlike __str__, which is a short representation of the current node). The reaction names are always shown; starting materials and products are optional.
Parameters: - products (bool) – include reaction product SMILES
- starting_materials (bool) – include starting material SMILES
Return type: str
-
-
class
schrodinger.analysis.reaction.
RouteNode
(mol=None, reagent_class=None)¶ Bases:
schrodinger.analysis.reaction.Node
A node in a synthetic route. Similar to RetroSynthesisNode, except that it can have one reaction instance at most. Also, RouteNode provides additional methods that only make sense for a synthetic route.
-
__str__
()¶ Return str(self).
-
precursors
¶ The list of precursors of this node (may be empty).
-
reaction_instance
¶ The reaction instance associated with this node. If the node has no reaction instance, raises KeyError.
-
reaction
¶ The reaction associated with this node. If the node has no reaction instance, raises KeyError.
-
isStartingMaterial
()¶ Return True if the node represents a starting material (i.e., has no reaction instance).
-
getStartingNodes
()¶ Search recursively and return the Node objects for all the starting materials in the route.
Return type: list of Node-derived objects
-
setReactionInstance
(reaction, precursors)¶ Set the reaction instance to the current node. This represents a one-step synthesis of the node from a list of precursor nodes.
-
steps
()¶ Return the total number of steps in the route. For example, the following synthesis has 3 steps but depth 2.
Target => A + B A => AA B => BBReturn type: int
-
depth
(_depth=0)¶ Return the maximum depth of the route. See example under steps().
Return type: int
-
write
(filename, self_contained=False)¶ Write a route file.
Parameters: - filename (str) – File to write.
- self_contained (bool) – Write a “self-contained route file”, which includes the reactions used by the route?
-
getTreeData
(self_contained=False)¶ Return a simple data structure, suitable for dumping to JSON, representing the route. See write() for more details.
Parameters: self_contained (bool) – Return the data for a “self-contained route file”, which includes the reactions used by the route? Returns: contents of route file Return type: dict
-
getReactionSet
()¶ Return the set of reactions used by the route.
-
checkReactions
(reqs)¶ Check that the route meets all requirements. Every element of ‘reqs’ must match a tag or reaction name for at least one of the reactions used by the route. Tag matching is exact; name matching uses shell-like globbing (*, ?, []).
Returns: True if route meets requirements. Return type: bool
-
getReactionSmiles
()¶ Return a representation of the current node as a reaction SMILES (not SMARTS!). The SMILES are kekulized and with explicit single bonds where applicable, to maximize compatibility with the sketcher.
Returns: reaction SMILES (retrosynthetic) Return type: str
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A node in a synthetic route. Similar to RetroSynthesisNode, except that it\n can have one reaction instance at most. Also, RouteNode provides additional\n methods that only make sense for a synthetic route.\n ', '__str__': <function RouteNode.__str__>, 'precursors': <property object>, 'reaction_instance': <property object>, 'reaction': <property object>, 'isStartingMaterial': <function RouteNode.isStartingMaterial>, 'getStartingNodes': <function RouteNode.getStartingNodes>, 'setReactionInstance': <function RouteNode.setReactionInstance>, 'steps': <function RouteNode.steps>, 'depth': <function RouteNode.depth>, 'write': <function RouteNode.write>, 'getTreeData': <function RouteNode.getTreeData>, '_getTreeData': <function RouteNode._getTreeData>, '_getNodeData': <function RouteNode._getNodeData>, 'getReactionSet': <function RouteNode.getReactionSet>, 'checkReactions': <function RouteNode.checkReactions>, 'getReactionSmiles': <function RouteNode.getReactionSmiles>})¶
-
__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__
(mol=None, reagent_class=None)¶
-
__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.analysis.reaction'¶
-
__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
-
__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)
-
treeAsString
(products=True, starting_materials=True, indexes=True)¶ Return a recursive string representation of the tree (unlike __str__, which is a short representation of the current node). The reaction names are always shown; starting materials and products are optional.
Parameters: - products (bool) – include reaction product SMILES
- starting_materials (bool) – include starting material SMILES
Return type: str
-
-
class
schrodinger.analysis.reaction.
ReagentNode
(mol=None, reagent_class=None, filename=None, smiles=None, smiles_list=None)¶ Bases:
schrodinger.analysis.reaction.RouteNode
A node representing a starting material in a synthetic route. Unlike RouteNode, it cannot have any reaction instances. Reagent nodes are identified by a reagent class.
Reagents may optionally have a filename or a smiles or a list of smiles as a source of reagent molecules. If none of these is provided, the object can try to find a reagent file based on the reagent class alone.
-
__init__
(mol=None, reagent_class=None, filename=None, smiles=None, smiles_list=None)¶
-
__str__
()¶ Return str(self).
-
findReagentFile
(libpath=None)¶ First, look for structure files matching <reagent_class>.* in the CWD. If one is found, return it. If multiple matches are found, an exception is raised. If none are found, look for <reagent_class>.csv in the mmshare data directory and return it if it exists, or None otherwise.
Parameters: libpath (list of str) – list of directories to prepend to the standard reagent library search path Returns: path to reagent file, or None if not found Return type: str Raises: ValueError if multiple matches are found in the CWD.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A node representing a starting material in a synthetic route. Unlike\n RouteNode, it cannot have any reaction instances. Reagent nodes are\n identified by a reagent class.\n\n Reagents may optionally have a filename or a smiles or a list of smiles as a\n source of reagent molecules. If none of these is provided, the object can try\n to find a reagent file based on the reagent class alone.\n ', '__init__': <function ReagentNode.__init__>, '__str__': <function ReagentNode.__str__>, 'findReagentFile': <function ReagentNode.findReagentFile>, '_getNodeData': <function ReagentNode._getNodeData>})¶
-
__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.analysis.reaction'¶
-
__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
-
__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)
-
checkReactions
(reqs)¶ Check that the route meets all requirements. Every element of ‘reqs’ must match a tag or reaction name for at least one of the reactions used by the route. Tag matching is exact; name matching uses shell-like globbing (*, ?, []).
Returns: True if route meets requirements. Return type: bool
-
depth
(_depth=0)¶ Return the maximum depth of the route. See example under steps().
Return type: int
-
getReactionSet
()¶ Return the set of reactions used by the route.
-
getReactionSmiles
()¶ Return a representation of the current node as a reaction SMILES (not SMARTS!). The SMILES are kekulized and with explicit single bonds where applicable, to maximize compatibility with the sketcher.
Returns: reaction SMILES (retrosynthetic) Return type: str
-
getStartingNodes
()¶ Search recursively and return the Node objects for all the starting materials in the route.
Return type: list of Node-derived objects
-
getTreeData
(self_contained=False)¶ Return a simple data structure, suitable for dumping to JSON, representing the route. See write() for more details.
Parameters: self_contained (bool) – Return the data for a “self-contained route file”, which includes the reactions used by the route? Returns: contents of route file Return type: dict
-
isStartingMaterial
()¶ Return True if the node represents a starting material (i.e., has no reaction instance).
-
precursors
¶ The list of precursors of this node (may be empty).
-
reaction
¶ The reaction associated with this node. If the node has no reaction instance, raises KeyError.
-
reaction_instance
¶ The reaction instance associated with this node. If the node has no reaction instance, raises KeyError.
-
setReactionInstance
(reaction, precursors)¶ Set the reaction instance to the current node. This represents a one-step synthesis of the node from a list of precursor nodes.
-
steps
()¶ Return the total number of steps in the route. For example, the following synthesis has 3 steps but depth 2.
Target => A + B A => AA B => BBReturn type: int
-
treeAsString
(products=True, starting_materials=True, indexes=True)¶ Return a recursive string representation of the tree (unlike __str__, which is a short representation of the current node). The reaction names are always shown; starting materials and products are optional.
Parameters: - products (bool) – include reaction product SMILES
- starting_materials (bool) – include starting material SMILES
Return type: str
-
write
(filename, self_contained=False)¶ Write a route file.
Parameters: - filename (str) – File to write.
- self_contained (bool) – Write a “self-contained route file”, which includes the reactions used by the route?
-
-
class
schrodinger.analysis.reaction.
ReagentClass
(name, reactive=False, description=None, smarts=None)¶ Bases:
object
Struct-like class to hold metadata for a reagent class. Fields include name, description, and ‘reactive’. A reactive reagent is one which shouldn’t be analyzed retrosynthetically. For example, acyl chlorides.
-
__init__
(name, reactive=False, description=None, smarts=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
__str__
()¶ Return str(self).
-
asDict
()¶ Return a dict representation of the reaction suitable for JSON serialization.
Returns: dict Return type: dict
-
findReagentFile
(libpath=None)¶ Look for <reagent_class>.* (where the extension corresponds to a recognized structure file format) in each of the directories in the library search path. Return the first match, but if multiple matches are found in the same directory, raise an exception.
Parameters: libpath (list of str) – list of directories to prepend to the default reagent library search path Returns: path to reagent file, or None if not found Return type: str Raises: ValueError if multiple matches are found in the CWD.
-
size
(libpath=None)¶ Return the number of structures in the reagent file for this class.
Parameters: libpath (list of str) – list of directories to prepend to the standard reagent library search path Returns: number of structures, or zero when no file is found. Return type: int
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': "\n Struct-like class to hold metadata for a reagent class. Fields include name,\n description, and 'reactive'. A reactive reagent is one which shouldn't be\n analyzed retrosynthetically. For example, acyl chlorides.\n ", '__init__': <function ReagentClass.__init__>, '__str__': <function ReagentClass.__str__>, 'asDict': <function ReagentClass.asDict>, 'findReagentFile': <function ReagentClass.findReagentFile>, 'size': <function ReagentClass.size>, '__dict__': <attribute '__dict__' of 'ReagentClass' objects>, '__weakref__': <attribute '__weakref__' of 'ReagentClass' 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.analysis.reaction'¶
-
__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
-
__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)
-
-
class
schrodinger.analysis.reaction.
SystematicIterator
(synthesizer, reagent_sources, start=0, stop=None)¶ Bases:
object
Generate all combinations (or a slice thereof) of products that can be synthesized by a Synthesizer using the given sets of starting materials.
-
__init__
(synthesizer, reagent_sources, start=0, stop=None)¶ Parameters: - synthesizer (Synthesizer) – Synthesizer
- reagent_sources (iterable of ReagentSource or iterable of list of Mol.) – List of reagent sources.
- start (int) – Start yielding from this reagent combination index (counting from zero).
- stop (int or NoneType) – Stop yielding when this product reagent combination index is reached. None means unlimited.
-
__iter__
()¶
-
__next__
()¶
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n Generate all combinations (or a slice thereof) of products that\n can be synthesized by a Synthesizer using the given sets of starting\n materials.\n ', '__init__': <function SystematicIterator.__init__>, '__iter__': <function SystematicIterator.__iter__>, '__next__': <function SystematicIterator.__next__>, '__dict__': <attribute '__dict__' of 'SystematicIterator' objects>, '__weakref__': <attribute '__weakref__' of 'SystematicIterator' 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.analysis.reaction'¶
-
__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)
-
-
class
schrodinger.analysis.reaction.
RandomSampleIterator
(synthesizer, reagent_sources, size, max_tries=None)¶ Bases:
object
Generate a random sample of unique products by repeatedly choosing a random reagent from each reagent source and keeping track of which products have been seen so far. Therefore, it is most efficient when only a fraction of the possible space of reagent combinations is sampled, because otherwise there may be many unproductive duplicates. Also, since it keeps the set of products seen so far, it uses memory proportional to ‘size’, so it is best if that number is not too large (thousands is fine).
-
__init__
(synthesizer, reagent_sources, size, max_tries=None)¶ Parameters: - synthesizer (Synthesizer) – Synthesizer
- reagent_sources (iterable of ReagentSource or iterable of list of Mol.) – List of reagent sources
- max_tries (int) – maximum number of random attempts to make before giving up, even if not enough products have been synthesized. The default is a function of ‘size’ and the number of reactant combinations.
Param: size: desired sample size (number of products).
-
__iter__
()¶
-
__next__
()¶
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': "\n Generate a random sample of unique products by repeatedly choosing a\n random reagent from each reagent source and keeping track of which\n products have been seen so far. Therefore, it is most efficient when\n only a fraction of the possible space of reagent combinations is\n sampled, because otherwise there may be many unproductive duplicates.\n Also, since it keeps the set of products seen so far, it uses memory\n proportional to 'size', so it is best if that number is not too large\n (thousands is fine).\n ", '__init__': <function RandomSampleIterator.__init__>, '__iter__': <function RandomSampleIterator.__iter__>, '__next__': <function RandomSampleIterator.__next__>, '_pickReagents': <function RandomSampleIterator._pickReagents>, '_pickMol': <function RandomSampleIterator._pickMol>, '__dict__': <attribute '__dict__' of 'RandomSampleIterator' objects>, '__weakref__': <attribute '__weakref__' of 'RandomSampleIterator' 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.analysis.reaction'¶
-
__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)
-
-
class
schrodinger.analysis.reaction.
Synthesizer
(route, id_property='s_m_title', allow_multiple_products=False)¶ Bases:
object
A Synthesizer is a “machine” that given a RouteNode, knows how to apply all the reactions in the RouteNode in the right order to a list of starting materials to give the final products.
-
__init__
(route, id_property='s_m_title', allow_multiple_products=False)¶ Create a synthesizer from a route. The value of id_property is propagated from the starting materials to the product, to make it possible to keep track of where a product came from.
Parameters: allow_multiple_products (bool) – if True, the synthesis won’t fail if a reaction generates more than one product.
-
run
(starting_materials)¶ Return the final product of the RouteNode given a list of starting materials.
Returns: list of products (may be empty) Return type: list of Mol
-
synthesizeCombinations
(reagent_sources, start=0, stop=None)¶ Create a SystematicIterator using the Synthesizer and the other arguments. See SystematicIterator for details. (This method is redundant but was kept for backward compatibility.)
-
synthesizeRandomSample
(reagent_sources, size, max_tries=None)¶ Crate a RandomSampleIterator using the Synthesizer and the other arguments. See RandomSampleIterator for details. (This method is redundant but was kept for backward compatibility.)
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A Synthesizer is a "machine" that given a RouteNode, knows how to apply all\n the reactions in the RouteNode in the right order to a list of starting\n materials to give the final products.\n ', '__init__': <function Synthesizer.__init__>, '_compile': <function Synthesizer._compile>, 'run': <function Synthesizer.run>, '_popReactants': <function Synthesizer._popReactants>, '_applyReaction': <function Synthesizer._applyReaction>, 'synthesizeCombinations': <function Synthesizer.synthesizeCombinations>, 'synthesizeRandomSample': <function Synthesizer.synthesizeRandomSample>, '_setProductProperties': <function Synthesizer._setProductProperties>, '_clearProductProperties': <function Synthesizer._clearProductProperties>, '_getReagentId': <function Synthesizer._getReagentId>, '__dict__': <attribute '__dict__' of 'Synthesizer' objects>, '__weakref__': <attribute '__weakref__' of 'Synthesizer' 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.analysis.reaction'¶
-
__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)
-
-
class
schrodinger.analysis.reaction.
RouteRenderer
(plus_size=50, arrow_length=250, arrowhead_size=25, label_padding=25, label_font=('helvetica', 30), plus_font=('helvetica', 48), max_scale=0.3, mol_padding=50, scale=0.375)¶ Bases:
object
A class for rendering a Route as an image.
Note: this class only supports “specific routes”, for which all nodes have a ‘mol’ attribute. Generic routes, in which nodes might have only a reagent class, are not supported yet.
-
__init__
(plus_size=50, arrow_length=250, arrowhead_size=25, label_padding=25, label_font=('helvetica', 30), plus_font=('helvetica', 48), max_scale=0.3, mol_padding=50, scale=0.375)¶ Configure the RouteRenderer with various optional parameters controlling the layout of the route. All sizes are in pixels.
Parameters: plus_size – width (including padding) taken by the plus signs.
-
renderToFile
(route, filename)¶ Render a Route and save the image to a file.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A class for rendering a Route as an image.\n\n Note: this class only supports "specific routes", for which all nodes have a\n \'mol\' attribute. Generic routes, in which nodes might have only a reagent\n class, are not supported yet.\n ', '__init__': <function RouteRenderer.__init__>, 'renderToFile': <function RouteRenderer.renderToFile>, '_arrangeRoute': <function RouteRenderer._arrangeRoute>, '_computeSize': <function RouteRenderer._computeSize>, '_arrangePrecursors': <function RouteRenderer._arrangePrecursors>, '_drawArrow': <function RouteRenderer._drawArrow>, '_addLabel': <function RouteRenderer._addLabel>, '__dict__': <attribute '__dict__' of 'RouteRenderer' objects>, '__weakref__': <attribute '__weakref__' of 'RouteRenderer' 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.analysis.reaction'¶
-
__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)
-
-
schrodinger.analysis.reaction.
mol_to_qpicture
(mol)¶ Generate a QPicture from an RDKit Mol.
Parameters: mol – molecule to render Return type: QPicture
-
class
schrodinger.analysis.reaction.
Reaction
(name, smarts=None, lhs_classes=None, rhs_classes=None, inverse_smarts=None, tags=None, tier=None, allow_multiple_products=False, rxnfile=None, inverse_rxnfile=None, description=None, reagents_dict=None, long_name=None, ld_data=None)¶ Bases:
object
A Reaction object represents a generic reaction, such as “amide coupling”. An actual instance of a reaction between specific reagents is a ReactionInstance (see below).
A Reaction may optionally be associated with “reagent classes” for the molecules on the left-hand-side and right-hand-side of the reaction. We avoid the terms “reactants” and “products” because they depend on the context; Reaction objects may be used for actual reactions, but also for retrosynthetic transforms (where “target” and “precursors” would be more appropriate), or for even for alchemical transformations.
A reagent class is just a name representing the type of compound involved in the reaction; the naming scheme is up to the caller. For example, for amide coupling, the reagent classes on one side might be “amine” and “acid”, and on the other “amide”.
-
__init__
(name, smarts=None, lhs_classes=None, rhs_classes=None, inverse_smarts=None, tags=None, tier=None, allow_multiple_products=False, rxnfile=None, inverse_rxnfile=None, description=None, reagents_dict=None, long_name=None, ld_data=None)¶ Parameters: - name (str) – Reaction name.
- smarts (str or NoneType) – Reaction SMARTS (RDKit dialect).
- lhs_classes (list of str or NoneType) – Reagent classes for the left-hand-side of the reaction.
- rhs_classes (list of str or NoneType) – Reagent classes for the right-hand-side of the reaction.
- inverse_smarts – Reaction SMARTS for the reverse reaction. If not specified, it is constructed automatically from ‘smarts’ by swapping around the “>>”.
- tags (iterable of str or NoneType) – Optional list of tags associated with the reaction.
- tier (int) – an integer describing how “good” the reaction is (lower is better)
- allow_multiple_products – ignored for backward compatibility
- rxnfile (str) – Path to MDL Rxnfile. May be used instead of ‘smarts’.
- inverse_rxnfile (str) – Path to MDL Rxnfile for the reverse reaction. May be used instead of ‘inverse_smarts’.
- description (str) – Reaction description.
- ld_data (object) – arbitrary object reserved for the use of LiveDesign.
-
__str__
()¶ Return str(self).
-
asDict
()¶ Return a dict representation of the reaction suitable for JSON serialization.
Returns: dict Return type: dict
-
apply
(reactants)¶ Apply the reaction to the given reactants, returning a list of lists of products. The products are already sanitized.
Return type: list of list of Mol
-
inverse
()¶ Return a new Reaction object for the inverse of the current reaction.
-
suggestReagentClasses
(r_classes, libpath=None, max_search=10)¶ Search through r_classes for reagent classes matching each of the reactants in the reaction.
Parameters: - r_classes (dict of ReagentClass) – dictionary of reagent classes by name
- libpath (list of str) – list of directories to prepend to the standard reagent library search path
- max_search (int) – maximum number of structures to search from each reagent file before deciding the file doesn’t match.
Returns: list of lists of reagent classes. Each item in the outer list corresponds to one of the molecules on the right-hand side of the reaction. Items in the inner list (which may be empty) are the suggested classes for that molecule.
Return type: list of list of ReagentClass
-
getDisplaySmarts
()¶ Return the display SMARTS for the reaction. This is a simplified SMARTS meant for depiction purposes only. If the reaction doesn’t have a display SMARTS, the inverse_smarts is returned.
Returns: display SMARTS Return type: str
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A Reaction object represents a generic reaction, such as "amide coupling".\n An actual instance of a reaction between specific reagents is a\n ReactionInstance (see below).\n\n A Reaction may optionally be associated with "reagent classes" for the\n molecules on the left-hand-side and right-hand-side of the reaction. We\n avoid the terms "reactants" and "products" because they depend on the\n context; Reaction objects may be used for actual reactions, but also for\n retrosynthetic transforms (where "target" and "precursors" would be more\n appropriate), or for even for alchemical transformations.\n\n A reagent class is just a name representing the type of compound involved\n in the reaction; the naming scheme is up to the caller. For example, for\n amide coupling, the reagent classes on one side might be "amine" and "acid",\n and on the other "amide".\n ', '__init__': <function Reaction.__init__>, '__str__': <function Reaction.__str__>, 'asDict': <function Reaction.asDict>, '_validateReagentClasses': <function Reaction._validateReagentClasses>, 'apply': <function Reaction.apply>, 'inverse': <function Reaction.inverse>, 'suggestReagentClasses': <function Reaction.suggestReagentClasses>, 'getDisplaySmarts': <function Reaction.getDisplaySmarts>, '__dict__': <attribute '__dict__' of 'Reaction' objects>, '__weakref__': <attribute '__weakref__' of 'Reaction' 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.analysis.reaction'¶
-
__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
-
__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)
-
-
class
schrodinger.analysis.reaction.
ReactionInstance
(reaction, precursors)¶ Bases:
object
A ReactionInstance is the application of a Reaction to a list of reagents/precursors. For example, “Amide syntesis” is a Reaction; but “Amide synthesis from acetic acid and ethylamine” is a ReactionInstance.
-
__init__
(reaction, precursors)¶ Initialize self. See help(type(self)) for accurate signature.
-
name
¶ The name of the reaction.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A ReactionInstance is the application of a Reaction to a list of\n reagents/precursors. For example, "Amide syntesis" is a Reaction; but\n "Amide synthesis from acetic acid and ethylamine" is a ReactionInstance.\n ', '__init__': <function ReactionInstance.__init__>, 'name': <property object>, '__dict__': <attribute '__dict__' of 'ReactionInstance' objects>, '__weakref__': <attribute '__weakref__' of 'ReactionInstance' 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.analysis.reaction'¶
-
__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)
-
-
schrodinger.analysis.reaction.
read_route_file
(filename, reactions_dict)¶ Read a route file in JSON format, returning a RouteNode object.
Parameters: reactions_dict (dict of {str: Reaction}) – dictionary of Reaction objects by name.
-
schrodinger.analysis.reaction.
parse_route_data
(json_data, reactions_dict=None)¶ Generate a Route from the raw dict/list-based data structure usually obtained from a route JSON file.
Parameters: reactions_dict (dict of {str: Reaction}) – dictionary of Reaction objects by name. Not required when using a self-contained route file.
-
schrodinger.analysis.reaction.
read_reactions_file
(filename=None, reagents_dict=None, merge_with_defaults=False)¶ Read a reactions file in JSON format and return a dictionary of reactions by name. If filename is None, read the standard reactions file from the mmshare data directory and add the ‘default’ tag to each reaction.
Parameters: - filename (str) – file to read
- reagents_dict (dict {str: ReagentClass}) – dictionary of reagent classes (normally from read_reagent_classes_file).
- merge_with_defaults (bool) – if True, read both the default file and the specified file and merge them.
Returns: dictionary of reactions by name
Return type: dict {str: Reaction}
-
schrodinger.analysis.reaction.
read_reagent_classes_file
(filename=None, merge_with_defaults=False)¶ Read a reagent classes file in JSON format and return a dictionary of reagent classes by name. If filename is None, read the standard reagent classes file from the mmshare data directory.
Parameters: - filename (str) – file to read
- merge_with_defaults (bool) – if True, read both the default file and the specified file and merge them.
Returns: dictionary of reagent classes by name
Return type: dict {str: ReagentClass}
-
schrodinger.analysis.reaction.
get_custom_reagent_classes
(filename)¶ Reads a reagent classes file in JSON format and returns a dictionary of reagent classes by name. If custom reagent classes file is not found it will be created.
Parameters: filename – file to read Returns: dictionary of reagent classes Return type: dict {str: ReagentClass}
-
schrodinger.analysis.reaction.
get_default_reactions_filename
()¶ Return the path to the default reactions file.
Returns: path Return type: str
-
schrodinger.analysis.reaction.
get_default_reagent_classes_filename
()¶ Return the path to the default reagent classes file.
Returns: path Return type: str
-
schrodinger.analysis.reaction.
parse_reaction_data
(raw_dict, reagents_dict=None)¶ Convert a “raw dict” (usually from a JSON file) into a dictionary of Reaction objects by name.
Return type: dict {str: Reaction}
-
schrodinger.analysis.reaction.
parse_reagent_classes_data
(raw_dict)¶ Convert a “raw dict” (usually from a JSON file) into a dictionary of ReagentClass objects by name.
Return type: dict {str: Reaction}
-
schrodinger.analysis.reaction.
write_reactions_file
(reactions, filename)¶ Write a reactions file. :reactions: list or dict of reactions :type reactions: list or dict of Reaction
-
schrodinger.analysis.reaction.
write_reagent_classes_file
(reagent_classes, filename)¶ Write a reagent classes file.
Parameters: - reagent_classes – dict of reagent classes by name
- filename (str) – file to write
-
schrodinger.analysis.reaction.
invert_reaction_smarts
(smarts)¶ Given a reaction SMARTS, return the reaction SMARTS for the reverse reaction.
Return type: str
-
schrodinger.analysis.reaction.
reaction_is_excluded
(reaction, exclude)¶ Check if a reaction meets any of the exclusion criteria.
Parameters: exclude (set of str) – Set of tags or reaction names to exclude. Tags are matched exactly; names are matched using shell globbing (*, ?, []). Returns: True if reaction is meets any of the exclusion criteria Return type: bool
-
schrodinger.analysis.reaction.
filter_reactions
(reactions, exclude)¶ Return a shallow copy of a list of reactions, filtering out those matching any of the exclusion criteria.
Parameters: exclude (set of str) – Set of tags or reaction names to exclude. Tags are matched exactly; names are matched using shell globbing (*, ?, []). Return type: list of reaction
-
schrodinger.analysis.reaction.
retrosynthesize
(target_mol, reactions_dict, max_depth=1, exclude=None, require_bonds=None, frozen_atoms=None)¶ Generate a retrosynthetic tree to the desired depth based on the target molecule.
Parameters: - reactions_dict (dict {str: Reaction}) – Reaction dictionary by name.
- exclude (set of str) – Set of tags or reaction names to exclude. Tags are matched exactly; names are matched using shell globbing (*, ?, []).
- require_bonds (set of tuple of int) – If provided, only reactions which break at least one bond in this set will be used for the analysis. Each bond is a sorted tuple of two 1-based atom indexes.
- frozen_atoms (set of int) – If provided, reactions which break any bond between two atoms in this set are skipped.
Return type: RetrosynthesisNode
-
schrodinger.analysis.reaction.
debug_mols
(message, mols, separator=' + ')¶ Print a debug message (if the logger level indicates it), appending a list of SMILES representation of the molecules.
-
class
schrodinger.analysis.reaction.
ReagentSource
(mols, size, filename, reagent_class, index)¶ Bases:
object
A ReagentSource is just a struct-like object with the following fields: - mols: a generator or list of Mol objects; - size: (int) the number of molecules in mols; - filename: (str) file where the mols came from (or as a special case,
“SMILES” if they came from the SMILES list hard-coded into the route);- reagent_class: (str) name of the reagent class.
- index: the 1-based index that identifies the starting material in a route.
- filters: a list of filters to apply to this reagent source. Each filter is
- a callable that takes an iterable of Mol and generating Mol.
-
__init__
(mols, size, filename, reagent_class, index)¶ Initialize self. See help(type(self)) for accurate signature.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.reaction', '__doc__': '\n A ReagentSource is just a struct-like object with the following fields:\n - mols: a generator or list of Mol objects;\n - size: (int) the number of molecules in mols;\n - filename: (str) file where the mols came from (or as a special case,\n "SMILES" if they came from the SMILES list hard-coded into the route);\n - reagent_class: (str) name of the reagent class.\n - index: the 1-based index that identifies the starting material in a route.\n - filters: a list of filters to apply to this reagent source. Each filter is\n a callable that takes an iterable of Mol and generating Mol.\n ', '__init__': <function ReagentSource.__init__>, '__dict__': <attribute '__dict__' of 'ReagentSource' objects>, '__weakref__': <attribute '__weakref__' of 'ReagentSource' 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.analysis.reaction'¶
-
__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)
-
schrodinger.analysis.reaction.
get_reagent_sources
(route, r_dict=None, libpath=None)¶ Return a list of reagent sources given a route and a dictionary of reagent filenames (each key is either a reagent index or reagent class name; each value is a filename).
Parameters: libpath (list of str) – list of directories to prepend to the standard reagent library search path Returns: reagent sources Return type: list of ReagentSource
-
schrodinger.analysis.reaction.
get_mol_reader
(filename, skip_bad=True)¶ Return a Mol generator given a filename. For SMILES, use the RDKit SmilesMolSupplier; for other formats, use StructureReader but convert Structure to Mol before yielding each molecule.
Parameters: skip_bad (bool) – if True, bad structures are skipped implicitly, instead of being yielded as None (only applies to SMILES and CSV formats.) Return type: generator of Mol
-
schrodinger.analysis.reaction.
adapt_st_reader
(reader)¶ Generate RDKit Mol objects given a StructureReader-like object. Structures which cause conversion errors are skipped but a warning is logged.
Parameters: reader (iterable of Structure) – source of structures to convert Returns: converted RDKit molecule objects Return type: generator of Mol
-
schrodinger.analysis.reaction.
create_reagent_library
(name, input_file, smarts, id_property='s_m_title', require_single_match=False)¶ Create a reagent library file for one reagent class by searching through an input file using the provided SMARTS pattern. Writes a file called <name>.csv.
Parameters: - name (str) – name of the reagent class.
- input_file (str) – name of structure file to process
- smarts (str) – SMARTS pattern to search
- id_property (str) – name of structure property to store as the title of each reagent.
- require_single_match (bool) – skip input structures matching the SMARTS pattern multiple times
Returns: output filename
Return type: str
-
schrodinger.analysis.reaction.
get_title
(mol, prop='s_m_title')¶ Return the title of a molecule. Looks for the property with the name specified by ‘prop’ but falls back to known aliases such as “NAME”.
Parameters: - mol (Chem.Mol) – input molecule
- prop (str) – title property name
Returns: molecule title, or None if unspecified
Return type: str or NoneType
-
schrodinger.analysis.reaction.
is_reagent_file
(filename)¶ Check whether a given file is usable as a reagent file. A reagent file must be a structure file and the structures need to have a title. In the case of a csv file, we look for columns named ‘s_m_title’ or ‘NAME’.
Parameters: filename (str) – filename Returns: True if the file is a reagent file Return type: bool
-
schrodinger.analysis.reaction.
get_one_step_route
(rxn)¶ Create a route for a one-step synthesis given a Reaction.
Parameters: rxn (Reaction) – reaction object Returns: new route object Return type: RouteNode
-
schrodinger.analysis.reaction.
get_libpath
()¶ Return the reagent library search path. It consists of the directories listed in the SCHRODINGER_REAGENT_LIB environment variable, if it exists, followed by ~/.schrodinger/reagents or its Windows equivalent, followed by the mmshare data/reagents directory.
Return type: list of str
-
schrodinger.analysis.reaction.
uniquify_mols
(mols)¶ Return a list of unique molecules from ‘mols’, using the canonical SMILES as the comparison key.
Parameters: mols (iterable of Mol) – molecules to uniquify Returns: unique molecules Return type: list of Mol
-
schrodinger.analysis.reaction.
get_kekule_smiles
(mol)¶ Return a Kekule SMILES, with explicit single bonds, for a molecule.
Returns: Kekule SMILES Return type: str