MoleculeMatchQ[mol,patt]
MoleculeMatchQ[patt]
represents an operator form of MoleculeMatchQ that can be applied to a molecule.
MoleculeMatchQ
MoleculeMatchQ[mol,patt]
MoleculeMatchQ[patt]
represents an operator form of MoleculeMatchQ that can be applied to a molecule.
Details and Options
- Possible forms for patt include:
-
Molecule[…] a molecule MoleculePattern[…] a molecule pattern ChemicalFormula[…] a chemical formula - A molecule mol is considered to match a MoleculePattern if every non-hydrogen atom in mol has a matching atom in the pattern.
- MoleculeMatchQ takes the following options:
-
IgnoreIsotopes False whether to match all specified mass numbers IgnoreStereochemistry False whether to match the stereo
Examples
open all close allBasic Examples (4)
Test whether two molecules match:
MoleculeMatchQ[
Molecule[{"H", "H", "O"}, {Bond[{1, 3}, "Single"], Bond[{2, 3}, "Single"]}],
Molecule[{"H", "O", "H"}, {Bond[{2, 1}, "Single"], Bond[{3, 2}, "Single"]}]
]Test whether a molecule matches a formula:
MoleculeMatchQ[
Molecule[{"C", "C", "C", "C", "C", "C", "H", "H", "H", "H", "H", "H"},
{Bond[{1, 2}, "Aromatic"], Bond[{2, 3}, "Aromatic"], Bond[{3, 4}, "Aromatic"],
Bond[{4, 5}, "Aromatic"], Bond[{5, 6}, "Aromatic"], Bond[{6, 1}, "Aromatic"],
Bond[{1, 7}, "Single"], Bond[{2, 8}, "Single"], Bond[{3, 9}, "Single"], Bond[{4, 10}, "Single"],
Bond[{5, 11}, "Single"], Bond[{6, 12}, "Single"]}, {}],
ChemicalFormula[{{"C", 6}, {"H", 6}}]
]Test whether a molecule matches a pattern:
MoleculeMatchQ[
Molecule[{"C", "C", "C", "C", "C", "C", "H", "H", "H", "H", "H", "H"},
{Bond[{1, 2}, "Aromatic"], Bond[{2, 3}, "Aromatic"], Bond[{3, 4}, "Aromatic"],
Bond[{4, 5}, "Aromatic"], Bond[{5, 6}, "Aromatic"], Bond[{6, 1}, "Aromatic"],
Bond[{1, 7}, "Single"], Bond[{2, 8}, "Single"], Bond[{3, 9}, "Single"], Bond[{4, 10}, "Single"],
Bond[{5, 11}, "Single"], Bond[{6, 12}, "Single"]}, {}],
MoleculePattern["a1aaaaa1"]
]Use the operator form of MoleculeMatchQ to select chemical entities with a particular formula:
Select[EntityList[[alkanes]], MoleculeMatchQ[ChemicalFormula[{"C" -> 6, "H" -> 14}]]]Options (2)
IgnoreIsotopes (1)
By default, isotopologues do not match:
MoleculeMatchQ[
Molecule[{"H", "O", "H"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"]}, {}],
Molecule[{Atom["H", "MassNumber" -> 2], "O", Atom["H", "MassNumber" -> 2]},
{Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"]}, {}]
]Use IgnoreIsotopesTrue to get a positive match:
MoleculeMatchQ[
Molecule[{"H", "O", "H"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"]}, {}],
Molecule[{Atom["H", "MassNumber" -> 2], "O", Atom["H", "MassNumber" -> 2]},
{Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"]}, {}],
IgnoreIsotopes -> True
]IgnoreStereochemistry (1)
By default, stereoisomers do not match:
MoleculeMatchQ[
Molecule["l-alanine"],
Molecule["d-alanine"]
]Use IgnoreStereochemistryTrue to get a positive match:
MoleculeMatchQ[
Molecule["l-alanine"],
Molecule["d-alanine"],
IgnoreStereochemistry -> True
]Related Guides
History
Text
Wolfram Research (2021), MoleculeMatchQ, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculeMatchQ.html.
CMS
Wolfram Language. 2021. "MoleculeMatchQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MoleculeMatchQ.html.
APA
Wolfram Language. (2021). MoleculeMatchQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MoleculeMatchQ.html
BibTeX
@misc{reference.wolfram_2026_moleculematchq, author="Wolfram Research", title="{MoleculeMatchQ}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/MoleculeMatchQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_moleculematchq, organization={Wolfram Research}, title={MoleculeMatchQ}, year={2021}, url={https://reference.wolfram.com/language/ref/MoleculeMatchQ.html}, note=[Accessed: 13-June-2026]}