/** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCCompoundXMLReader(Reader input) throws Exception { setReader(input); }
@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 testAccepts() throws Exception { PCCompoundXMLReader reader = new PCCompoundXMLReader(); Assert.assertTrue(reader.accepts(AtomContainer.class)); }
@Override public <T extends IChemObject> T read(T object) throws CDKException { if (object instanceof IAtomContainer) { try { parserHelper = new PubChemXMLHelper(object.getBuilder()); builder = object.getBuilder(); return (T) readMolecule(); } catch (IOException e) { throw new CDKException("An IO Exception occurred while reading the file.", e); } catch (CDKException e) { throw e; } catch (Exception e) { throw new CDKException("An error occurred: " + e.getMessage(), e); } } else { throw new CDKException("Only supported is reading of IAtomContainer objects."); } }
@BeforeClass public static void setup() throws Exception { setSimpleChemObjectReader(new PCCompoundXMLReader(), "data/asn/pubchem/cid1145.xml"); }
@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); }
@Override public <T extends IChemObject> T read(T object) throws CDKException { if (object instanceof IAtomContainer) { try { parserHelper = new PubChemXMLHelper(object.getBuilder()); builder = object.getBuilder(); return (T) readMolecule(); } catch (IOException e) { throw new CDKException("An IO Exception occurred while reading the file.", e); } catch (CDKException e) { throw e; } catch (Exception e) { throw new CDKException("An error occurred: " + e.getMessage(), e); } } else { throw new CDKException("Only supported is reading of IAtomContainer objects."); } }
/** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCCompoundXMLReader(Reader input) throws Exception { setReader(input); }
public PCCompoundXMLReader(InputStream input) throws Exception { setReader(input); }
public PCCompoundXMLReader(InputStream input) throws Exception { setReader(input); }
@Override public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); }
@Override public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); }