Skip to content

Commit

Permalink
Fixed proton isotope perception.
Browse files Browse the repository at this point in the history
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information
Stephan Beisken authored and egonw committed Mar 23, 2013
1 parent c273930 commit 421345b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -925,14 +925,14 @@ private void fixHydrogenIsotopes(IMolecule molecule,IsotopeFactory isotopeFactor
if ("D".equals(pseudo.getLabel())) {
IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class,atom);
newAtom.setSymbol("H");
IIsotope isotope = molecule.getBuilder().newInstance(IIsotope.class,"H", 2);
isotopeFactory.configure(newAtom, isotope);
IIsotope isotope = molecule.getBuilder().newInstance(IIsotope.class, 1, "H", 2, 2.014101778, 0.0115);
isotopeFactory.configure(newAtom, isotope);
AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom);
} else if ("T".equals(pseudo.getLabel())) {
IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class,atom);
newAtom.setSymbol("H");
IIsotope isotope = molecule.getBuilder().newInstance(IIsotope.class,"H", 3);
isotopeFactory.configure(newAtom, isotope);
IIsotope isotope = molecule.getBuilder().newInstance(IIsotope.class, 1, "H", 3, 3.016049278, 0d);
isotopeFactory.configure(newAtom, isotope);
AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom);
}
}
Expand Down
40 changes: 32 additions & 8 deletions src/test/org/openscience/cdk/io/MDLV2000ReaderTest.java
Expand Up @@ -25,9 +25,18 @@
package org.openscience.cdk.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openscience.cdk.AtomContainer;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.ChemModel;
Expand All @@ -49,14 +58,6 @@
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;

import java.io.InputStream;
import java.io.StringReader;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;


/**
* TestCase for the reading MDL mol files using one test file.
Expand Down Expand Up @@ -865,6 +866,18 @@ public void testDeuterium() throws Exception {
Assert.assertEquals(3, deuteriumCount);
}

@Test
public void testDeuteriumProperties() throws Exception {
String filename = "data/mdl/chemblMolregno5369.mol";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.RELAXED);
IAtomContainer molecule = new AtomContainer();
molecule = reader.read(molecule);
IAtom deuterium = molecule.getAtom(molecule.getAtomCount() - 1);
Assert.assertTrue(1 == deuterium.getAtomicNumber());
Assert.assertTrue(2.014101778 == deuterium.getExactMass());
}

@Test public void testTritium() throws Exception {
String filename = "data/mdl/chemblMolregno7039.mol";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
Expand All @@ -878,6 +891,17 @@ public void testDeuterium() throws Exception {
Assert.assertEquals(1, tritiumCount);
}

@Test public void testTritiumProperties() throws Exception {
String filename = "data/mdl/chemblMolregno7039.mol";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins);
IAtomContainer molecule = new AtomContainer();
molecule = reader.read(molecule);
IAtom tritium = molecule.getAtom(molecule.getAtomCount() - 1);
Assert.assertTrue(1 == tritium.getAtomicNumber());
Assert.assertTrue(3.016049278 == tritium.getExactMass());
}

/**
* Test that R-groups at higher atom numbers (>9) are read correctly
*/
Expand Down

0 comments on commit 421345b

Please sign in to comment.