PatternReaction[reactantsproducts]
represents a templated reaction between molecule patterns in reactants and products.
PatternReaction[reactantsproducts,mapping]
represents a reaction with a specified mapping between atoms in reactants and products.
PatternReaction["smarts"]
represents a reaction defined by the given reaction SMARTS string.
PatternReaction
PatternReaction[reactantsproducts]
represents a templated reaction between molecule patterns in reactants and products.
PatternReaction[reactantsproducts,mapping]
represents a reaction with a specified mapping between atoms in reactants and products.
PatternReaction["smarts"]
represents a reaction defined by the given reaction SMARTS string.
Details
- PatternReaction displays in a notebook as a graphical depiction of the reaction. Mapped atom pairs are indicated through a mouseover effect.
- reactants and products should be lists of MoleculePattern objects.
- A pattern reaction is used in conjunction with ApplyReaction to effect transformations on Molecule objects.
- Multiple occurrences of a reactant or product must appear explicitly in the pattern reaction, and stoichiometric coefficients are always assumed to be 1.
- mapping should be a list of the form {{ri,ari}{pj,apj},…}, indicating that the atom with index ari in reactant ri is mapped to the atom with index apj in product pj.
- A reaction SMARTS string is written "reactants>>products", where the reactants and products are valid SMARTS patterns, with components separated by a period. Atom mapping is indicated within the atom primitive by a colon followed by an integer. For example, "[H:1][O:2][H:3]>>[H:1][O-:2].[H+:3]" denotes the breakup of water into a hydroxide ion and a proton.
- For a given PatternReaction rxn, the following properties "prop" can be accessed as rxn["prop"]:
-
"Reactants" a list of reactants "Products" a list of products "AtomMapping" the atom mapping from reactants to products "FullyAtomMappedQ" returns True if all atoms in the reaction are mapped "Graphics" a graphics object representing the reaction - For a given PatternReaction rxn, the following forms are used to test for applicability in the reaction:
-
rxn["ReactantMatchQ",mol] returns True if mol matches any reactant pattern in rxn rxn["ReactantMatchQ",mol,n] returns True if mol matches the n
reactant patternrxn["ReactantMatchList",mol] matches mol against each reactant and returns a list of True or False values rxn["ProductMatchQ",mol] returns True if mol matches any product in rxn rxn["ProductMatchQ",mol,n] returns True if mol matches the n
productrxn["ProductMatchList",mol] matches mol against each product and returns a list of True or False values - PatternReaction is treated as a raw object by functions such as AtomQ.
Examples
Basic Examples (3)
Define a pattern reaction for the dissociation of molecular sodium chloride:
PatternReaction[{MoleculePattern[{"Na", "Cl"}, {Bond[{1, 2}, "Single"]}]} -> {MoleculePattern[{Atom["Na", "FormalCharge" -> 1]}], MoleculePattern[{Atom["Cl", "FormalCharge" -> -1]}]}, {{1, 1} -> {1, 1}, {1, 2} -> {2, 1}}]Define the same reaction using a SMARTS string:
PatternReaction["[Na:1][Cl:2]>>[Na+:1].[Cl-:2]"]Define a pattern reaction for the dissociation of hydrochloric acid in water:
PatternReaction[{MoleculePattern[{"H", "Cl"}, {Bond[{1, 2}, "Single"]}], MoleculePattern[{"H", "O", "H"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"]}]} -> {MoleculePattern[{Atom["Cl", "FormalCharge" -> -1]}], MoleculePattern[{"H", Atom["O", "FormalCharge" -> 1], "H", "H"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{2, 4}, "Single"]}]}, {{1, 1} -> {2, 4}, {1, 2} -> {1, 1}, {2, 1} -> {2, 1}, {2, 2} -> {2, 2}, {2, 3} -> {2, 3}}]Apply the reaction to an acid and an alcohol:
ApplyReaction[%, {Entity["Chemical", "HydrogenChloride"], Entity["Chemical", "Water"]}]Define a pattern reaction for an intermolecular esterification:
PatternReaction[{MoleculePattern[{"C", "O", "O"}, {Bond[{1, 2}, "Double"], Bond[{1, 3}, "Single"]}], MoleculePattern[{"C", "O"}, {Bond[{1, 2}, "Single"]}]} -> {MoleculePattern[{"C", "O", "O", "C"}, {Bond[{1, 2}, "Double"], Bond[{1, 3}, "Single"],
Bond[{3, 4}, "Single"]}], MoleculePattern[{"O"}, {}]}, {{1, 1} -> {1, 1}, {1, 2} -> {1, 2}, {1, 3} -> {2, 1}, {2, 1} -> {1, 4}, {2, 2} -> {1, 3}}]Apply the reaction to an acid and an alcohol:
ApplyReaction[%, {Entity["Chemical", "AceticAcid"], Entity["Chemical", "Ethanol"]}]Related Guides
History
Text
Wolfram Research (2022), PatternReaction, Wolfram Language function, https://reference.wolfram.com/language/ref/PatternReaction.html.
CMS
Wolfram Language. 2022. "PatternReaction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PatternReaction.html.
APA
Wolfram Language. (2022). PatternReaction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PatternReaction.html
BibTeX
@misc{reference.wolfram_2026_patternreaction, author="Wolfram Research", title="{PatternReaction}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/PatternReaction.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_patternreaction, organization={Wolfram Research}, title={PatternReaction}, year={2022}, url={https://reference.wolfram.com/language/ref/PatternReaction.html}, note=[Accessed: 12-June-2026]}