Skip to content
Niema Moshiri edited this page May 18, 2018 · 7 revisions

TreeSwift is a Python package for efficiently traversing and manipulating ultra-large phylogenetic trees. It has been tested on Python 2.6-2.7 and 3.3-3.7, but it should theoretically work on all versions.

Installation

TreeSwift can be installed using pip:

sudo pip install treeswift

If you are using a machine on which you lack administrative powers, TreeSwift can be installed locally using pip:

pip install --user treeswift

Usage

Typical usage should be as follows:

  1. Import the treeswift package
  2. Use treeswift.read_tree_newick to load your Newick tree
  3. Use the various Tree class functions on the resulting object as you need
import treeswift
tree = treeswift.read_tree_newick(my_newick_string)
for node in tree.traverse_postorder():
    print(node)

For more examples, take a look at the Cookbook

Clone this wiki locally