6
$\begingroup$

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

$\endgroup$
2
  • 3
    $\begingroup$ 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])]"]} $\endgroup$ Commented Feb 4, 2020 at 23:17
  • $\begingroup$ 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. $\endgroup$ Commented Feb 5, 2020 at 0:25

3 Answers 3

6
$\begingroup$
MoleculePlot[mol1, First @ AtomList[mol1,"O","AtomIndex"]] 

enter image description here

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

enter image description here

$\endgroup$
3
$\begingroup$

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

$\endgroup$
3
$\begingroup$

The reason why OP's attempt is incorrect has been explained by Jason in the comment above, here I'd like to add another solution for OP's problem, which (I believe) is handier than existing solutions under this and the previous question from OP. The workflow is, first use AtomLabels -> "AtomIndex" option of MoleculePlot to check the needed index:

MoleculePlot[mol1, AtomLabels -> "AtomIndex"] 

enter image description here

We immediately see the index of the interested oxygen atom is 1, and the carbon atom on the other side of the double bond is 2, so, to highlight the oxygen atom:

MoleculePlot[mol1, 1] 

enter image description here

To highlight the corresponding double bond:

MoleculePlot[mol1, Bond@{1, 2}] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.