ivy.treebase module

Functions to get trees and character data from treebase

ivy.treebase.fetch_study(study_id, format=u'nexml')[source]

Get a study from treebase in one of various formats

Parameters:
  • study_id (str) – The id of the study
  • format (str) – One of [“rdf”, “html”, “nexml”, “nexus”]
Returns:

Str representing a nexus file (if format = “nexus”)

OR

An lxml etree object

ivy.treebase.parse_chars(e, otus)[source]
ivy.treebase.parse_charsets(study_id)[source]
ivy.treebase.parse_nexml(doc)[source]

Parse an etree ElementTree

Parameters:doc – An etree ElementTree or a file that can be parsed into an etree ElementTree with etree.parse
Returns:
An ivy Storage object containing all the information from the
nexml file: Characters, metadata, OTUs, and trees.
ivy.treebase.parse_otus(e)[source]

Get OTUs from an etree object

Parameters:e – A nexml document parsed by etree
Returns:A dict mapping keys to OTUs contained in ivy Storage objects
Return type:dict
ivy.treebase.parse_states(e)[source]

e is a characters element

ivy.treebase.parse_trees(e, otus)[source]

Get trees from an etree object

Parameters:
  • e – A nexml document parsed by etree
  • otus – OTUs returned by parse_otus
Returns:

A list of ivy Storage objects each

containing every node of a tree.

Return type:

list