Skip to content

Commit

Permalink
Added ability to read atom parity from Mol files (inc. junit test).
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Feb 19, 2012
1 parent fb47c57 commit 07bbbb2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -518,6 +518,11 @@ private IMolecule readMolecule(IMolecule molecule) throws CDKException {
logger.error("Cannot set mass difference for a non-element!");
}


// set the stereo partiy
Integer parity = line.length() > 41 ? Character.digit(line.charAt(41), 10) : 0;
atom.setStereoParity(parity);

if (line.length() >= 51) {
String valenceString = removeNonDigits(line.substring(48,51));
logger.debug("Valence: ", valenceString);
Expand Down
16 changes: 16 additions & 0 deletions src/test/data/mdl/mol_testAtomParity.mol
@@ -0,0 +1,16 @@

Mrv0541 01311217092D

6 5 0 0 0 0 999 V2000
-1.1749 0.1436 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
-0.7624 0.8581 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.7624 -0.5709 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
-1.1749 1.5726 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
0.0626 0.8581 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
-1.9999 0.1436 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 1 0 0 0
2 4 2 0 0 0 0
2 5 1 0 0 0 0
1 6 1 0 0 0 0
M END
21 changes: 21 additions & 0 deletions src/test/org/openscience/cdk/io/MDLV2000ReaderTest.java
Expand Up @@ -919,4 +919,25 @@ public void testPseudoAtomLabels() throws Exception {
Assert.assertEquals("Gln", pa.getLabel());
}

@Test
public void testAtomParity() throws CDKException{

InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/mol_testAtomParity.mol");
MDLV2000Reader reader = new MDLV2000Reader(in);
IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
reader.read(molecule);

boolean chiralCentre = false;
IAtom[] atoms = AtomContainerManipulator.getAtomArray(molecule);
for (IAtom atom : atoms) {
Integer parity = atom.getStereoParity();
if(parity == 1){
chiralCentre = true;
}
}

Assert.assertTrue(chiralCentre);

}

}

0 comments on commit 07bbbb2

Please sign in to comment.