Menu

#1383 AtomContainerManipulator.convertImplicitToExplicitHydrogens does not treat correctly the chiral atoms with H atom ligand

cdk-1.6.x
closed
John May
None
1
2016-08-18
2016-08-17
No

This bug was very tricky to hunt down. It was found with CDK 1.5.13
The code within function convertImplicitToExplicitHydrogens() is OK. However it does not work.
The problems comes from the fact that function TetrahedralChirality.getLigands() returns a copy of ligands array and the code bellow (which is logiaclly correct) changes the copy but the original stereo element is not changed at all.

// update tetrahedral elements with an implicit part
for (IStereoElement se : atomContainer.stereoElements()) {
if (se instanceof ITetrahedralChirality) {
ITetrahedralChirality tc = (ITetrahedralChirality) se;

            IAtom focus = tc.getChiralAtom();
            IAtom[] neighbors = tc.getLigands();
            IAtom hydrogen = hNeighbor.get(focus);

            // in sulfoxide - the implicit part of the tetrahedral centre
            // is a lone pair
            if (hydrogen == null) continue;

            for (int i = 0; i < tc.getLigands().length; i++) {
                if (neighbors[i] == focus) {
                    neighbors[i] = hydrogen;
                    break;
                }
            }
        }
    }

And here is the code for the function getLigands():

public IAtom[] getLigands() {
IAtom[] arrayCopy = new IAtom[4];
System.arraycopy(ligandAtoms, 0, arrayCopy, 0, 4);
return arrayCopy;
}

Discussion

  • John May

    John May - 2016-08-17

    Ahhh! Good find Nikolay, I'll get that patched right away.

     
  • John May

    John May - 2016-08-17

    Easy to fix so did it now - https://github.com/cdk/cdk/pull/230

     
  • Nikolay Kochev

    Nikolay Kochev - 2016-08-17

    Great!

     
  • John May

    John May - 2016-08-18
    • status: open --> closed
     
  • John May

    John May - 2016-08-18

    Resolved