WLJS LogoWLJS Notebook

FindMoleculeSubstructure

Find atom-index mappings for molecular substructure matches.

FindMoleculeSubstructure[mol, patt] finds a mapping between the atom indices in patt and one occurrence in mol.

FindMoleculeSubstructure[mol, patt, All] returns mappings for all occurrences. Replace All with an integer n to return at most n mappings.

Examples

Find every five-carbon chain in hexane:

molecule = Molecule["hexane"];
pattern = MoleculePattern["CCCCC"];

FindMoleculeSubstructure[molecule, pattern, All]

Highlight the atoms from the first match:

match = First[FindMoleculeSubstructure[molecule, pattern]];
MoleculePlot[molecule, Values[match]]

See MoleculePattern and MoleculeSubstructureCount.

Something isn't working? Report an issue.

Please visit the official Wolfram Language Reference for more details.

On this page