0.0
No commit activity in last 3 years
No release in over 3 years
Provides PhyloXML support for BioRuby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1.0
~> 1.8.3
~> 3.12

Runtime

~> 1.4.2
~> 2.3.2
 Project Readme

bio-phyloxml

Build Status

bio-phyloxml is a phyloXML plugin for BioRuby, an open source bioinformatics library for Ruby.

phyloXML is an XML language for saving, analyzing and exchanging data of annotated phylogenetic trees. The phyloXML parser in BioRuby is implemented in Bio::PhyloXML::Parser, and its writer in Bio::PhyloXML::Writer. More information can be found at phyloxml.org.

This phyloXML code has historically been part of the core BioRuby gem, but has been split into its own gem as part of an effort to modularize BioRuby. bio-phyloxml and many more plugins are available at biogems.info.

This code was originally written by Diana Jaunzeikare during the Google Summer of Code 2009 for the Implementing phyloXML support in BioRuby project with NESCent, mentored by Christian Zmasek et al. For details of development, see github.com/latvianlinuxgirl/bioruby and the BioRuby mailing list archives.

NOTE: this is currently in the repackaging process and is not yet released! Production users should use the phyloXML support provided with BioRuby for the time being.

Requirements

bio-phyloxml uses libxml-ruby, which requires several C libraries and their headers to be installed:

  • zlib
  • libiconv
  • libxml

With these installed, the bio and libxml-ruby gems should be installed

gem install -r bio libxml-ruby

For more information see the libxml installer page and the BioRuby installation page.

Installation

gem install bio-phyloxml

Migration

Users who were previously using the phyloXML support in the core BioRuby gem should be able to migrate to using this gem very easily. Simply install the bio-phyloxml gem as described below, and add require 'bio-phyloxml' to the relevant application code.

Usage

require 'bio-phyloxml'

Parsing a file

require 'bio-phyloxml'

# Create new phyloxml parser
phyloxml = Bio::PhyloXML::Parser.open('example.xml')

# Print the names of all trees in the file
phyloxml.each do |tree|
  puts tree.name
end

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

tree = phyloxml[3]

You can use all Bio::Tree methods on the tree, since PhyloXML::Tree inherits from Bio::Tree. For example,

tree.leaves.each do |node|
 puts node.name
end

PhyloXML files can hold additional information besides phylogenies at the end of the file. This info can be accessed through the 'other' array of the parser object.

phyloxml = Bio::PhyloXML::Parser.open('example.xml')
while tree = phyloxml.next_tree
  # do stuff with trees
end 

puts phyloxml.other

Writing a file

# Create new phyloxml writer
writer = Bio::PhyloXML::Writer.new('tree.xml')

# Write tree to the file tree.xml
writer.write(tree1) 

# Add another tree to the file
writer.write(tree2)

Retrieving data

Here is an example of how to retrieve the scientific name of the clades included in each tree.

require 'bio-phyloxml'

phyloxml = Bio::PhyloXML::Parser.open('ncbi_taxonomy_mollusca.xml')
phyloxml.each do |tree|
  tree.each_node do |node|
    print "Scientific name: ", node.taxonomies[0].scientific_name, "\n"
  end
end

Retrieving 'other' data

require 'bio'

phyloxml = Bio::PhyloXML::Parser.open('phyloxml_examples.xml')
while tree = phyloxml.next_tree
 #do something with the trees
end

p phyloxml.other
puts "\n"
#=> output is an object representation

#Print in a readable way
puts phyloxml.other[0].to_xml, "\n"
#=>:
#
#<align:alignment xmlns:align="http://example.org/align">
#  <seq name="A">acgtcgcggcccgtggaagtcctctcct</seq>
#  <seq name="B">aggtcgcggcctgtggaagtcctctcct</seq>
#  <seq name="C">taaatcgc--cccgtgg-agtccc-cct</seq>
#</align:alignment>

#Once we know whats there, lets output just sequences
phyloxml.other[0].children.each do |node|
 puts node.value
end
#=>
#
#acgtcgcggcccgtggaagtcctctcct
#aggtcgcggcctgtggaagtcctctcct
#taaatcgc--cccgtgg-agtccc-cct

The API doc is online. (TODO: generate and link) For more code examples see the test files in the source tree.

Project home page

Information on the source tree, documentation, examples, issues and how to contribute, see

http://github.com/csw/bioruby-phyloxml

The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.

Cite

If you use this software, please cite one of

Biogems.info

This Biogem is published at #bio-phyloxml

Copyright

Copyright (c) 2009 Diana Jaunzeikare. See LICENSE.txt for further details.