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;
}
Ahhh! Good find Nikolay, I'll get that patched right away.
Easy to fix so did it now - https://github.com/cdk/cdk/pull/230
Great!
Resolved