0
$\begingroup$

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 :<

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

demonstration:

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))

spits out True three times

$\endgroup$
1
  • $\begingroup$ Thanks so much wikke! $\endgroup$
    – Guest
    Nov 23 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.