diff --git a/src/test/data/mdl/ligand-1a0i.sdf b/src/test/data/mdl/ligand-1a0i.sdf new file mode 100644 index 00000000000..0055e514b95 --- /dev/null +++ b/src/test/data/mdl/ligand-1a0i.sdf @@ -0,0 +1,204 @@ +1A0I_ATP_A_1 + RCSB PDB04121112133D +Coordinates from PDB:1A0I:A:1 Model:1 without hydrogens + 31 33 0 0 0 0 999 V2000 + -1.4630 -18.5150 50.8220 P 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2090 -18.0430 49.4400 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.5300 -17.2750 51.6340 O 0 0 0 0 0 0 0 0 0 0 0 0 + -2.8510 -19.0240 50.8640 O 0 0 0 0 0 0 0 0 0 0 0 0 + 0.2750 -19.5630 52.8510 P 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6560 -20.1450 53.8680 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.5190 -20.4000 52.9670 O 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3050 -19.5070 51.3540 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.9300 -17.4650 53.3890 P 0 0 0 0 0 0 0 0 0 0 0 0 + 2.5380 -17.6780 52.0570 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.6500 -15.9920 53.4350 O 0 0 0 0 0 0 0 0 0 0 0 0 + 0.6260 -18.1970 53.3730 O 0 0 0 0 0 0 0 0 0 0 0 0 + 2.9180 -17.8830 54.5940 O 0 0 0 0 0 0 0 0 0 0 0 0 + 2.6240 -17.4710 55.9330 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1670 -18.7010 56.7120 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.9630 -19.8680 56.4910 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.2670 -18.7570 57.9400 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0300 -18.1290 57.9260 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3200 -20.2340 58.3070 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0620 -20.8690 58.1950 O 0 0 0 0 0 0 0 0 0 0 0 0 + 2.5980 -20.7080 57.6020 C 0 0 0 0 0 0 0 0 0 0 0 0 + 3.6340 -21.5680 58.2300 N 0 0 0 0 0 0 0 0 0 0 0 0 + 3.9520 -22.9070 58.0310 C 0 0 0 0 0 0 0 0 0 0 0 0 + 5.0160 -23.2570 58.8640 N 0 0 0 0 0 0 0 0 0 0 0 0 + 5.2750 -22.1220 59.5800 C 0 0 0 0 0 0 0 0 0 0 0 0 + 6.2540 -22.1790 60.5260 C 0 0 0 0 0 0 0 0 0 0 0 0 + 7.0510 -23.3780 60.8010 N 0 0 0 0 0 0 0 0 0 0 0 0 + 6.4270 -21.0100 61.2320 N 0 0 0 0 0 0 0 0 0 0 0 0 + 5.5890 -19.9570 60.8820 C 0 0 0 0 0 0 0 0 0 0 0 0 + 4.6040 -19.9410 59.9160 N 0 0 0 0 0 0 0 0 0 0 0 0 + 4.4610 -21.1210 59.2230 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 0 0 0 + 1 3 1 0 0 0 0 + 1 4 1 0 0 0 0 + 1 8 1 0 0 0 0 + 5 6 2 0 0 0 0 + 5 7 1 0 0 0 0 + 5 8 1 0 0 0 0 + 5 12 1 0 0 0 0 + 9 10 2 0 0 0 0 + 9 11 1 0 0 0 0 + 9 12 1 0 0 0 0 + 9 13 1 0 0 0 0 + 13 14 1 0 0 0 0 + 14 15 1 0 0 0 0 + 15 16 1 0 0 0 0 + 15 17 1 0 0 0 0 + 16 21 1 0 0 0 0 + 17 18 1 0 0 0 0 + 17 19 1 0 0 0 0 + 19 20 1 0 0 0 0 + 19 21 1 0 0 0 0 + 21 22 1 0 0 0 0 + 22 23 1 0 0 0 0 + 22 31 1 0 0 0 0 + 23 24 2 0 0 0 0 + 24 25 1 0 0 0 0 + 25 26 1 0 0 0 0 + 25 31 2 0 0 0 0 + 26 27 1 0 0 0 0 + 26 28 2 0 0 0 0 + 28 29 1 0 0 0 0 + 29 30 2 0 0 0 0 + 30 31 1 0 0 0 0 +A 1 +PG +A 2 +O1G +A 3 +O2G +A 4 +O3G +A 5 +PB +A 6 +O1B +A 7 +O2B +A 8 +O3B +A 9 +PA +A 10 +O1A +A 11 +O2A +A 12 +O3A +A 13 +O5' +A 14 +C5' +A 15 +C4' +A 16 +O4' +A 17 +C3' +A 18 +O3' +A 19 +C2' +A 20 +O2' +A 21 +C1' +A 22 +N9 +A 23 +C8 +A 24 +N7 +A 25 +C5 +A 26 +C6 +A 27 +N6 +A 28 +N1 +A 29 +C2 +A 30 +N3 +A 31 +C4 +M END +> +1A0I_ATP_A_1 + +> +ATP + +> +1A0I + +> +A + +> +1 + +> + + +> +1 + +> + + +> +0 + +> +C10 N5 O13 P3 + +> +ADENOSINE-5'-TRIPHOSPHATE + +> +[[(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxy-oxolan-2-yl]methoxy-hydroxy-phosphoryl] phosphono hydrogen phosphate + +> + + +> +NON-POLYMER + +> +C10 H16 N5 O13 P3 + +> +507.181 + +> +2008-10-14 + +> + + +> + + +> + + +> +N + +> +InChI=1/C10H16N5O13P3/c11-8-5-9(13-2-12-8)15(3-14-5)10-7(17)6(16)4(26-10)1-25-30(21,22)28-31(23,24)27-29(18,19)20/h2-4,6-7,10,16-17H,1H2,(H,21,22)(H,23,24)(H2,11,12,13)(H2,18,19,20)/t4-,6-,7-,10-/m1/s1/f/h18-19,21,23H,11H2 + +> +ZKHQWZAMYRWXGA-FJYXAIENDD + +> +c1nc(c2c(n1)n(cn2)[C@H]3[C@@H]([C@@H]([C@H](O3)CO[P@@](=O)(O)O[P@](=O)(O)OP(=O)(O)O)O)O)N + +$$$$ diff --git a/src/test/org/openscience/cdk/io/Mol2WriterTest.java b/src/test/org/openscience/cdk/io/Mol2WriterTest.java index 52104cef1ee..34efbea64fe 100644 --- a/src/test/org/openscience/cdk/io/Mol2WriterTest.java +++ b/src/test/org/openscience/cdk/io/Mol2WriterTest.java @@ -24,22 +24,27 @@ */ package org.openscience.cdk.io; -import java.io.IOException; -import java.io.StringWriter; - import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.openscience.cdk.AtomContainerSet; import org.openscience.cdk.ChemFile; import org.openscience.cdk.ChemModel; -import org.openscience.cdk.MoleculeSet; import org.openscience.cdk.DefaultChemObjectBuilder; +import org.openscience.cdk.MoleculeSet; import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.smiles.SmilesParser; +import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.util.List; /** * TestCase for the writer MOL2 writer. @@ -125,4 +130,30 @@ public void testWriterForAmide() throws Exception { } + /** + * This test just ensures that Mol2Writer does not throw an NPE. + * + * It does not test whether the output is correct or not. + * @throws Exception + * @cdk.bug 3315503 + */ + @Test + public void testMissingAtomType() throws Exception { + String filename = "data/mdl/ligand-1a0i.sdf"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + IChemFile fileContents = (IChemFile) reader.read(new ChemFile()); + List molecules = ChemFileManipulator.getAllAtomContainers(fileContents); + IAtomContainer mol = molecules.get(0); + CDKHueckelAromaticityDetector.detectAromaticity(mol); + AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); + + StringWriter writer = new StringWriter(); + Mol2Writer molwriter = new Mol2Writer(writer); + molwriter.write(mol); + molwriter.close(); + + String mol2file = writer.getBuffer().toString(); + Assert.assertTrue(mol2file.indexOf("24 R24 -1.209 -18.043 49.44 X") > 0); + } } \ No newline at end of file