The Wolfram Language allows searching for and highlighting arbitrarily defined substructures within a Molecule object. This example shows how patterns can be defined for atoms, bonds and arbitrary substructures.
Patterns representing individual atoms can be defined as strings or Atom objects.
Create highlighting rules with a label for each pattern.
The labels on the left-hand sides of the result automatically form a legend.
Patterns for bonds are defined using the Bond head.
Use MoleculePattern to represent complex patterns like a carboxylic ester, using a combination of atoms and bonds.
The pattern is highlighted without a caption when just the pattern is used.