Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 19, 2012
John May johnmay Added ability to read atom parity from Mol files (inc. junit test). 07bbbb2
John May johnmay Added close to unit-test resource stream eae7598
Egon Willighagen egonw Fixed unit test: because the implementation creates an IMolecule obje…
…ct, the original 'molecule' pointer does not get atoms, and the returned IMolecule object should be assigned to get a molecule with information

Change-Id: I480895ef8a0f308a279f80c869a6efb93c67cbee
8ff4584
5 src/main/org/openscience/cdk/io/MDLV2000Reader.java
View
@@ -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);
16 src/test/data/mdl/mol_testAtomParity.mol
View
@@ -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
25 src/test/org/openscience/cdk/io/MDLV2000ReaderTest.java
View
@@ -24,6 +24,7 @@
* */
package org.openscience.cdk.io;
+import java.io.IOException;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -919,4 +920,28 @@ public void testPseudoAtomLabels() throws Exception {
Assert.assertEquals("Gln", pa.getLabel());
}
+ @Test
+ public void testAtomParity() throws CDKException, IOException{
+
+ InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/mol_testAtomParity.mol");
+ MDLV2000Reader reader = new MDLV2000Reader(in);
+ IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
+ molecule = reader.read(molecule);
+ reader.close();
+
+ Assert.assertEquals(6, molecule.getAtomCount());
+ boolean chiralCentre = false;
+ IAtom[] atoms = AtomContainerManipulator.getAtomArray(molecule);
+ for (IAtom atom : atoms) {
+ Integer parity = atom.getStereoParity();
+ if(parity == 1){
+ chiralCentre = true;
+ }
+ }
+
+
+ Assert.assertTrue(chiralCentre);
+
+ }
+
}

No commit comments for this range

Something went wrong with that request. Please try again.