Skip to content

Commit

Permalink
Merge branch 'cdk-1.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Feb 26, 2010
2 parents 04001b7 + e1c03fb commit 5944d6a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 96 deletions.
14 changes: 12 additions & 2 deletions src/main/org/openscience/cdk/io/MDLReader.java
Expand Up @@ -319,6 +319,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;
Expand Down Expand Up @@ -373,7 +375,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();

Expand Down Expand Up @@ -485,7 +490,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()) {
Expand Down

0 comments on commit 5944d6a

Please sign in to comment.