Using templates
Applying a Template
Applying a template involve finding the subgraph isomorphism mappings of the template reactant on the molecule. If these mappings exist the template changes can be applied to the initial molecule to produce the product molecule. Note a template can produce more than one output
In Retropaths, this is done with the functions
Reaction Library
The Library is a python object which represents the collection of Template. A library object can be created from a directory of saved templates (pickle files)
Reactions = Libary.from_directory(react_pickle_folder)
Reactions.matching = MathingGroupsData.load(matching)
psave(Reactions, react_pickle)
Under the hood, a library is a dict
object but has many additional functions like filter_compatible
. See Code Documentation.
There are two main libraries:
Named reactions, or reactions, are like chemical recipes describing what to put in the reaction pot and what the expected product is. An elementary step are the individual transition state events that a molecule undergoes during the course of a reaction.
Reaction Pot
In real chemical reactions, more than one chemical reaction can happen sequentially or concurrently. To simulate this we introduce the Reaction Pot. The pot object is the chemical reactor, it simulates a network of chemical reactions.
The reaction pot is a python object that takes an initial Molecule, Conditions, a name (optional), and an environment (optional). Environment molecules can be replenished during the course of a chemical reaction.
The main algorithm of the pot object is run()
which is a breadth first search algorithm but other algorithms like beam search, and orderly generation (a bipartite reaction network) can also be implemented.
Within the run()
function we can define additional parameters e.g. , filtering the conditions, BFS maximum depth, and whether to add environment molecules.
pot.run_with_timeout_and_error_catching(timeout_seconds,
templ_library,
name=rxn.name,
skip_condition_filter=True,
maximum_number_of_nodes=maximum_number_of_nodes,
max_depth=max_depth,
stoichiometric=stoichiometric,
)
See the Tutorials for more information