I am encountering a strange error with the following molecule:

mol = Molecule[
    IncludeHydrogens -> All

MoleculePlot[mol, {{27}, {28}}]


The orange hydrogen atom has the index 27, and the blue one the index 28.

Now I try to evaluate the following two expressions:

mol // MoleculeModify[{"DeleteAtom", 27}]
mol // MoleculeModify[{"DeleteAtom", 28}]

In the first case, I get back a molecule. But in the second case, I do not. I simply get back the unevaluated expression.

DeleteAtom expressions

I wanted to see whether it was the bond with the nitrogen atom that was causing the problem. Evidently, it was not.

nh3 = Molecule["ammonia", IncludeHydrogens -> All];
nh3 // MoleculeModify[{"DeleteAtom", 2}]

DeleteAtom for NH3

Question. Why does deleting atom 28 in mol not work? I could find nothing in the documentation of MoleculeModify to indicate that deleting that hydrogen should not work.


Mathematica Version 13.0.1, Windows 11 Pro

  • $\begingroup$ is bug, will fix $\endgroup$
    – Jason B.
    Commented Mar 2, 2022 at 15:52
  • $\begingroup$ As a workaround, when trying to delete a hydrogen atom you can increment the unpaired electron count of the neighbor atom (this has to be done anyway or the hydrogen atom will be re-added to fill the valence). MoleculeModify[mol, {"SetUnpairedElectronCount", 3 -> 1}] works for this molecule. $\endgroup$
    – Jason B.
    Commented Mar 2, 2022 at 15:58
  • $\begingroup$ @JasonB. Just to confirm: Is this workaround needed only when deleting hydrogen atoms? $\endgroup$ Commented Mar 2, 2022 at 19:10
  • $\begingroup$ The only time the neighbor atom's unpaired electron count is incremented is when deleting a hydrogen atom, when you are explicitly creating a radical. $\endgroup$
    – Jason B.
    Commented Mar 2, 2022 at 19:25

1 Answer 1


This bug was fixed in version 13.1:

In[1]:= mol = Molecule["C=c1[nH]nc(C(=O)N2CCN(C(=O)CCCOC)CC2)c1=CC=CC"];                                      

In[2]:= mol // MoleculeModify[{"DeleteAtom", 27}]                                                             

Out[2]= Molecule[<C18H25N4O3>]

In[3]:= mol // MoleculeModify[{"DeleteAtom", 28}]                                                             

Out[3]= Molecule[<C18H25N4O3>]

In[4]:= $Version                                                                                              

Out[4]= 13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)

Your Answer

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

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