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
 /**
  * Add subpart to a SequenceAnnotation
  *
  * @param sub Subpart to create SequenceAnnotation
  * @param place
  * @return
  */
 private SequenceAnnotation createAnnotation(Subpart sub, int place) {
   SequenceAnnotation annotation2 = SBOLFactory.createSequenceAnnotation();
   annotation2.setURI(
       URI.create("http://sbols.org/anot/an_" + this.partId + "_" + sub.id + "_" + place));
   DnaComponent dnaComponent2 = SBOLFactory.createDnaComponent();
   dnaComponent2.setURI(URI.create("http://partsregistry.org/Part/" + sub.getPart_name()));
   dnaComponent2.setDescription(sub.description);
   dnaComponent2.setDisplayId(sub.getPart_name());
   dnaComponent2.setName(sub.nickName);
   dnaComponent2.addType(SequenceOntology.type(sub.getType().toString()));
   annotation2.setSubComponent(dnaComponent2);
   return annotation2;
 }
Exemplo n.º 3
0
 private SequenceAnnotation createAnnotation(feature sub, int place) {
   SequenceAnnotation annotation2 = SBOLFactory.createSequenceAnnotation();
   annotation2.setBioStart(sub.startpos);
   annotation2.setBioEnd(sub.endpos);
   if (sub.direction.equals("forward")) annotation2.setStrand(StrandType.POSITIVE);
   else annotation2.setStrand(StrandType.NEGATIVE);
   annotation2.setURI(URI.create("http://sbols.org/anot/f_" + sub.id));
   DnaComponent dnaComponent2 = SBOLFactory.createDnaComponent();
   dnaComponent2.setURI(URI.create("http://partsregistry.org/feat/f_" + sub.id));
   dnaComponent2.setDisplayId("f_" + sub.id);
   dnaComponent2.setName(sub.type);
   dnaComponent2.addType(SequenceOntology.type(sub.type));
   annotation2.setSubComponent(dnaComponent2);
   return annotation2;
 }
Exemplo n.º 4
0
  private SBOLRootObject createDnaComponent(String xml, SBOLDocument document) {
    SAXBuilder builder = new SAXBuilder();
    DnaComponent dnaComponent = SBOLFactory.createDnaComponent();
    try {
      Document doc = builder.build(new File(xml));
      Element rootEl = doc.getRootElement();

      Element list = rootEl.getChild("part_list").getChild("part");
      partId = Integer.parseInt(list.getChildText("part_id"));
      dnaComponent.setURI(URI.create(list.getChildText("part_url")));
      dnaComponent.setDisplayId(list.getChildText("part_name"));
      dnaComponent.setName(list.getChildText("part_short_name"));
      dnaComponent.setDescription(list.getChildText("part_short_desc"));
      Element seq = rootEl.getChild("part_list").getChild("part").getChild("sequences");

      dnaComponent.setDnaSequence(this.createDnaSequence(seq.getChildText("seq_data")));
      List<SequenceAnnotation> seqs = createAllDnaSubComponent(xml);
      System.out.println(seqs.size());
      for (int i = 0; i < seqs.size(); i++) dnaComponent.addAnnotation(seqs.get(i));

    } catch (JDOMException e) {
      //            e.printStackTrace();

    } catch (IOException e) {
      //            e.printStackTrace();
    }
    return dnaComponent;
  }
Exemplo n.º 5
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();
 }
Exemplo n.º 6
0
 public DnaSequence createDnaSequence(String seq) {
   DnaSequence dnaSequence = SBOLFactory.createDnaSequence();
   dnaSequence.setURI(URI.create("http://partsregistry.org/seq/partseq_" + this.partId));
   dnaSequence.setNucleotides(strToSeq(seq));
   return dnaSequence;
 }
Exemplo n.º 7
0
 /** Creates a document with a single DnaComponent. */
 public SBOLDocument createDocument(String xml) {
   SBOLDocument document = SBOLFactory.createDocument();
   document.addContent(createDnaComponent(xml, document));
   return document;
 }