4

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:

mol1

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?

Thanks in advance

AsukaMinato
  • 9,758
  • 1
  • 14
  • 40
Shredderroy
  • 5,249
  • 17
  • 26
  • 2
    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 04 '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 05 '20 at 00:25

2 Answers2

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

enter image description here

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

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
3

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]

highlighting the atom index 1 in the MoleculePlot

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

list of atom indices, highlights multiple atoms

Joshua Schrier
  • 3,356
  • 8
  • 19