Example #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);
  }
Example #2
0
 //	public static URI getTypeBySubpartType(subpart_type type)
 //	{
 //		switch(type)
 //		{
 //			case Terminator:return SequenceOntology.TERMINATOR;
 //			case Primers:return SequenceOntology.PRIMER_BINDING_SITE;
 //		}
 //		return SequenceOntology.CDS;
 //	}
 public xmlToSbol(String xml, String sbol) throws IOException {
   SBOLDocument document = createDocument(xml);
   System.out.println(
       "Created a new SBOL document with " + document.getContents().size() + " element(s)");
   FileOutputStream fileoutStream = new FileOutputStream(sbol);
   SBOLFactory.write(document, fileoutStream);
   fileoutStream.close();
 }