| |
- __builtin__.object
-
- BranchData
- Tree
- TreeNode
class BranchData(__builtin__.object) |
|
A class for managing branch specific data for a Tree
By default, this class implements bootstrap data for TreeNode's.
To incorporate new kinds of branch data, do the following. Subclass this
class (say, MyBranchData). Create Tree's with
Tree(branch_data=MyBranchData()). This will ensure your new branch data
manager is used for manipulations to the tree. Any tree's copied from the
tree (via tree.copy()) will also use the same branch manager. |
|
Methods defined here:
- __init__(self)
- get_branch_data(self, node)
- Returns branch specific data from a node
- merge_branch_data(self, data1, data2)
- Merges the branch data from two neighboring branches into one
- set_branch_data(self, node, data)
- Set the branch specific data from 'data' to node.data
- split_branch_data(self, node)
- Split a branch's data into two copies
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'BranchData' objects>
- list of weak references to the object (if defined)
|
class Tree |
|
Basic rooted tree
Well suited for phylogenetic trees |
|
Methods defined here:
- __init__(self, nextname=1, branch_data=<summon.treelib.BranchData object>)
- __iter__(self)
- Iterate through nodes of tree
- add(self, node)
- Add a node to the tree
Does not add node to any specific location (use add_child instead).
- addTree = add_tree(self, parent, childTree)
- add_child(self, parent, child)
- Add a child node to an existing node 'parent' in the tree
- add_tree(self, parent, childTree)
- Add a subtree to the tree.
- clear(self)
- Clear all nodes from tree
- clear_data(self, *keys)
- Clear tree data
- copy(self)
- Returns a copy of the tree
- copy_data(self, tree)
- Copy tree data to another
- copy_node_data(self, tree)
- Copy node data to another tree
- findDepths = find_depths(self, node=None)
- find_depths(self, node=None)
- DEPRECATED
- getOnelineNewick = get_one_line_newick(self)
- get_branch_data(self, node)
- Returns branch specific data from a node
- get_one_line_newick(self)
- Get a presentation of the tree in a oneline string newick format
- hasData = has_data(self, dataname)
- has_data(self, dataname)
- Does the tree contain 'dataname' in its extra data
- leafNames = leaf_names(self, node=None)
- leaf_names(self, node=None)
- Returns the leaf names of the tree in order
- leaves(self, node=None)
- Return the leaves of the tree in order
- make_root(self, name=None)
- Create a new root node
- merge_branch_data(self, data1, data2)
- Merges the branch data from two neighboring branches into one
- merge_names(self, tree2)
- Merge the node names from tree2 into this tree.
Change any names that conflict
- newName = new_name(self)
- new_name(self)
- Returns a new node name that should be unique in the tree
- postorder(self, node=None)
- Iterate through nodes in post-order traversal
- preorder(self, node=None)
- Iterate through nodes in pre-order traversal
- readData = read_data(self, node, data)
- readNewick = read_newick(self, filename, readData=None)
- readParentTree = read_parent_tree(self, treeFile, labelFile=None, labels=None)
- read_big_newick(self, filename)
- Reads a big newick file with a custom parser
- read_data(self, node, data)
- Default data reader: reads optional bootstrap and branch length
- read_newick(self, filename, readData=None)
- Reads newick tree format from a file stream
You can specify a specialized node data reader with 'readData'
- read_parent_tree(self, treeFile, labelFile=None, labels=None)
- Reads a parent array from a file
- remove(self, node)
- Removes a node from a tree.
Notifies parent (if it exists) that node has been removed.
- removeTree = remove_tree(self, node)
- remove_tree(self, node)
- Removes subtree rooted at 'node' from tree.
Notifies parent (if it exists) that node has been removed.
- rename(self, oldname, newname)
- Rename a node in the tree
- replaceTree = replace_tree(self, node, childTree)
- replace_tree(self, node, childTree)
- Remove node and replace it with the root of childTree
- set_branch_data(self, node, data)
- Set the branch specific data from 'data' to node.data
- set_default_data(self)
- Set default values in each node's data
- split_branch_data(self, node)
- Split a branch's data into two copies
- write(self, out=<open file '<stdout>', mode 'w'>, writeData=None, oneline=False, rootData=False)
- Write the tree in newick notation
- writeData = write_data(self, node)
- writeNewick = write_newick(self, out=<open file '<stdout>', mode 'w'>, writeData=None, oneline=False, rootData=False)
- writeParentTree = write_parent_tree(self, treeFile, labels)
- write_data(self, node)
- Default data writer: writes optional bootstrap and branch length
- write_newick(self, out=<open file '<stdout>', mode 'w'>, writeData=None, oneline=False, rootData=False)
- Write the tree in newick notation
- write_newick_node(self, node, out=<open file '<stdout>', mode 'w'>, depth=0, writeData=None, oneline=False, rootData=False)
- Write the node in newick format to the out file stream
- write_parent_tree(self, treeFile, labels)
- Writes tree to the parent array format
|
class TreeNode |
|
A class for nodes in a rooted Tree
Contains fields for branch length 'dist' and custom data 'data' |
|
Methods defined here:
- __init__(self, name)
- __iter__(self)
- Iterate through child nodes
- copy(self, parent=None, copyChildren=True)
- Returns a copy of a TreeNode and all of its children
- isLeaf = is_leaf(self)
- is_leaf(self)
- Returns True if the node is a leaf (no children)
- leafNames = leaf_names(self)
- leaf_names(self)
- Returns the leaf names beneath the node in traversal order
- leaves(self)
- Returns the leaves beneath the node in traversal order
- recurse(self, func, *args)
- Applies a function 'func' to the children of a node
- writeData = write_data(self, out)
- write_data(self, out)
- Writes the data of the node to the file stream 'out'
| |