Package Bio :: Package Nexus :: Module Trees :: Class Tree
[show private | hide private]
[frames | no frames]

Class Tree

Chain --+
        |
       Tree


Represents a tree using a chain of nodes with on predecessor (=ancestor) and multiple successors (=subclades).
Method Summary
  __init__(self, tree, weight, rooted, name, data, values_are_support, max_support)
Ntree(self,tree).
  __str__(self)
Short version of to_string(), gives plain tree
  branchlength2support(self)
Move values stored in data.branchlength to data.support, and set branchlength to 0.0
  common_ancestor(self, node1, node2)
Return the common ancestor that connects to nodes.
  convert_absolute_support(self, nrep)
Convert absolute support (clade-count) to rel.
  display(self)
Quick and dirty lists of all nodes.
  distance(self, node1, node2)
Add and return the sum of the branchlengths between two nodes.
  get_taxa(self, node_id)
Return a list of all otus downwards from a node (self, node_id).
  get_terminals(self)
Return a list of all terminal nodes.
  is_bifurcating(self, node)
Return True if tree downstream of node is strictly bifurcating.
  is_compatible(self, tree2, threshold, strict)
Compares branches with support>threshold for compatibility.
  is_identical(self, tree2)
Compare tree and tree2 for identity.
  is_monophyletic(self, taxon_list)
Return node_id of common ancestor if taxon_list is monophyletic, -1 otherwise.
  node(self, node_id)
Return the instance of node_id.
  prune(self, taxon)
Prunes a terminal taxon from the tree.
  randomize(self, ntax, taxon_list, branchlength, branchlength_sd, bifurcate)
Generates a random tree with ntax taxa and/or taxa from taxlabels.
  root_with_outgroup(self, outgroup)
  search_taxon(self, taxon)
Returns the first matching taxon in self.data.taxon.
  set_subtree(self, node)
Return subtree as a set of nested sets.
  split(self, parent_id, n, branchlength)
Speciation: generates n (default two) descendants of a node.
  sum_branchlength(self, root, node)
Adds up the branchlengths from root (default self.root) to node.
  to_string(self, support_as_branchlengths, branchlengths_only, plain, plain_newick)
Return a paup compatible tree line.
  unroot(self)
Defines a unrooted Tree structure, using data of a rooted Tree.
    Inherited from Chain
  add(self, node, prev)
Attaches node to another: (self, node, prev).
  all_ids(self)
Return a list of all node ids.
  collapse(self, id)
Deletes node from chain and relinks successors to predecessor: collapse(self, id).
  is_parent_of(self, parent, grandchild)
Check if grandchild is a subnode of parent: is_parent_of(self,parent,grandchild).
  kill(self, id)
Kills a node from chain without caring to what it is connected: kill(self,id).
  link(self, parent, child)
Connects son to parent: link(self,son,parent).
  trace(self, start, finish)
Returns a list of all node_ids between two nodes (excluding start, including end): trace(start,end).
  unlink(self, id)
Disconnects node from his predecessor: unlink(self,id).

Method Details

__init__(self, tree=None, weight=1.0, rooted=False, name='', data=<class Bio.Nexus.Trees.NodeData at 0x30537960>, values_are_support=False, max_support=1.0)
(Constructor)

Ntree(self,tree).
Overrides:
Bio.Nexus.Nodes.Chain.__init__

__str__(self)
(Informal representation operator)

Short version of to_string(), gives plain tree

branchlength2support(self)

Move values stored in data.branchlength to data.support, and set branchlength to 0.0

This is necessary when support has been stored as branchlength (e.g. paup), and has thus been read in as branchlength.

common_ancestor(self, node1, node2)

Return the common ancestor that connects to nodes.

node_id = common_ancestor(self,node1,node2)

convert_absolute_support(self, nrep)

Convert absolute support (clade-count) to rel. frequencies.

Some software (e.g. PHYLIP consense) just calculate how often clades appear, instead of calculating relative frequencies.

display(self)

Quick and dirty lists of all nodes.

distance(self, node1, node2)

Add and return the sum of the branchlengths between two nodes. dist = distance(self,node1,node2)

get_taxa(self, node_id=None)

Return a list of all otus downwards from a node (self, node_id).

nodes = get_taxa(self,node_id=None)

get_terminals(self)

Return a list of all terminal nodes.

is_bifurcating(self, node=None)

Return True if tree downstream of node is strictly bifurcating.

is_compatible(self, tree2, threshold, strict=True)

Compares branches with support>threshold for compatibility.

result = is_compatible(self,tree2,threshold)

is_identical(self, tree2)

Compare tree and tree2 for identity.

result = is_identical(self,tree2)

is_monophyletic(self, taxon_list)

Return node_id of common ancestor if taxon_list is monophyletic, -1 otherwise.

result = is_monophyletic(self,taxon_list)

node(self, node_id)

Return the instance of node_id.

node = node(self,node_id)

prune(self, taxon)

Prunes a terminal taxon from the tree.

id_of_previous_node = prune(self,taxon) If taxon is from a bifurcation, the connectiong node will be collapsed and its branchlength added to remaining terminal node. This might be no longer a meaningful value'

randomize(self, ntax=None, taxon_list=None, branchlength=1.0, branchlength_sd=None, bifurcate=True)

Generates a random tree with ntax taxa and/or taxa from taxlabels.

new_tree = randomize(self,ntax=None,taxon_list=None,branchlength=1.0,branchlength_sd=None,bifurcate=True) Trees are bifurcating by default. (Polytomies not yet supported).

search_taxon(self, taxon)

Returns the first matching taxon in self.data.taxon. Not restricted to terminal nodes.

node_id = search_taxon(self,taxon)

set_subtree(self, node)

Return subtree as a set of nested sets.

sets = set_subtree(self,node)

split(self, parent_id=None, n=2, branchlength=1.0)

Speciation: generates n (default two) descendants of a node.

[new ids] = split(self,parent_id=None,n=2,branchlength=1.0):

sum_branchlength(self, root=None, node=None)

Adds up the branchlengths from root (default self.root) to node.

sum = sum_branchlength(self,root=None,node=None)

to_string(self, support_as_branchlengths=False, branchlengths_only=False, plain=True, plain_newick=False)

Return a paup compatible tree line.

to_string(self,support_as_branchlengths=False,branchlengths_only=False,plain=True)

unroot(self)

Defines a unrooted Tree structure, using data of a rooted Tree.

Generated by Epydoc 2.1 on Mon Aug 27 16:43:41 2007 http://epydoc.sf.net