Skip to content

Commit

Permalink
Read dimension field - there was actually already a test file that pr…
Browse files Browse the repository at this point in the history
…eviously required setting a flag.
  • Loading branch information
johnmay committed Sep 25, 2017
1 parent 77ce652 commit a37ba2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce

int linecount = 0;
String title = null;
String program = null;
String remark = null;
String line = "";

Expand All @@ -333,6 +334,7 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce
}
line = input.readLine();
linecount++;
program = line;
line = input.readLine();
linecount++;
if (line.length() > 0) {
Expand Down Expand Up @@ -406,8 +408,10 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce
}
}
} else if (!hasZ) {

if (!forceReadAs3DCoords.isSet()) {
//' CDK 09251712073D'
// 0123456789012345678901
if (!(program.length() >= 22 && program.substring(20, 22).equals("3D"))
&& !forceReadAs3DCoords.isSet()) {
for (IAtom atomToUpdate : atoms) {
Point3d p3d = atomToUpdate.getPoint3d();
if (p3d != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,24 @@ public void testZeroZCoordinates() throws Exception {
assertTrue(has3d);
}

/**
* @cdk.bug 1732307
*/
@Test
public void testZeroZCoordinates3DMarked() throws Exception {
String filename = "data/mdl/nozcoord.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins);
IAtomContainer mol = reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class));
reader.close();
Assert.assertNotNull(mol);
Assert.assertEquals(5, mol.getAtomCount());

boolean has3d = GeometryUtil.has3DCoordinates(mol);
assertTrue(has3d);
}

/**
* @cdk.bug 1826577
*/
Expand Down

0 comments on commit a37ba2f

Please sign in to comment.