diff --git a/src/main/java/org/openmolecules/chem/conf/so/TetrahedralStereoRule.java b/src/main/java/org/openmolecules/chem/conf/so/TetrahedralStereoRule.java index eaab6430..b8c5f235 100644 --- a/src/main/java/org/openmolecules/chem/conf/so/TetrahedralStereoRule.java +++ b/src/main/java/org/openmolecules/chem/conf/so/TetrahedralStereoRule.java @@ -30,6 +30,7 @@ import com.actelion.research.chem.Coordinates; import com.actelion.research.chem.Molecule; +import com.actelion.research.chem.MolfileCreator; import com.actelion.research.chem.StereoMolecule; import com.actelion.research.chem.conf.Conformer; @@ -187,7 +188,6 @@ private void calculateRotatableAtoms(StereoMolecule mol, int[] neighbourAtom, in int stereoCenter = neighbourAtom[4]; int neighbours = (neighbourAtom[3] == -1) ? 3 : 4; - int[] fragmentNo = new int[mol.getAllAtoms()]; boolean[] neglectBond = new boolean[mol.getAllBonds()]; for (int i=0; i=3 neighbour-bond-fragment and to proportionally rotate the closer part of it and not just one atom int remainingNeighboursToRotate = neighbours - 2 - (rotatableAtomCount == 0 ? 0 : 1); for (int i=0; i=mRotatableNeighbour.length) { + System.out.println("##### Out of bounds exception:"+new MolfileCreator(mol).getMolfile()); + System.out.print("neighbours:"+neighbours+" "); + System.out.print("neighbourAtom:"); for (int k:neighbourAtom) System.out.print(" " + k); System.out.println(); + System.out.print("neighbourBond:"); for (int k : neighbourBond) System.out.print(" " + k); System.out.println(); + System.out.print("fragmentNo:"); for (int k : fragmentNo) System.out.print(" " + k); System.out.println(); + System.out.print("isNeighbourFragment:"); for (boolean k : isNeighbourFragment) System.out.print(" " + k); System.out.println(); + System.out.print("isRotatableAtom:"); for (boolean b : isRotatableAtom) System.out.print(" " + b); System.out.println(); +} mRotatableNeighbour[rotatableIndex++] = neighbourAtom[i]; +} else mStaticNeighbour[staticIndex++] = neighbourAtom[i]; } @@ -324,7 +338,8 @@ private void calculateRotatableAtoms(StereoMolecule mol, int[] neighbourAtom, in private Coordinates calculateRotationAxis(Conformer conformer) { Coordinates axis = new Coordinates(); - for (int atom:mStaticNeighbour) + int[] neighbour = (mStaticNeighbour.length == 2) ? mStaticNeighbour : mRotatableNeighbour; + for (int atom:neighbour) axis.add(conformer.getCoordinates(atom)); axis.scale(0.5); @@ -343,8 +358,8 @@ public String toString() { StringBuilder sb = new StringBuilder("stereo rule:"); super.addAtomList(sb); sb.append(" rotatable:"); - for (int rn:mRotatableNeighbour) - sb.append(rn+" "); + for (int ra:mRotatableAtom) + sb.append(ra+" "); return sb.toString(); } }