Permalink
Browse files

Synchronized behavior with the MDLV2000Reader (addressing bug #2942196)

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
egonw authored and rajarshi committed Feb 24, 2010
1 parent 4398cc4 commit 2ceef95e7487920db56a0b4f59337adf588c602a
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/main/org/openscience/cdk/io/MDLReader.java
@@ -318,6 +318,8 @@ private IMolecule readMolecule(IMolecule molecule) throws CDKException {
double x = 0.0;
double y = 0.0;
double z = 0.0;
+ double totalX = 0.0;
+ double totalY = 0.0;
double totalZ = 0.0;
//int[][] conMat = new int[0][0];
//String help;
@@ -372,7 +374,10 @@ private IMolecule readMolecule(IMolecule molecule) throws CDKException {
x = new Double(line.substring( 0,10).trim()).doubleValue();
y = new Double(line.substring(10,20).trim()).doubleValue();
z = new Double(line.substring(20,30).trim()).doubleValue();
- totalZ += Math.abs(z); // *all* values should be zero, not just the sum
+ // *all* values should be zero, not just the sum
+ totalX += Math.abs(x);
+ totalY += Math.abs(y);
+ totalZ += Math.abs(z);
logger.debug("Coordinates: " + x + "; " + y + "; " + z);
String element = line.substring(31,34).trim();
@@ -484,7 +489,12 @@ private IMolecule readMolecule(IMolecule molecule) throws CDKException {
}
// convert to 2D, if totalZ == 0
- if (totalZ == 0.0 && !forceReadAs3DCoords.isSet()) {
+ if (totalX == 0.0 && totalY == 0.0 && totalZ == 0.0) {
+ logger.info("All coordinates are 0.0");
+ for (IAtom atomToUpdate : molecule.atoms()) {
+ atomToUpdate.setPoint3d(null);
+ }
+ } else if (totalZ == 0.0 && !forceReadAs3DCoords.isSet()) {
logger.info("Total 3D Z is 0.0, interpreting it as a 2D structure");
Iterator<IAtom> atomsToUpdate = molecule.atoms().iterator();
while (atomsToUpdate.hasNext()) {

0 comments on commit 2ceef95

Please sign in to comment.