#1264 Stereochemistry is lost when cloning an IAtomContainer

cdk-1.4.x
closed
nobody
None
9
2012-11-04
2012-10-18
No

Reported in the Bioclipse bug tracker:

When an AtomContainer is cloned it seams to lose the stereochemistry
information, and therefore the InChI of the clone isn't the same as for the
original AtomContainer.

Comparing the InChIs (with Assert.assertEquals() ) result in a failure with the
stack-trace:
org.junit.ComparisonFailure:
expected:<...23-24H,13-14H2,1-6H3[/t19-,20+,23+,24-]> but
was:<...23-24H,13-14H2,1-6H3[]>
...
For the cloned AtomContainer the InChI-generator status is 'warning' (for the
"real" AtomContainer it's 'okey') with the message:
Wrong 0D stereo descriptor(s): #1; #2; #3; #4; Omitted undefined stereo

I also tried to copy the AtomContainer using '[...] new_mol = new
AtomContainer(old_mol);'
The only difference in the result doing so was the warning-message from the
InChI-generator (for the copied AtomContainer new_mol):
Omitted undefined stereo

See -> http://pele.farmbio.uu.se/bugzilla36/show_bug.cgi?id=3170

Discussion

  • John May

    John May - 2012-10-19

    I have a feeling this might be tricky. You can't just clone the the IStereoElements as the atoms won't match that of the clone. So you need to map the atoms of each element from their old to new counter parts. As there are multiple stereo-element it would have to be done for each one independently.

    :/

     
  • Egon Willighagen

    John, absolutely true, but not different from cloning bonds... the trick I think the code uses, is to create a temporary map of cloned atoms with the uncloned atoms as keys, so that you can look up what the matching (already cloned) atom is...

     
  • John May

    John May - 2012-10-19

    using the new markdown in trackers...

    newAtoms = new IAtom[bond.getAtomCount()];
    for (int j = 0; j < bond.getAtomCount(); ++j) {
        newAtoms[j] = clone.getAtom(getAtomNumber(bond.getAtom(j)));
    }
    

    It may be quicker to use a map instead of getAtomNumber() which is O(N) but perhaps for small arrays there wouldn't be a noticeable difference.

     
    Last edit: John May 2012-10-19
  • John May

    John May - 2012-11-04

    Patch has been apply to egonw/cdk-1.4.x

     
  • John May

    John May - 2012-11-04
    • status: open --> closed