SimpleIOHandler extends BioPAXIOHandlerAdapter { public void convertToOWL(Model model, OutputStream outputStream) { initializeExporter(model); try { Writer out = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); writeObjects(out, model); out.close(); } catch (IOException e) { throw new BioPaxIOException("Cannot convert to OWL!", e); } } SimpleIOHandler();  SimpleIOHandler(BioPAXLevel level);  SimpleIOHandler(BioPAXFactory factory, BioPAXLevel level); void mergeDuplicates(boolean mergeDuplicates); void checkRestrictions(boolean checkRestrictions); String getXmlStreamInfo(); String getId(); void convertToOWL(Model model, OutputStream outputStream); void writeObject(Writer out, BioPAXElement bean); void absoluteUris(boolean absoluteUris); boolean isAbsoluteUris(); void normalizeNameSpaces(boolean normalizeNameSpaces); boolean isNormalizeNameSpaces(); boolean isMergeDuplicates(); static String convertToOwl(Model model);  }
@Test public final void testReadWriteL2() throws IOException { BioPAXIOHandler io = new SimpleIOHandler(); io.fixReusedPEPs(false); Model model = getL2Model(io); assertNotNull(model); assertFalse(model.getObjects().isEmpty()); System.out.println("Model has " + model.getObjects().size() + " objects)"); FileOutputStream out = new FileOutputStream( getClass().getResource("").getFile() + File.separator + "simpleReadWrite.owl" ); io.convertToOWL(model, out); }
@Test public final void testReadWriteL3() throws IOException { BioPAXIOHandler io = new SimpleIOHandler(); Model model = getL3Model(io); assertNotNull(model); assertFalse(model.getObjects().isEmpty()); System.out.println("Model has " + model.getObjects().size() + " objects)"); FileOutputStream out = new FileOutputStream(getClass().getResource("") .getFile() + File.separator + "simpleReadWrite.owl"); io.convertToOWL(model, out); }
@Test public final void testIoNoBpNamespacePrefix() throws IOException { BioPAXIOHandler io = new SimpleIOHandler(); String s = "L3" + File.separator + "biopax3-short-metabolic-pathway2.owl"; InputStream in = SimpleIOHandlerTest.class.getClassLoader().getResourceAsStream(s); Model model = io.convertFromOWL(in); assertNotNull(model); assertFalse(model.getObjects().isEmpty()); System.out.println("Model2 has " + model.getObjects().size() + " objects)"); FileOutputStream out = new FileOutputStream(getClass().getResource("") .getFile() + File.separator + "simpleReadWrite2.owl"); model.setXmlBase(null); io.convertToOWL(model, out); }
@Test public final void testXMLEscapes() throws IOException { BioPAXIOHandler io = new SimpleIOHandler(); MockFactory mock = new MockFactory(BioPAXLevel.L3); final Model model = mock.createModel(); Protein[] pr = mock.create(model, Protein.class, 1); String s = "\" \' < > & % : + && #"; System.out.println(s); pr[0].getName().clear(); pr[0].addName(s); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); io.convertToOWL(model, outputStream); outputStream.flush(); ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); outputStream.close(); Model newModel = io.convertFromOWL(inputStream); Protein prot = (Protein) newModel.getObjects().iterator().next(); assertTrue(prot.getName().iterator().next().equals(s)); }