({{, (RefLink[FindMoleculeSubstructure, paclet:ref/FindMoleculeSubstructure])[mol,patt] 
finds a mapping between the atom indices in mol and all occurrences of patt in mol.}, {, (RefLink[FindMoleculeSubstructure, paclet:ref/FindMoleculeSubstructure])[mol,patt,n]
finds at most n mappings.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[FindMoleculeSubstructure, paclet:ref/FindMoleculeSubstructure]) returns a list of associations (RefLink[Association, paclet:ref/Association])[(Subscript[p, 1])->(Subscript[m, 1]),(Subscript[p, 2])->(Subscript[m, 2]),…] where (Subscript[p, i]) and (Subscript[m, i]) are atom indices in patt and mol, respectively.

If n is (RefLink[All, paclet:ref/All]), all mappings are returned.

By default, substructure matches are pruned to remove multiple matches to the same set of atoms. Use the option (RefLink[Overlaps, paclet:ref/Overlaps])->(RefLink[True, paclet:ref/True]) to disable this behavior.

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Find phenyl rings in a molecule:

m=Molecule["CCCc1cccc(c1)CCCCC(c2ccccc2)CC"]

benz=MoleculePattern["c1ccccc1"];
FindMoleculeSubstructure[m,benz,All]

Find all alcohol functional groups:

m=Molecule[];

FindMoleculeSubstructure[m,MoleculePattern[{"C","O","H"},{Bond[{1,2}],Bond[{2,3}]}],All]

OpenersExampleSection1(Spacer1)Scope  (4)

Use an atomic symbol string as a pattern:

water=Molecule["water"];
FindMoleculeSubstructure[water,"O"]

FindMoleculeSubstructure[water,"H",All]

Indicate charge or mass number in the atomic symbol:

m=Molecule[];

FindMoleculeSubstructure[m,"O-"]

FindMoleculeSubstructure[m,"14C"]

Use (RefLink[Atom, paclet:ref/Atom]) to make a more general pattern. Find all charged atoms:

m=Molecule[];

FindMoleculeSubstructure[m,Atom["FormalCharge"->Except[0]],All]

Find positively charged atoms:

FindMoleculeSubstructure[m,Atom["FormalCharge"->GreaterThan[0]],All]

Find negatively charged atoms:

FindMoleculeSubstructure[m,Atom["FormalCharge"->LessEqualThan[-1]],All]

Use (RefLink[Bond, paclet:ref/Bond]) to define a pattern for any double bond:

m=Molecule[];

FindMoleculeSubstructure[m,Bond[_,"Double"],All]

Find only double bonds with a nitrogen atom:

FindMoleculeSubstructure[m,Bond[{"N",_},"Double"],All]

Find double bonds with a charged atom:

FindMoleculeSubstructure[m,Bond[{Atom["FormalCharge"->Except[0]],_},"Double"],All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MoleculeContainsQ, paclet:ref/MoleculeContainsQ])  ▪  (RefLink[MoleculePattern, paclet:ref/MoleculePattern])  ▪  (RefLink[MoleculePlot, paclet:ref/MoleculePlot])  ▪  (RefLink[AtomList, paclet:ref/AtomList])  ▪  (RefLink[BondList, paclet:ref/BondList])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Molecular Structure & Computation, paclet:guide/MolecularStructureAndComputation])}, {▪(RefLinkPlain[Physics & Chemistry: Data and Computation, paclet:guide/PhysicsAndChemistryDataAndComputation])}})}})