Atom Unique IDs and OBMol / SetOBMol

OK, I’ve been tracking down a subtle bug that shows up in the insert feature.

I’ve added a new twist in v1.1 that you can “grow by fragment” – if you have selected atoms when you insert a fragment, the hydrogens are replaced by the inserted fragment.

Only, there’s a clear bug if you insert benzene and then insert again – you should end up with 6 benzenes linked to the central benzene ring. You don’t. The code is “doing the right thing,” except the unique IDs for the atoms aren’t unique once you go through OBMol / SetOBMol.

See the pictures – the labels are atom->id(). Notice that in the first picture, the first two carbon atoms are ID 1 and 2. Then in the next image, they’re ID 0 and 1. All the other numbering is off too.

I just pushed something to Gerrit which attempts to fix this. When we copy OBMol / call setOBMol, the unique IDs would be lost before. The patch copies ids to OpenBabel, and attempts to find matching atoms when running setOBMol.

But it doesn’t do anything.

Suggestions?


Prof. Geoffrey Hutchison
Department of Chemistry
University of Pittsburgh
tel: (412) 648-0492
email: geoff.hutchison@gmail.com
web: http://hutchison.chem.pitt.edu/

I just pushed something to Gerrit which attempts to fix this. When we copy OBMol / call setOBMol, the unique IDs would be lost before. The patch copies ids to OpenBabel, and attempts to find matching atoms when running setOBMol.

But it doesn’t do anything.

Aha. I found out that OBAtom doesn’t copy its unique IDs. So there’s a bug in Open Babel, which I’m about to fix.

Now the Avogadro code crashes properly. So it’s doing something. :wink:

-Geoff