Package schrodinger :: Package analysis :: Module reaction
[hide private]
[frames] | no frames]

Module reaction



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)

Classes [hide private]
  Node
Base class for a node in a synthetic route or a retrosynthetic tree.
  RetroSynthesisNode
A node in a retrosynthetic analysis tree.
  RouteNode
A node in a synthetic route.
  ReagentNode
A node representing a starting material in a synthetic route.
  Synthesizer
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 product.
  RouteRenderer
A class for rendering a Route as an image.
  Reaction
A Reaction object represents a generic reaction, such as "amide coupling".
  ReactionInstance
A ReactionInstance is the application of a Reaction to a list of reagents/precursors.
Functions [hide private]
 
_reaction_node_schema(v)
 
read_route_file(filename, reactions_dict)
Read a route file in JSON format, returning a RouteNode object.
 
parse_route_data(json_data, reactions_dict)
Generate a Route from the raw dict/list-based data structure usually obtained from a route JSON file.
 
_parse_route_node(node, reactions_dict, counter)
dict {str: Reaction}
read_reactions_file(filename)
Read a reactions file in JSON format and return a dictionary of reactions by name.
dict {str: Reaction}
parse_reaction_data(raw_dict)
Convert a "raw dict" (usually from a JSON file) into a dictionary of Reaction objects by name.
str
invert_reaction_smarts(smarts)
Given a reaction SMARTS, return the reaction SMARTS for the reverse reaction.
bool
reaction_is_excluded(reaction, exclude)
Check if a reaction meets any of the exclusion criteria.
list of reaction
filter_reactions(reactions, exclude)
Return a shallow copy of a list of reactions, filtering out those matching any of the exclusion criteria.
RetrosynthesisNode
retrosynthesize(target_mol, reactions_dict, max_depth=1, exclude=None)
Generate a retrosynthetic tree to the desired depth based on the target molecule.
 
_retrosynthesize(mol, reactions, max_depth, reagent_class=None)
 
_convert_unicode(val)
Return a copy of a recursive data structure based on dicts and/or lists, replacing any unicode keys or values with str.
 
debug_mols(message, mols, separator=' + ')
Print a debug message (if the logger level indicates it), appending a list of SMILES representation of the molecules.
list of generators of Mol.
get_reagent_sources(route, r_dict=None, smiles_opts=None)
Return a list of reagent sources given a route and a dictionary of reagent sources (each key is either a reagent index or reagent class name; each value is a filename).
generator of Mol
get_mol_reader(filename, smiles_opts=None)
Return a Mol generator given a filename.
Variables [hide private]
  logger = log.get_output_logger("schrodinger.analysis.reaction")
  reagent_node_schema = Schema(Any({Required(Any('file', 'smiles...
  reaction_node_schema = Schema({'reaction_name': str, 'precurso...
  route_file_schema = Schema(Any(reaction_node_schema, reagent_n...
  reaction_file_schema = Schema({str: {Required('smarts'): str, ...
  __package__ = 'schrodinger.analysis'
Function Details [hide private]

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.

parse_route_data(json_data, reactions_dict)

 

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.

invert_reaction_smarts(smarts)

 

Given a reaction SMARTS, return the reaction SMARTS for the reverse reaction.

Parameters:
  • smarts (str)
Returns: str

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 (*, ?, []).
  • reaction (Reaction)
Returns: bool
True if reaction is meets any of the exclusion criteria

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 (*, ?, []).
  • reactions (list of Reaction)
Returns: list of reaction

retrosynthesize(target_mol, reactions_dict, max_depth=1, exclude=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 (*, ?, []).
  • target_mol (Mol)
Returns: RetrosynthesisNode

_convert_unicode(val)

 

Return a copy of a recursive data structure based on dicts and/or lists, replacing any unicode keys or values with str. (Of course, this limits the JSON input to things that can be represented with str.) This is needed to clean up JSON inputs, which use unicode, because the RDKit APIs can't handle unicode. Anything other than list or dict is copied shallowly.

debug_mols(message, mols, separator=' + ')

 

Print a debug message (if the logger level indicates it), appending a list of SMILES representation of the molecules.

Parameters:
  • message (str)
  • mols (iterable of Mol)
  • separator (str)

get_reagent_sources(route, r_dict=None, smiles_opts=None)

 

Return a list of reagent sources given a route and a dictionary of reagent sources (each key is either a reagent index or reagent class name; each value is a filename).

Parameters:
  • smiles_opts - Dictionary to pass through to get_mol_reader.
  • r_dict (dict {str or int: str})
Returns: list of generators of Mol.

get_mol_reader(filename, smiles_opts=None)

 

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:
  • smiles_opts (dict) - Keyword arguments to pass to SmilesMolSupplier().
Returns: generator of Mol

Variables Details [hide private]

reagent_node_schema

Value:
Schema(Any({Required(Any('file', 'smiles', 'reagent')): str, Any('step\
s', 'depth'): int,}, {Required('smiles_list'): [str], Any('steps', 'de\
pth'): int,},))

reaction_node_schema

Value:
Schema({'reaction_name': str, 'precursors': [Any(_reaction_node_schema\
, reagent_node_schema)], Any('steps', 'depth'): int,})

route_file_schema

Value:
Schema(Any(reaction_node_schema, reagent_node_schema))

reaction_file_schema

Value:
Schema({str: {Required('smarts'): str, 'inverse_smarts': str, 'lhs_cla\
sses': [str], 'rhs_classes': [str], 'tags': [str],}})