Basic usage

This basic example provides a minimal script to solve reaction mapping problems. In this example, we look at a simple SN2 reaction between 1-bromopropane and the hydroxide anion.

import scm.reactmap as rm

settings = rm.Settings(use_heuristics = False)

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

print("Mapping cost:", reaction.cost)
print("Atom map")
for idx, at in enumerate(reactant.atoms):
    print("Reactant atom {:2} -> Product atom {:2}".format(idx,reaction.mapping[idx]))

The output shows the total cost of the mapping as well as the assignment of each atom in the reactants to a unique atom in the products.

Mapping cost: 2
Atom map
Reactant atom  0 -> Product atom  1
Reactant atom  1 -> Product atom  2
Reactant atom  2 -> Product atom  3
Reactant atom  3 -> Product atom  0
Reactant atom  4 -> Product atom  4
Reactant atom  5 -> Product atom  5
Reactant atom  6 -> Product atom  6
Reactant atom  7 -> Product atom  7
Reactant atom  8 -> Product atom  8
Reactant atom  9 -> Product atom  9
Reactant atom 10 -> Product atom 10
Reactant atom 11 -> Product atom 11
Reactant atom 12 -> Product atom 12