BioRuby PhyloXML HowTo documentation

From Phyloinformatics
Revision as of 20:49, 11 August 2009 by Dianaj (talk) (How to parse a file)
Jump to: navigation, search


PhyloXML is a tree format for saving and exchanging data of annotated phylogenetic trees. PhyloXML parsers and writers are implemented in BioRuby, BioPython and BioPerl. More information at


In addition to BioRuby library you need a libxml ruby bindings. To install:

gem install -r libxml-ruby

How to parse a file

require 'bio'
# Create new phyloxml parser
phyloxml ='example.xml')
# Print the names of all trees in the file
phyloxml.each do |tree|

If there are several trees in the file, you can access the one you wish by an index

tree = phyloxml[3]

You can use all Bio::Tree methods on the tree. For example,

tree.leaves.each do |node|