# How can I highlight a single atom in MoleculePlot?

Consider the following molecule:

mol1 = Molecule["O=C(N(CC(NCC(F)(F)F)=O)CN1C2=CC=CC=C2)C31CCN(C(C4=CC(C=NN5)=C5C=C4)=O)CC3"];


In AtomList[mol1], the first atom is an oxygen. According to the documentation of MoleculePattern, one of the formats of invocation (the third one) is as follows:

MoleculePattern[mol, {id1, id2, …}] returns a molecule pattern consisting of the atoms from mol with index idi and their connecting bonds.

Thus, I would expect that

MoleculePlot[mol1, MoleculePattern[mol1, {1}]]


would highlight only the first oxygen atom (the orange one, and perhaps the double bond that goes with it). Instead, the output is the following:

All three of the oxygen atoms are highlighted. Is this a bug in MoleculePlot, or is the documentation incorrect? Is there a workaround to highlight only a single atom at a time?

• MoleculePattern[mol1, {1}] returns a pattern that should match atom 1 in mol1. In this case, that pattern also matches other oxygen atoms. To get a pattern to specifically match each oxygen requires a recursive SMARTS. The three oxygen atoms should be matched by {MoleculePattern["[$(O=Cc)]"], MoleculePattern["[$(O=C[R0])]"], MoleculePattern["[\$(O=C[R2])]"]} – Jason B. Feb 4 '20 at 23:17
• Thanks for the comment about SMARTS. Unfortunately, I am not a chemist, so I am having to learn some of these things as I go along. – Shredderroy Feb 5 '20 at 0:25

MoleculePlot[mol1, First @ AtomList[mol1,"O","AtomIndex"]]


MoleculePlot[mol1, Last @ AtomList[mol1,"O","AtomIndex"]]


Actually, there is no need to specify a MoleculePattern for what you want to do. If you read the documentation carefully you merely want to specify an Integer atom index (or a list of Integer atom indices) as the second argument to MoleculePlot, not a pattern. Here's an example:

mol1 = Molecule[
"O=C(N(CC(NCC(F)(F)F)=O)CN1C2=CC=CC=C2)C31CCN(C(C4=CC(C=NN5)=C5C=\
C4)=O)CC3"];
MoleculePlot[mol1, 1]


MoleculePlot[mol1, {1, 3, 5}]