MoleculeContainsQ[molecule,patt]
returns True if patt is a substructure of molecule, and False otherwise.
MoleculeContainsQ[patt]
represents an operator form of MoleculeContainsQ that can be applied to a molecule.
MoleculeContainsQ
MoleculeContainsQ[molecule,patt]
returns True if patt is a substructure of molecule, and False otherwise.
MoleculeContainsQ[patt]
represents an operator form of MoleculeContainsQ that can be applied to a molecule.
Details and Options
- patt should be one of the following forms:
-
MoleculePattern[…] a valid molecule pattern Atom[…] a pattern for a single atom Bond[{a1,a2}] a bond between atoms with specified patterns
Examples
open all close allBasic Examples (4)
Test for the presence of oxygen atoms:
MoleculeContainsQ[Molecule["water"], Atom["O"]]MoleculeContainsQ[Molecule["water"], Atom["S"]]Select molecules with a carboxylic acid group:
Select[{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"]}, {}], Molecule[{"O", "C", "C", "C", "C", "C", "C", "H", "H", "H", "H", "H", "H"},
{Bond[{1, 2}, "Single"], Bond[{2, 3}, "Aromatic"], Bond[{3, 4}, "Aromatic"],
Bond[{4, 5}, "Aromatic"], Bond[{5, 6}, "Aromatic"], Bond[{6, 7}, "Aromatic"],
Bond[{7, 2}, "Aromatic"], Bond[{1, 8}, "Single"], Bond[{3, 9}, "Single"],
Bond[{4, 10}, "Single"], Bond[{5, 11}, "Single"], Bond[{6, 12}, "Single"],
Bond[{7, 13}, "Single"]}, {}], Molecule[{"O", "C", "O", "C", "C", "C", "C", "C", "C", "H", "H", "H", "H", "H", "H"},
{Bond[{1, 2}, "Double"], Bond[{2, 3}, "Single"], Bond[{2, 4}, "Single"], Bond[{4, 5}, "Aromatic"],
Bond[{5, 6}, "Aromatic"], Bond[{6, 7}, "Aromatic"], Bond[{7, 8}, "Aromatic"],
Bond[{8, 9}, "Aromatic"], Bond[{9, 4}, "Aromatic"], Bond[{3, 10}, "Single"],
Bond[{5, 11}, "Single"], Bond[{6, 12}, "Single"], Bond[{7, 13}, "Single"],
Bond[{8, 14}, "Single"], Bond[{9, 15}, "Single"]}, {}]},
MoleculeContainsQ[MoleculePattern["[C](=[O])[OH]"]]]Test for the presence of carbon-sulfur bonds in a molecule:
m = Molecule["O=C(C1CCC1)S[C@@H]1CCC1(C)C"];MoleculeContainsQ[m, Bond[{"C", "S"}, "Single"]]The bond order can be specified or not:
MoleculeContainsQ[m, Bond[{"C", "S"}, _]]MoleculeContainsQ[m, Bond[{"C", "S"}, "Double"]]MoleculeContainsQ[Molecule[{"Cl", "C", "C", "C", "Cl", "C", "C", "C", "O", "C", "C", "C", "C", "C", "C", "Cl", "Cl",
"H", "H", "H", "H"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Aromatic"], Bond[{3, 4}, "Aromatic"],
Bond[{4, 5}, "Single"], Bond[{4, 6}, "Aromati ... ond[{15, 16}, "Single"],
Bond[{13, 17}, "Single"], Bond[{8, 2}, "Aromatic"], Bond[{15, 10}, "Aromatic"],
Bond[{11, 6}, "Aromatic"], Bond[{3, 18}, "Single"], Bond[{8, 19}, "Single"],
Bond[{12, 20}, "Single"], Bond[{14, 21}, "Single"]}, {}], Atom["RingAtomQ" -> True]]Applications (1)
nlist = EntityList[EntityClass["Chemical", "Nucleosides"]]Create a pattern for the purine ring system:
purinePattern = MoleculePattern[{"N", "C", "N", "C", "C", "C", "N", "C", "N"}, {Bond[{1, 2}], Bond[{2, 3}], Bond[{3, 4}], Bond[{4, 5}], Bond[{5, 6}], Bond[{6, 1}], Bond[{6, 7}], Bond[{7, 8}], Bond[{8, 9}], Bond[{9, 5}]}]Select all nucleosides that contain purine:
Select[nlist, MoleculeContainsQ[purinePattern]]Show the selected molecules with the purine ring highlighted:
MoleculePlot[#, purinePattern]& /@ %Related Guides
History
Text
Wolfram Research (2019), MoleculeContainsQ, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculeContainsQ.html.
CMS
Wolfram Language. 2019. "MoleculeContainsQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MoleculeContainsQ.html.
APA
Wolfram Language. (2019). MoleculeContainsQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MoleculeContainsQ.html
BibTeX
@misc{reference.wolfram_2026_moleculecontainsq, author="Wolfram Research", title="{MoleculeContainsQ}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/MoleculeContainsQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_moleculecontainsq, organization={Wolfram Research}, title={MoleculeContainsQ}, year={2019}, url={https://reference.wolfram.com/language/ref/MoleculeContainsQ.html}, note=[Accessed: 13-June-2026]}