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

From Phyloinformatics
Jump to: navigation, search
(update)
 
(42 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Preface==
+
<strong>Note:</strong> This page has moved to: https://github.com/rvosa/bio-nexml/wiki/NeXML-API-for-BioRuby
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==
 
Parse an NeXML file.
 
 
 
  doc = Bio::NeXML::Parser.new( "trees.xml" )
 
  nexml = doc.parse
 
  nexml.class #Bio::NeXML::Nexml
 
 
 
Read taxa blocks by calling <code>otus</code> method on an <code>nexml</code> object. This returns an array of <code>otus</code> objects.
 
 
 
  nexml.otus.each do |taxa|
 
    puts taxa.id
 
    puts taxa.label
 
  end
 
 
 
An array of <code>otu</code> objects can be obtained by calling <code>otu</code> method on an <code>otus</code> object.
 
 
 
  taxa1 = nexml.otus.first
 
  taxa1.class #Bio::NeXML::Otus
 
  taxa1.otu.each do |taxon|
 
    puts taxon.id
 
    puts taxon.label
 
  end
 
 
 
Trees are accessible by calling <code>trees</code> method on an <code>nexml</code> object, which returns an array of <code>trees</code> objects.
 
 
 
  nexml.trees.each do |trees|
 
    puts trees.id
 
  end
 
 
 
The taxa block to which a <code>trees</code> object is linked to can be obtained.
 
 
 
  trees1 = nexml.trees.first
 
  trees1.class #Bio::NeXML::Trees
 
  trees1.otus
 
 
 
All the <code>tree</code> objects under a <code>trees</code> element are obtainable.
 
 
 
  trees1.tree.each do |tree|
 
    puts tree.id
 
  end
 
 
 
All the available instance methods from <code>[http://bioruby.org/rdoc/classes/Bio/Tree.html#M001688 Bio::Tree]</code> class can be called on a <code>tree</code> object.
 
  tree1 = trees1.tree.first
 
  tree1.class #Bio::NeXML::IntTree or Bio::NeXML::FloatTree
 
  node1 = tree.get_node_by_name "n3" #note name is same as id
 
  tree1.parents node1
 
  
 
[[Category:NeXML and RDF API for BioRuby]]
 
[[Category:NeXML and RDF API for BioRuby]]

Latest revision as of 19:06, 22 September 2011

Note: This page has moved to: https://github.com/rvosa/bio-nexml/wiki/NeXML-API-for-BioRuby