schrodinger.application.pathfinder.analysis module

A module to perform retrosynthetic analysis.

Examples:

# retrosynthetic analysis
reactions = reaction.read_reactions_file('reactions.json')
retrosynthesis = analysis.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')
class schrodinger.application.pathfinder.analysis.RetrosynthesisState(mols_analyzed, depth, done, tree)

Bases: tuple

depth

Depth of the last node to be analyzed (int)

done

Flag indicating whether the analysis ran to completion (bool)

mols_analyzed

Number of molecules analyzed so far (int)

tree

Retrosynthetic tree (RetrosynthesisNode)

class schrodinger.application.pathfinder.analysis.Transformer(rxns)

Bases: object

Applies transformations (single-reactant, single-product reactions such as functional group interconversions) to an input molecule and generates routes up to a certain depth.

The transformations are tried in input order, which means that: 1) when two transfomations can be applied to different parts of the molecule, only one of the two possible route orders is returned; 2) when one transformation depends on another, it may only work if the second one appears later in the input order. These restrictions are meant as an optimization to reduce combinatorial explosions, with the understanding that the supported use case is “orthogonal” transformations.

__init__(rxns)
Parameters

rxns ({str: reaction.Reaction}) – reaction dictionary by name

apply(mol, max_depth)

Generate routes up to the given depth. The first route will always be the zero-step route consisting of the starting material.

Parameters
  • mol (rdkit.Chem.rdchem.Mol) – input molecule

  • max_depth (int) – maximum number of steps

Returns

list of routes

Return type

[schrodinger.application.pathfinder.route.RouteNode]

class schrodinger.application.pathfinder.analysis.ForwardAnalyzer(rxns)

Bases: object

Using “applicable” synthetic reactions and a list of routes, generate a new list of routes up to a certain depth. A reactions is synthetic if it has more than one reactant; it is “applicable” if any of the reactant templates match the target molecule of the route.

We don’t actually apply the reactions because we don’t know what the “other reactant” would be yet; we just check which atoms would be matched. Multiple reactions can be applied as long as the atoms matched by each don’t overlap (in other words, the reactions are orthogonal). This works best when the reaction SMARTS are written in such a way that only relevant atoms are matched.

__init__(rxns)
Parameters

rxns ({str: reaction.Reaction}) – reaction dictionary by name

analyzeRoutes(routes, max_depth)

For each input route, generate new routes using “applicable” synthetic reactions.

Parameters
  • routes ([schrodinger.application.pathfinder.route.RouteNode]) – list of input routes

  • max_depth (int) – maximum number of steps. NOTE: this is a total depth including the steps already in the input route. For example, if an input route has two steps and max_depth=3, only 1 more step would be considered.

Returns

list of new routes. None of the input routes are returned, because transformation-only routes are not considered interesting for the purpose of this class.

Return type

[schrodinger.application.pathfinder.route.RouteNode]

schrodinger.application.pathfinder.analysis.retrosynthesize(*a, **d)

Convenience wrapper for retrosynthesize_gen for backward compatibility. Takes takes the same arguments as retrosynthesize_gen and returns a RetrosynthesisNode.

schrodinger.application.pathfinder.analysis.retrosynthesize_gen(target_mol, reactions_dict, max_depth=1, exclude=None, require_bonds=None, frozen_atoms=None, broken_bonds=None, fragments=None, label_attachment_atoms=False)

Generate a retrosynthetic tree to the desired depth based on the target molecule. This function is a generator which yields after analyzing each molecule (node in the tree). The search is done breadth-first and the caller can break out at any time, getting a valid (but possibly incomplete) tree.

Parameters
  • reactions_dict (.reaction.ReactionDict or dict {str: Reaction}) – Reaction dictionary.

  • 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.

  • broken_bonds ({(int, int): set(str)}) – If provided, this dict will be filled with a bond: reactions mapping, where a bond is a pair of atom indexes, and the reactions a set of strings (reaction names) for all the bonds that were broken during the analysis.

  • fragments (set of tuple of int) – If provided, this set will be filled with tuples of atom indexes for the fragments identified during the analysis. “Fragment” here is understood as a subset of atoms in the original molecule that is also present in a precursor.

  • label_attachment_atoms (bool) – if true, add atom mapping numbers to “attachment atoms”, which are atoms that were present in the target molecule and which were involved in any broken bond.

Returns

yields a RetrosynthesisState after analyzing each molecule. The current tree can be found in the .tree property of the state object. NOTE: the same (evolving) tree object is returned with each state! This is for efficiency reasons and because there’s not a strong use case for keeping a “trajectory”.

Return type

generator of RetrosynthesisState

schrodinger.application.pathfinder.analysis.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.application.pathfinder.analysis.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.application.pathfinder.analysis.is_transformation(rxn)

Check if a reaction is a “transformation”, meaning that it has a single reactant and a single product.

Parameters

rxn (reaction.Reaction) – reaction to test

Returns

True if rxn is a transformation, False otherwise

Return type

bool

schrodinger.application.pathfinder.analysis.parse_frozen_atoms(frozen_atoms_str)

Parse a frozen atom string spec.

Parameters

frozen_atoms_str (Optional[str]) – comma-separated atom indices or a SMARTS

Return type

set[int] or rdkit.Chem.Mol

Raises

ValueError if string cannot be parsed.

schrodinger.application.pathfinder.analysis.get_frozen_atoms(frozen_atoms, mol)

Convert a frozen_atoms spec into a set of int atom indices, if needed. If no conversion is required, the frozen_atoms argument is returned.

Parameters
  • frozen_atoms (set[int] or rdkit.Chem.Mol) – a set of atom indices or a query molecule.

  • mol (rdkit.Chem.Mol) – target molecule

Return type

set[int]