MoleculePattern[{atom1,atom2,… }, { bond1,bond2,… }]
represents a molecule pattern with atoms atomi and bonds bondi for use in substructure searching.
MoleculePattern["smarts"]
represents a molecule pattern from the input SMARTS pattern.
MoleculePattern
MoleculePattern[{atom1,atom2,… }, { bond1,bond2,… }]
represents a molecule pattern with atoms atomi and bonds bondi for use in substructure searching.
MoleculePattern["smarts"]
represents a molecule pattern from the input SMARTS pattern.
Details and Options
- The atoms and bonds in a MoleculePattern are not checked for proper valence, and no implicit hydrogens are added.
- Possible forms for the atom patterns include:
-
"sym" an atom with atomic symbol "sym" Atom["sym",prop->val] an atom with properties described by rules patt1|patt2|… an atom matching any of the patti - A bond is entered as Bond[{id1,id2},"type"]. If the bond type is omitted, it will match any type.
- Possible options include:
-
AtomDiagramCoordinates Automatic two-dimensional coordinates StereochemistryElements None a list specifying a stereochemical arrangement
Examples
open all close allBasic Examples (3)
Define a pattern for sulfur-oxygen bonds:
sulfurOxygenBond = MoleculePattern[{"S", "O"}, {Bond[{1, 2}, "Single"]}];
m = Molecule["4-methylbenzenesulfonic acid"]Use MoleculeContainsQ to verify the molecule matches the pattern:
MoleculeContainsQ[m, sulfurOxygenBond]Use the pattern in MoleculePlot to visualize:
MoleculePlot[m, sulfurOxygenBond]Find bonds between carbon and heavier atoms:
bondPattern = MoleculePattern[
{Atom["AtomicNumber" -> GreaterThan[6]], "C"},
{Bond[{1, 2}]}
];m = Molecule[{Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["O"], Atom["C"], Atom["O"],
Atom["N"], Atom["C"], Atom["C"], Atom["C"], Atom["N"], Atom["C"], Atom["C"], Atom["C"],
Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["C"], A ... er" -> 4, "Direction" -> "Clockwise",
"FiducialAtom" -> 3, "Ligands" -> {5, 9, 33}], Association["StereoType" -> "Tetrahedral",
"ChiralCenter" -> 5, "Direction" -> "Counterclockwise", "FiducialAtom" -> 4,
"Ligands" -> {6, 20, 34}]}];BondList[m, bondPattern]MoleculePlot[m, %]Make a molecule pattern from part of a molecule:
m = Molecule[{Atom["O"], Atom["C"], Atom["C"], Atom["C"], Atom["N"], Atom["C"], Atom["C"], Atom["C"],
Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["N"], Atom["C"], Atom["C"], Atom["C"],
Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["O"], A ... "],
Bond[{32, 62}, "Single"], Bond[{33, 63}, "Single"], Bond[{33, 64}, "Single"],
Bond[{36, 65}, "Single"], Bond[{36, 66}, "Single"], Bond[{37, 67}, "Single"],
Bond[{38, 68}, "Single"], Bond[{39, 69}, "Single"], Bond[{40, 70}, "Single"]}];patt = MoleculePattern[m, Range[12]];Find this pattern in the parent molecule:
MoleculeSubstructureCases[m, patt, All, "AtomIndices"]Visualize the pattern with MoleculePlot:
MoleculePlot[m, Style[patt, RGBColor[0.5800000000000001, 0.6266666666666667, 2/3]]]Options (2)
AtomDiagramCoordinates (1)
By default, diagram coordinates will be automatically generated:
MoleculePlot[MoleculePattern["[#6]-[#6](-[#7]-[#6]-[#6])-[#6]"]]MoleculePlot[MoleculePattern["[#6]-[#6](-[#7]-[#6]-[#6])-[#6]", AtomDiagramCoordinates -> {{-0.07, 0.34}, {0.24, -0.61}, {-0.43, -1.36}, {-1.41, -1.15}, {-1.72, -0.2}, {1.22, -0.82}}]]StereochemistryElements (1)
Create a molecule pattern with defined stereo:
patt = MoleculePattern[{Atom["C", Rule["HydrogenCount", 1]], "Cl", "Br", "I"}, {Bond[{1, 2}, "Single"], Bond[{1, 3}, "Single"], Bond[{1, 4}, "Single"]}, StereochemistryElements -> {<|"StereoType" -> "Tetrahedral", "ChiralCenter" -> 1, "Direction" -> "Clockwise"|>}]Select the enantiomer that matches the pattern:
Select[{Molecule[{"Cl", Atom["C", "HydrogenCount" -> 1], "Br", "I"},
{Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{2, 4}, "Single"]},
{StereochemistryElements -> {Association["StereoType" -> "Tetrahedral", "ChiralCenter" -> 2,
"Direction" -> "Counterclockwise"]}}], Molecule[{"Cl", Atom["C", "HydrogenCount" -> 1], "I", "Br"},
{Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{2, 4}, "Single"]},
{StereochemistryElements -> {Association["StereoType" -> "Tetrahedral", "ChiralCenter" -> 2,
"Direction" -> "Counterclockwise"]}}]}, MoleculeMatchQ[patt]]Properties & Relations (1)
An invalid molecule pattern can be detected with MoleculePatternQ:
MoleculePatternQ@MoleculePattern["[#6]-[#6](-[#7]-[#6]-[#6])-[#6"]Fixing the string creates a valid pattern:
MoleculePatternQ@MoleculePattern["[#6]-[#6](-[#7]-[#6]-[#6])-[#6]"]See Also
MoleculeSubstructureCases MoleculeContainsQ PatternReaction MoleculePlot AtomCount BondCount AtomList BondList
Function Repository: MoleculeRingPattern
Related Guides
History
Text
Wolfram Research (2019), MoleculePattern, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculePattern.html.
CMS
Wolfram Language. 2019. "MoleculePattern." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MoleculePattern.html.
APA
Wolfram Language. (2019). MoleculePattern. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MoleculePattern.html
BibTeX
@misc{reference.wolfram_2026_moleculepattern, author="Wolfram Research", title="{MoleculePattern}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/MoleculePattern.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_moleculepattern, organization={Wolfram Research}, title={MoleculePattern}, year={2019}, url={https://reference.wolfram.com/language/ref/MoleculePattern.html}, note=[Accessed: 12-June-2026]}