FindMoleculeSubstructure[mol,patt]
finds a mapping between the atom indices in mol and an occurrence of patt in mol.
FindMoleculeSubstructure[mol,patt,All]
finds all occurrences of patt in mol and returns all mappings.
FindMoleculeSubstructure[mol,patt,n]
finds at most n mappings.


FindMoleculeSubstructure
FindMoleculeSubstructure[mol,patt]
finds a mapping between the atom indices in mol and an occurrence of patt in mol.
FindMoleculeSubstructure[mol,patt,All]
finds all occurrences of patt in mol and returns all mappings.
FindMoleculeSubstructure[mol,patt,n]
finds at most n mappings.
Details and Options

- FindMoleculeSubstructure returns a list of associations Association[p1->m1,p2->m2,…] where pi and mi are atom indices in patt and mol, respectively.
- By default, substructure matches are pruned to remove multiple matches to the same set of atoms. Use the option Overlaps->True to disable this behavior.
- FindMoleculeSubstructure takes the following options:
-
IgnoreStereochemistry False whether to ignore stereochemistry IncludeHydrogens Automatic whether to include hydrogen atoms Overlaps False whether to include matches that overlap
Examples
open all close allScope (4)
Use an atomic symbol string as a pattern:
Indicate charge or mass number in the atomic symbol:
Use Atom to make a more general pattern. Find all charged atoms:
Find positively charged atoms:
Find negatively charged atoms:
Use Bond to define a pattern for any double bond:
Options (3)
IgnoreStereochemistry (1)
By default, stereoisomers do not match:
Use IgnoreStereochemistryTrue to get a positive match:
IncludeHydrogens (1)
By default, substructure matching is performed using a molecule's hydrogen-suppressed graph, unless the pattern contains explicit hydrogen atoms:
Some matches to hydrogen will be missed for more involved patterns. In the following example, the pattern is for a carbon atom bonded to either a hydrogen or chlorine atom, but only finds the C-Cl bond:
Use the option IncludeHydrogensTrue to make sure hydrogens are treated as explicit for the purposes of pattern matching:
See Also
Molecule MoleculeContainsQ MoleculePattern MoleculeMatchQ MoleculeSubstructureCount MoleculeFreeQ MoleculePlot AtomList BondList
Function Repository: MoleculeRingPattern
Related Guides
History
Text
Wolfram Research (2019), FindMoleculeSubstructure, Wolfram Language function, https://reference.wolfram.com/language/ref/FindMoleculeSubstructure.html.
CMS
Wolfram Language. 2019. "FindMoleculeSubstructure." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FindMoleculeSubstructure.html.
APA
Wolfram Language. (2019). FindMoleculeSubstructure. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindMoleculeSubstructure.html
BibTeX
@misc{reference.wolfram_2025_findmoleculesubstructure, author="Wolfram Research", title="{FindMoleculeSubstructure}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/FindMoleculeSubstructure.html}", note=[Accessed: 20-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_findmoleculesubstructure, organization={Wolfram Research}, title={FindMoleculeSubstructure}, year={2019}, url={https://reference.wolfram.com/language/ref/FindMoleculeSubstructure.html}, note=[Accessed: 20-August-2025]}