/** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCSubstanceXMLReader(Reader input) throws Exception { setReader(input); }
@Test public void testAccepts() throws Exception { PCSubstanceXMLReader reader = new PCSubstanceXMLReader(); Assert.assertTrue(reader.accepts(AtomContainer.class)); }
@Test public void testReading() throws Exception { String filename = "data/asn/pubchem/sid577309.xml"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PCSubstanceXMLReader reader = new PCSubstanceXMLReader(ins); IAtomContainer molecule = (IAtomContainer) reader.read(new AtomContainer()); Assert.assertNotNull(molecule); // check atom stuff Assert.assertEquals(19, molecule.getAtomCount()); Assert.assertTrue(molecule.getAtom(0) instanceof IPseudoAtom); // check bond stuff Assert.assertEquals(19, molecule.getBondCount()); Assert.assertNotNull(molecule.getBond(3)); } }
@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 ChemFile objects."); } }
@BeforeClass public static void setup() throws Exception { setSimpleChemObjectReader(new PCSubstanceXMLReader(), "data/asn/pubchem/sid577309.xml"); }
@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 ChemFile objects."); } }
/** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCSubstanceXMLReader(Reader input) throws Exception { setReader(input); }
public PCSubstanceXMLReader(InputStream input) throws Exception { setReader(input); }
public PCSubstanceXMLReader(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)); }