biopython v1.71.0 Bio.Nexus.Trees.Tree
Represent a tree using a chain of nodes with on predecessor (=ancestor) and multiple successors (=subclades).
Link to this section Summary
Functions
Ntree(self,tree)
Short version of to_string(), gives plain tree
Add data to the node parsed from the comments, taxon and support
Add leaf or tree (in newick format) to a parent_id
Hook subtree starting with node child to parent
Extract values (support/branchlength) from xx[:yyy], xx
Parse (a,b,c…)[[[xx]:]yy] into subcomponents and travels down recursively
Return all node_ids downwards from a node
Move values stored in data.branchlength to data.support, and set branchlength to 0.0
Collapse all subtrees which belong to the same genus
Return the common ancestor that connects two nodes
Convert absolute support (clade-count) to rel. frequencies
Count the number of terminal nodes that are attached to a node
Quick and dirty lists of all nodes
Add and return the sum of the branchlengths between two nodes
Return a list of all otus downwards from a node
Return a list of all terminal nodes
Return True if any of the nodes has data.support != None
Return True if tree downstream of node is strictly bifurcating
Compare branches with support>threshold for compatibility
Compare tree and tree2 for identity
Return True if node is an internal node
Return node_id of common ancestor if taxon_list is monophyletic, -1 otherwise
Return True if all successors of a node are terminal ones
Return True if node is a terminal node
Sort node numbers according to the number of terminal nodes
Create nicely formatted support/branchlengths
Merge clade support (from consensus or list of bootstrap-trees) with phylogeny
Convert a node tree to a newick tree recursively
Return the instance of node_id
Prune a terminal taxon from the tree
Generate a random tree with ntax taxa and/or taxa from taxlabels
Return the first matching taxon in self.data.taxon. Not restricted to terminal nodes
Return subtree as a set of nested sets
Speciation: generates n (default two) descendants of a node
Add up the branchlengths from root (default self.root) to node
Return a paup compatible tree line
Define a unrooted Tree structure, using data of a rooted Tree
Link to this section Functions
Ntree(self,tree).
Short version of to_string(), gives plain tree.
Add data to the node parsed from the comments, taxon and support.
Add leaf or tree (in newick format) to a parent_id.
Hook subtree starting with node child to parent.
Extract values (support/branchlength) from xx[:yyy], xx.
Parse (a,b,c…)[[[xx]:]yy] into subcomponents and travels down recursively.
Return all node_ids downwards from a node.
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.
Collapse all subtrees which belong to the same genus.
(i.e share the same first word in their taxon name.)
Return the common ancestor that connects two nodes.
node_id = common_ancestor(self,node1,node2)
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.
Count the number of terminal nodes that are attached to a node.
Quick and dirty lists of all nodes.
Add and return the sum of the branchlengths between two nodes.
dist = distance(self,node1,node2)
Return a list of all otus downwards from a node.
nodes = get_taxa(self,node_id=None)
Return a list of all terminal nodes.
Return True if any of the nodes has data.support != None.
Return True if tree downstream of node is strictly bifurcating.
Compare branches with support>threshold for compatibility.
result = is_compatible(self,tree2,threshold)
Compare tree and tree2 for identity.
result = is_identical(self,tree2)
Return True if node is an internal node.
Return node_id of common ancestor if taxon_list is monophyletic, -1 otherwise.
result = is_monophyletic(self,taxon_list)
Return True if all successors of a node are terminal ones.
Return True if node is a terminal node.
Sort node numbers according to the number of terminal nodes.
Create nicely formatted support/branchlengths.
Merge clade support (from consensus or list of bootstrap-trees) with phylogeny.
tree=merge_bootstrap(phylo,bs_tree=
Convert a node tree to a newick tree recursively.
Return the instance of node_id.
node = node(self,node_id)
Prune 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’
Generate 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).
Return the first matching taxon in self.data.taxon. Not restricted to terminal nodes.
node_id = search_taxon(self,taxon)
Return subtree as a set of nested sets.
sets = set_subtree(self,node)
Speciation: generates n (default two) descendants of a node.
[new ids] = split(self,parent_id=None,n=2,branchlength=1.0):
Add up the branchlengths from root (default self.root) to node.
sum = sum_branchlength(self,root=None,node=None)
Return a paup compatible tree line.
Define a unrooted Tree structure, using data of a rooted Tree.