Skip to content

Commit

Permalink
Converting implicit to explicit hydrogens needs to copy the stereoche…
Browse files Browse the repository at this point in the history
…mistry [bug:1383]
  • Loading branch information
johnmay committed Aug 17, 2016
1 parent 6582393 commit c05d665
Showing 1 changed file with 17 additions and 8 deletions.
Expand Up @@ -438,26 +438,35 @@ public static void convertImplicitToExplicitHydrogens(IAtomContainer atomContain
atomContainer.addBond(bond);

// update tetrahedral elements with an implicit part
for (IStereoElement se : atomContainer.stereoElements()) {
if (se instanceof ITetrahedralChirality) {
ITetrahedralChirality tc = (ITetrahedralChirality) se;
List<IStereoElement> stereos = new ArrayList<>();
for (IStereoElement stereo : atomContainer.stereoElements()) {
if (stereo instanceof ITetrahedralChirality) {
ITetrahedralChirality tc = (ITetrahedralChirality) stereo;

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;
if (hydrogen != null) {
for (int i = 0; i < 4; i++) {
if (neighbors[i] == focus) {
neighbors[i] = hydrogen;
break;
}
}
// neighbors is a copy so need to create a new stereocenter
stereos.add(new TetrahedralChirality(focus, neighbors, tc.getStereo()));
} else {
stereos.add(stereo);
}
} else {
stereos.add(stereo);
}
}
atomContainer.setStereoElements(stereos);

}

Expand Down

0 comments on commit c05d665

Please sign in to comment.