Difference between revisions of "NeXML and RDF API for BioRuby"

From Phyloinformatics
Jump to: navigation, search
(Reader)
Line 2: Line 2:
 
The following document discusses the implementation of an NeXML parser and serializer and an RDF API for BioRuby. Note that this document is not final yet.
 
The following document discusses the implementation of an NeXML parser and serializer and an RDF API for BioRuby. Note that this document is not final yet.
  
==Reader==
+
==Parsing==
Define a Bio::NeXML::Reader class to provide an API for parsing NeXML.
+
The parsed document is abstracted with <code>Bio::NeXML::Parser</code> class. A file, i/o object, URL or string is parsed transparently while instantiating <code>Bio::NeXML::Parser</code> or with the shortcut, <code>Bio::NeXML.parse</code> method.
 +
 
 +
<code>
 +
nexml = Bio::NeXML.parse( "trees.xml" )
 +
</code>
 +
 
 +
<code>otus</code> can be iterated over by calling the <code>each_otus</code> iterator on <code>nexml</code>.
 +
 
 +
<code>
 +
nexml.each_otus{ |otus| puts otus.id }
 +
</code>
 +
 
 +
===OTUS and OTU===
 +
An <code>otus</code> is modeled by <code>Bio::NeXML::Otus</code> and an <code>otu</code> by <code>Bio::NeXML::Otu</code>. With an <code>otus</code> object all the <code>otu</code> nested in it can be iterated over, with the <code>each_otu</code> iterator.
 +
 
 +
<code>
 +
otus.each_otu{ |otu| puts otu.id }
 +
</code>
 +
 
 +
Bio::NeXML::Otu, inherits from Bio::Taxonomy.
  
 
[[Category:NeXML and RDF API for BioRuby]]
 
[[Category:NeXML and RDF API for BioRuby]]

Revision as of 22:43, 27 May 2010

Preface

The following document discusses the implementation of an NeXML parser and serializer and an RDF API for BioRuby. Note that this document is not final yet.

Parsing

The parsed document is abstracted with Bio::NeXML::Parser class. A file, i/o object, URL or string is parsed transparently while instantiating Bio::NeXML::Parser or with the shortcut, Bio::NeXML.parse method.

nexml = Bio::NeXML.parse( "trees.xml" )

otus can be iterated over by calling the each_otus iterator on nexml.

nexml.each_otus{ |otus| puts otus.id }

OTUS and OTU

An otus is modeled by Bio::NeXML::Otus and an otu by Bio::NeXML::Otu. With an otus object all the otu nested in it can be iterated over, with the each_otu iterator.

otus.each_otu{ |otu| puts otu.id }

Bio::NeXML::Otu, inherits from Bio::Taxonomy.