3
$\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$
  • 1
    $\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$ – Jason B. Feb 4 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$ – Shredderroy Feb 5 at 0:25
3
$\begingroup$
MoleculePlot[mol1, First @ AtomList[mol1,"O","AtomIndex"]]

enter image description here

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

enter image description here

| improve this answer | |
$\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

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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