Mapping multiple reactions

To map multiple reactions, the user can simply pass a list of reactmap.Reaction instances to reactmap.Map. An exmaple is given below where we define 3 reactions and then pass them all at once to reactmap.Map.

import scm.reactmap as rm

# we'll keep a list of all reactions we want to map
# and then pass this list to rm.Map
reactions = []

reactant  = rm.Molecule(smiles="CCC[Br].[OH1-]")
product   = rm.Molecule(smiles="[Br-].CCCO")
reactions.append( rm.Reaction(reactant=reactant, product=product, name="SN2") )

reactant  = rm.Molecule(atoms=['H','O','O','H'], bonds=[(0,1),(1,2),(2,3)])
product   = rm.Molecule(atoms=['H','O','O','H'], bonds=[(0,1),(2,3)])
reactions.append( rm.Reaction(reactant = reactant, product = product, name = "homolytic cleavage") )

reactant  = rm.Molecule(smiles='C=C.[H][H]')
product   = rm.Molecule(smiles='CC')
reactions.append( rm.Reaction(reactant = reactant, product = product, name = "hydrogenation") )

rm.Map(reactions)

Appending the following lines to the code allows us to look at each reaction’s mapping information individually.

for r in reactions:
    print("Reaction {} had a cost of {}".format(r.name,r.cost))

This produces the following output:

Reaction SN2 had a cost of 2
Reaction homolytic cleavage had a cost of 1
Reaction hydrogenation had a cost of 3