Permalink
Browse files

Merged cdk-1.4.x

  • Loading branch information...
2 parents db6b021 + 03ef86b commit edddc48b61003e278cb4f8d05ea12bdf805d3c1b @egonw committed Jan 23, 2012
View
@@ -303,6 +303,7 @@
<param name="module" value="${module}"/>
</antcall>
+ <ant antfile="javadoc.xml" target="compileDocTests"/>
<ant antfile="javadoc.xml" target="ojdcheck-module">
<property name="module" value="${module}"/>
</ant>
View
@@ -240,6 +240,7 @@
<classpath>
<fileset dir="develjar/">
<include name="ojdcheck.jar" />
+ <include name="com-sun-*.jar" />
</fileset>
</classpath>
</javac>
@@ -67,7 +67,7 @@
/**
* Reads content from MDL molfiles and SD files.
- * It can read a {@link IMolecule} or {@link IChemModel} from an MDL molfile, and
+ * It can read a {@link IAtomContainer} or {@link IChemModel} from an MDL molfile, and
* a {@link IChemFile} from a SD file, with a {@link IChemSequence} of
* {@link IChemModel}'s, where each IChemModel will contain one IMolecule.
*
@@ -167,6 +167,7 @@ public boolean accepts(Class<? extends IChemObject> classObject) {
if (IChemFile.class.equals(interfaces[i])) return true;
if (IChemModel.class.equals(interfaces[i])) return true;
if (IAtomContainer.class.equals(interfaces[i])) return true;
+ if (IAtomContainer.class.equals(interfaces[i])) return true;
}
Class superClass = classObject.getSuperclass();
if (superClass != null) return this.accepts(superClass);
@@ -487,15 +488,16 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce
}
}
else {
- atom = molecule.getBuilder().newInstance(IPseudoAtom.class,"R");
+ atom = molecule.getBuilder().newInstance(IPseudoAtom.class,element);
}
} else {
handleError(
- "Invalid element type. Must be an existing " +
- "element, or one in: A, Q, L, LP, *.",
- linecount, 32, 35
+ "Invalid element type. Must be an existing " +
+ "element, or one in: A, Q, L, LP, *.",
+ linecount, 32, 35
);
- atom = molecule.getBuilder().newInstance(IPseudoAtom.class,element);
+ atom = molecule.getBuilder().newInstance(IPseudoAtom.class, element);
+ atom.setSymbol(element);
}
// store as 3D for now, convert to 2D (if totalZ == 0.0) later
@@ -20,22 +20,6 @@
*/
package org.openscience.cdk.io;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.vecmath.Point2d;
-import javax.vecmath.Point3d;
-
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
@@ -54,6 +38,21 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.BondManipulator;
+import javax.vecmath.Point2d;
+import javax.vecmath.Point3d;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* Class that implements the MDL mol V3000 format. This reader reads the
* element symbol and 2D or 3D coordinates from the ATOM block.
@@ -128,6 +127,7 @@ public boolean accepts(Class classObject) {
Class[] interfaces = classObject.getInterfaces();
for (int i=0; i<interfaces.length; i++) {
if (IAtomContainer.class.equals(interfaces[i])) return true;
+ if (IAtomContainer.class.equals(interfaces[i])) return true;
}
Class superClass = classObject.getSuperclass();
if (superClass != null) return this.accepts(superClass);
@@ -271,6 +271,7 @@ public void readAtomBlock(IAtomContainer readData) throws CDKException {
throw new CDKException("Invalid element type. Must be an existing element, or one in: A, Q, L, LP, *.");
}
atom = readData.getBuilder().newInstance(IPseudoAtom.class,element);
+ atom.setSymbol(element);
}
// parse atom coordinates (in Angstrom)
@@ -584,14 +585,6 @@ public boolean isReady() throws CDKException {
}
}
- @TestMethod("testAccepts")
- public boolean accepts(IChemObject object) {
- if (object instanceof IAtomContainer) {
- return true;
- }
- return false;
- }
-
@TestMethod("testClose")
public void close() throws IOException {
input.close();
@@ -0,0 +1,78 @@
+
+ -OEChem-01171208162D
+
+ 31 32 0 1 0 0 0 0 0999 V2000
+ 2.2700 -0.5000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ -1.2200 -0.1300 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.9600 -0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.6200 1.4900 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.1200 -1.4500 0.0000 Gln 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.8400 -0.9400 0.0000 Ile 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.7600 -1.5400 0.0000 Asn 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.1200 0.7400 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 1.7600 -1.2400 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.2000 1.8500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.1800 -1.5400 0.0000 Pro 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.0200 -1.7800 0.0000 Leu 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.2600 -2.6500 0.0000 Gly 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.1000 -0.2500 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.5800 -0.0700 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8400 1.2800 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.0400 2.7500 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.1000 -2.8900 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.6800 0.9200 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.5400 -1.2400 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.4300 0.5500 0.0000 C 0 0 0 0 0 0 0 0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+Carbetocin
+
+> <Entry_Date>
+6/19/1990
+
+$$$$
@@ -0,0 +1,32 @@
+
+ Marvin 01211213222D
+
+ 0 0 0 0 0 999 V3000
+M V30 BEGIN CTAB
+M V30 COUNTS 10 10 0 0 0
+M V30 BEGIN ATOM
+M V30 1 C -1.925 0.935 0 0
+M V30 2 C -3.2587 0.165 0 0
+M V30 3 C -3.2587 -1.375 0 0
+M V30 4 C -1.925 -2.145 0 0
+M V30 5 C -0.5913 -1.375 0 0
+M V30 6 C -0.5913 0.165 0 0
+M V30 7 C 0.8962 0.5636 0 0
+M V30 8 C 2.2299 -0.2064 0 0
+M V30 9 C 3.7174 0.1922 0 0
+M V30 10 Leu 0.8962 2.1036 0 0
+M V30 END ATOM
+M V30 BEGIN BOND
+M V30 1 1 1 2
+M V30 2 2 1 6
+M V30 3 2 2 3
+M V30 4 1 3 4
+M V30 5 2 4 5
+M V30 6 1 5 6
+M V30 7 1 6 7
+M V30 8 1 7 8
+M V30 9 1 8 9
+M V30 10 1 7 10
+M V30 END BOND
+M V30 END CTAB
+M END
@@ -57,6 +57,7 @@
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;
+
/**
* TestCase for the reading MDL mol files using one test file.
* A test case for SDF files is available as separate Class.
@@ -942,4 +943,17 @@ public void testAliasAtomNaming() throws Exception {
}
Assert.assertEquals(2, r1Count);
}
+
+ @Test
+ public void testPseudoAtomLabels() throws Exception {
+ InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/pseudoatoms.sdf");
+ MDLV2000Reader reader = new MDLV2000Reader(in);
+ IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
+ molecule = reader.read(molecule);
+ Assert.assertTrue(molecule.getAtom(4) instanceof IPseudoAtom);
+ Assert.assertEquals("Gln", molecule.getAtom(4).getSymbol());
+ IPseudoAtom pa = (IPseudoAtom) molecule.getAtom(4);
+ Assert.assertEquals("Gln", pa.getLabel());
+ }
+
}
@@ -23,6 +23,7 @@
*/
package org.openscience.cdk.io;
+import java.io.InputStream;
import java.io.StringWriter;
import java.util.Properties;
@@ -354,5 +355,21 @@ public void testUnsupportedBondOrder() throws Exception {
mdlWriter.write(benzene);
Assert.assertTrue(writer.toString().indexOf("2 1 4 0 0 0 0") != -1);
}
-
+
+ @Test
+ public void testWritePseudoAtoms() throws Exception {
+ InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/pseudoatoms.sdf");
+ MDLV2000Reader reader = new MDLV2000Reader(in);
+ IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
+ molecule = reader.read(molecule);
+
+ StringWriter writer = new StringWriter();
+ MDLV2000Writer mwriter = new MDLV2000Writer(writer);
+ mwriter.write(molecule);
+
+ String output = writer.toString();
+ Assert.assertTrue(output.indexOf("Gln") != -1);
+ Assert.assertTrue(output.indexOf("Leu") != -1);
+ }
+
}
@@ -27,10 +27,12 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.silent.AtomContainer;
+import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
@@ -90,4 +92,16 @@
}
}
+ @Test
+ public void testPseudoAtomLabels() throws Exception {
+ InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/pseudoatomsv3000.mol");
+ MDLV3000Reader reader = new MDLV3000Reader(in);
+ IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
+ molecule = reader.read(molecule);
+ Assert.assertTrue(molecule.getAtom(9) instanceof IPseudoAtom);
+ Assert.assertEquals("Leu", molecule.getAtom(9).getSymbol());
+ IPseudoAtom pa = (IPseudoAtom) molecule.getAtom(9);
+ Assert.assertEquals("Leu", pa.getLabel());
+ }
+
}
@@ -38,9 +38,9 @@
public class SymbolSetQueryAtomTest extends CDKTestCase
{
- SymbolSetQueryAtom symbolSet = null;
+ private static SymbolSetQueryAtom symbolSet = null;
- @BeforeClass public void setUp() {
+ @BeforeClass static public void setUp() {
symbolSet = new SymbolSetQueryAtom();
symbolSet.addSymbol("C");
symbolSet.addSymbol("Fe");

0 comments on commit edddc48

Please sign in to comment.