POT GROW¶
%%time
from IPython.core.display import HTML
import retropaths.helper_functions as hf
from retropaths.molecules.molecule import Molecule
from retropaths.reactions.pot import Pot
from ipywidgets import interact
library = hf.pload('../data/reactions.p')
HTML('<script src="//d3js.org/d3.v3.min.js"></script>')
CPU times: user 7.09 s, sys: 631 ms, total: 7.72 s Wall time: 7.83 s
A pot with environment¶
# We create a Pot now with some water, hydrazine and chloridic acid as environment.
mol = Molecule.from_smiles('CCOC(=O)c1c(nc(c(n1)C(F)(F)F)C(F)(F)F)N')
environment_mol = Molecule.from_smiles('NN.O.Cl')
pot = Pot(mol, rxn_name='Try_growth_with_environment', environment=environment_mol)
pot.draw()
Pot name: Try_growth_with_environment | Status: EMPTY
Acidity all_pH | Solvent any
Pot root
Pot environment
Pot reaction graph
Node growth¶
When we grow a node, each template of the library is matched, and if isomorphic (and respect the rules) it is applied to the molecule (root molecule + environment). Each new product creates a new node to be added to the graph.
pot.grow_this_node(0, library) # <- this is the main call inside pot.run(), it grows the reaction network, from one node.
pot.draw()
Pot name: Try_growth_with_environment | Status: EMPTY
Acidity all_pH | Solvent any
Pot root
Pot environment
Pot reaction graph
Green nodes are the one that need to be grown. Take a look at what happens in each EDGE of the reaction network graph. Remember, the initial node can contain more than one molecule!
- add environment
- make matching (with rules)
- apply the template
- CLEAN the pot node from environment and minor products
- add final node to the graph
# this cell lets you select an edge, and it displays step by step what has happened at that edge with the template application.
@interact(edge=pot.edge_view())
def draw_edge(edge):
return pot.draw_step(edge, library)
interactive(children=(Dropdown(description='edge', options=(Edge(n1=0, n2=1), Edge(n1=0, n2=2), Edge(n1=0, n2=…
# let's grow more this graph!!
# this cell can be run multiple times.
if pot.any_leaves_growable(): # This is very similar on how the code runs in the internals. Is there any growable (not converged) node?
for i in pot.leaves: # What are the LEAVES of the graph in present state (green nodes)?
print(f'Growing node {i}...\r', end="")
pot.grow_this_node(i, library, filter_minor_products=True, use_father_error=False)
else:
print(f'Pot is converged.')
pot.draw()
Growing node 3...
Pot name: Try_growth_with_environment | Status: EMPTY
Acidity all_pH | Solvent any
Pot root
Pot environment
Pot reaction graph
After the second layer is calculated, note how both node 1 and node 3 point to the same node, 6!
@interact(edge=pot.edge_view())
def draw_edge(edge):
return pot.draw_step(edge, library)
interactive(children=(Dropdown(description='edge', options=(Edge(n1=0, n2=1), Edge(n1=2, n2=1), Edge(n1=0, n2=…
STOICHIMETRIC POT¶
A stoichiometric pot is created without environment. The idea of a stoichiometric growth is that we just rearrange the edges without ever adding/taking out any atom.
pot = Pot(mol+environment_mol, rxn_name='Stoichiometric pot')
pot.draw()
Pot name: Stoichiometric pot | Status: EMPTY
Acidity all_pH | Solvent any
Pot root
Pot environment
Pot reaction graph
pot.grow_this_node_stoichiometric(0, library)
pot.draw()
Pot name: Stoichiometric pot | Status: EMPTY
Acidity all_pH | Solvent any
Pot root
Pot environment
Pot reaction graph
@interact(edge=pot.edge_view())
def draw_edge(edge):
return pot.draw_step(edge, library, stoichiometric=True)
interactive(children=(Dropdown(description='edge', options=(Edge(n1=0, n2=1), Edge(n1=0, n2=2), Edge(n1=0, n2=…