Exemplo n.º 1
0
  public static void main(String[] args) throws Exception {
    System.out.format("Create a very simple SBOL document%n%n");
    // create a DnaComponent and set some of its properties
    DnaComponent dnaComponent = SBOLFactory.createDnaComponent();
    dnaComponent.setURI(URI.create("http://example.com/MyDnaComponent"));
    dnaComponent.setDisplayId("MyDnaComponent");
    dnaComponent.setName("myDNA");
    dnaComponent.setDescription("This is a very simple example");

    // create an empty document populated with some SBOL objects
    SBOLDocument document = SBOLFactory.createDocument();
    // add the DnaComponent to this document
    document.addContent(dnaComponent);

    // write the contents of the document as an XML file to stdout
    System.out.format("Serialize the SBOL document in the official XML format:%n");
    SBOLFactory.write(document, System.out);

    // now serialize the contents into a buffer so we can read it back
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    SBOLFactory.write(document, buffer);
    // create a new document using the byte buffer as our input
    SBOLDocument newDocument = SBOLFactory.read(new ByteArrayInputStream(buffer.toByteArray()));

    // write the contents of the new document in amore human-readable format
    System.out.format("%nSerialize the SBOL document in a more readable presentation format:%n");
    new SBOLPrettyWriter().write(newDocument, System.out);
  }
Exemplo n.º 2
0
 /** Creates a document with a single DnaComponent. */
 public SBOLDocument createDocument(String xml) {
   SBOLDocument document = SBOLFactory.createDocument();
   document.addContent(createDnaComponent(xml, document));
   return document;
 }