I would like to use RDKit to highlight all benzene rings (regardless of substitution pattern - e.g. phenol, chlorobenene, benzoic acid type should all be highlighted) in any given molecule. I cannot come up with a general SMARTS pattern that simply matches 'benzene ring'. This seems like it should be a lot simpler than I found it to be :<
just "[c]1:[c]:[c]:[c]:[c]:[c]1" should do the job. lowercase c means aromatic carbon, i also include aromatic bonds ":" explicitly though even without it should work quite well for your purpose.
from rdkit import Chem patt=Chem.MolFromSmarts("[c]1:[c]:[c]:[c]:[c]:[c]1") chlorobenzene=Chem.MolFromSmiles("c1ccccc1Cl") phenol=Chem.MolFromSmiles("c1ccccc1O") benzoicacid=Chem.MolFromSmiles("c1ccccc1C(=O)O") for m in [chlorobenzene,phenol,benzoicacid]: print(m.HasSubstructMatch(patt))
True three times