@BeforeClass public static void setup() throws Exception { setSimpleChemObjectReader(new PCCompoundXMLReader(), "data/asn/pubchem/cid1145.xml"); }
@Test public void testAccepts() throws Exception { PCCompoundXMLReader reader = new PCCompoundXMLReader(); Assert.assertTrue(reader.accepts(AtomContainer.class)); }
@Test public void testReading3DCoords() throws Exception { String filename = "data/asn/pubchem/cid176.xml"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PCCompoundXMLReader reader = new PCCompoundXMLReader(ins); IAtomContainer molecule = (IAtomContainer) reader.read(new AtomContainer()); reader.close(); Assert.assertNotNull(molecule); // check atom stuff Assert.assertEquals(8, molecule.getAtomCount()); Assert.assertNull(molecule.getAtom(0).getPoint2d()); Point3d point = molecule.getAtom(0).getPoint3d(); Assert.assertNotNull(point); Assert.assertEquals(-0.9598, point.x, 0.0001); Assert.assertEquals(1.5616, point.y, 0.0001); Assert.assertEquals(1.8714, point.z, 0.0001); } }
@Test public void testReading() throws Exception { String filename = "data/asn/pubchem/cid1145.xml"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PCCompoundXMLReader reader = new PCCompoundXMLReader(ins); IAtomContainer molecule = (IAtomContainer) reader.read(new AtomContainer()); reader.close(); Assert.assertNotNull(molecule); // check atom stuff Assert.assertEquals(14, molecule.getAtomCount()); Assert.assertEquals("O", molecule.getAtom(0).getSymbol()); Assert.assertEquals(Integer.valueOf(-1), molecule.getAtom(0).getFormalCharge()); Assert.assertEquals("N", molecule.getAtom(1).getSymbol()); Assert.assertEquals(Integer.valueOf(1), molecule.getAtom(1).getFormalCharge()); // check bond stuff Assert.assertEquals(13, molecule.getBondCount()); Assert.assertNotNull(molecule.getBond(3)); // coordinates Assert.assertNull(molecule.getAtom(0).getPoint3d()); Point2d point = molecule.getAtom(0).getPoint2d(); Assert.assertNotNull(point); Assert.assertEquals(3.7320508956909, point.x, 0.00000001); Assert.assertEquals(0.5, point.y, 0.00000001); }