MoSSOutputReader extends DefaultChemObjectReader { @Override public <T extends IChemObject> T read(T object) throws CDKException { if (object instanceof IAtomContainerSet) { IAtomContainerSet cf = (IAtomContainerSet) object; try { cf = readAtomContainerSet(cf); } catch (IOException e) { logger.error("Input/Output error while reading from input."); } return (T) cf; } else if (object instanceof IChemFile) { IChemFile chemFile = (IChemFile) object; IChemSequence chemSeq = object.getBuilder().newInstance(IChemSequence.class); IChemModel chemModel = object.getBuilder().newInstance(IChemModel.class); IAtomContainerSet molSet = object.getBuilder().newInstance(IAtomContainerSet.class); try { molSet = readAtomContainerSet(molSet); } catch (IOException e) { logger.error("Input/Output error while reading from input."); } chemModel.setMoleculeSet(molSet); chemSeq.addChemModel(chemModel); chemFile.addChemSequence(chemSeq); return (T) chemFile; } else { throw new CDKException("Only supported is reading of IAtomContainerSet."); } } MoSSOutputReader(Reader input);  MoSSOutputReader(InputStream input);  MoSSOutputReader(); @Override IResourceFormat getFormat(); @Override void setReader(Reader reader); @Override void setReader(InputStream input); @Override boolean accepts(Class<? extends IChemObject> testClass); @Override T read(T object); @Override void close();  }
@Test public void testExampleFile_MolReading() throws Exception { String filename = "data/moss/TKO.mossoutput"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MoSSOutputReader reader = new MoSSOutputReader(ins); IAtomContainerSet moleculeSet = new AtomContainerSet(); moleculeSet = reader.read(moleculeSet); Assert.assertEquals(19, moleculeSet.getAtomContainerCount()); for (IAtomContainer mol : moleculeSet.atomContainers()) { Assert.assertEquals(Integer.valueOf(mol.getProperty("atomCount").toString()).intValue(), mol.getAtomCount()); Assert.assertEquals(Integer.valueOf(mol.getProperty("bondCount").toString()).intValue(), mol.getBondCount()); } }
@Test public void testExampleFile_SupportColumns() throws Exception { String filename = "data/moss/TKO.mossoutput"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MoSSOutputReader reader = new MoSSOutputReader(ins); IAtomContainerSet moleculeSet = new AtomContainerSet(); moleculeSet = reader.read(moleculeSet); Assert.assertEquals(5.06, Double .valueOf(moleculeSet.getAtomContainer(0).getProperty("focusSupport").toString()).doubleValue(), 0.01); Assert.assertEquals(1.74, Double.valueOf(moleculeSet.getAtomContainer(0).getProperty("complementSupport").toString()) .doubleValue(), 0.01); }