NAME
Bio::Tree::NodeI - Interface describing a Tree Node
SYNOPSIS
# get a Tree::NodeI somehow# like from a TreeIOuse Bio::TreeIO;# read in a clustalw NJ in phylip/newick formatmy $treeio = Bio::TreeIO->new(-format => 'newick', -file => 'file.dnd');my $tree = $treeio->next_tree; # we'll assume it worked for demo purposes# you might want to test that it was definedmy $rootnode = $tree->get_root_node;# process just the next generationforeach my $node ( $rootnode->each_Descendent() ) {print "branch len is ", $node->branch_length, "\n";}# process all the childrenmy $example_leaf_node;foreach my $node ( $rootnode->get_all_Descendents() ) {if( $node->is_Leaf ) {print "node is a leaf ... ";# for example use below$example_leaf_node = $node unless defined $example_leaf_node;}print "branch len is ", $node->branch_length, "\n";}# The ancestor() method points to the parent of a node# A node can only have one parentmy $parent = $example_leaf_node->ancestor;# parent won't likely have an description because it is an internal node# but child will because it is a leafprint "Parent id: ", $parent->id," child id: ",$example_leaf_node->id, "\n";
DESCRIPTION
A NodeI is capable of the basic structure of building a tree and storing the branch length between nodes. The branch length is the length of the branch between the node and its ancestor, thus a root node in a Tree will not typically have a valid branch length.
Various implementations of NodeI may extend the basic functions and allow storing of other information (like attaching a species object or full sequences used to build a tree or alternative sequences). If you don't know how to extend a Bioperl object please ask, happy to help, we would also greatly appreciate contributions with improvements or extensions of the objects back to the Bioperl code base so that others don't have to reinvent your ideas.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Jason Stajich
Email [email protected]
CONTRIBUTORS
Aaron Mackey [email protected]
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
add_Descendent
Title : add_DescendentUsage : $node->add_Descendent($node);Function: Adds a descendent to a nodeReturns : number of current descendents for this nodeArgs : Bio::Node::NodeI
each_Descendent
Title : each_DescendentUsage : my @nodes = $node->each_Descendent;Function: all the descendents for this Node (but not their descendentsi.e. not a recursive fetchall)Returns : Array of Bio::Tree::NodeI objectsArgs : none
Decorated Interface methods
get_all_Descendents
Title : get_all_Descendents($sortby)Usage : my @nodes = $node->get_all_Descendents;Function: Recursively fetch all the nodes and their descendents*NOTE* This is different from each_DescendentReturns : Array or Bio::Tree::NodeI objectsArgs : $sortby [optional] "height", "creation", "alpha", "revalpha",or a coderef to be used to sort the order of children nodes.
is_Leaf
Title : is_LeafUsage : if( $node->is_Leaf )Function: Get Leaf statusReturns : booleanArgs : none
descendent_count
Title : descendent_countUsage : my $count = $node->descendent_count;Function: Counts the number of descendents a node has(and all of their subnodes)Returns : integerArgs : none
to_string
Title : to_stringUsage : my $str = $node->to_string()Function: For debugging, provide a node as a stringReturns : stringArgs : none
height
Title : heightUsage : my $len = $node->heightFunction: Returns the height of the tree starting at thisnode. Height is the maximum branchlength to get to the tip.Returns : The longest length (weighting branches with branch_length) to a leafArgs : none
depth
Title : depthUsage : my $len = $node->depthFunction: Returns the depth of the tree starting at thisnode. Depth is the distance from this node to the root.Returns : The branch length to the root.Args : none
Get/Set methods
branch_length
Title : branch_lengthUsage : $obj->branch_length()Function: Get/Set the branch lengthReturns : value of branch_lengthArgs : newvalue (optional)
id
Title : idUsage : $obj->id($newval)Function: The human readable identifier for the nodeReturns : value of human readable idArgs : newvalue (optional)
internal_id
Title : internal_idUsage : my $internalid = $node->internal_idFunction: Returns the internal unique id for this NodeReturns : unique idArgs : none
description
Title : descriptionUsage : $obj->description($newval)Function: Get/Set the description stringReturns : value of descriptionArgs : newvalue (optional)
bootstrap
Title : bootstrapUsage : $obj->bootstrap($newval)Function: Get/Set the bootstrap valueReturns : value of bootstrapArgs : newvalue (optional)
ancestor
Title : ancestorUsage : my $node = $node->ancestor;Function: Get/Set the ancestor node pointer for a NodeReturns : Null if this is top level nodeArgs : none
invalidate_height
Title : invalidate_heightUsage : private helper methodFunction: Invalidate our cached value of the node height in the treeReturns : nothingArgs : none
Methods for associating Tag/Values with a Node
These methods associate tag/value pairs with a Node
set_tag_value
Title : set_tag_valueUsage : $node->set_tag_value($tag,$value)$node->set_tag_value($tag,@values)Function: Sets a tag value(s) to a node. Replaces old values.Returns : number of values stored for this tagArgs : $tag - tag name$value - value to store for the tag
add_tag_value
Title : add_tag_valueUsage : $node->add_tag_value($tag,$value)Function: Adds a tag value to a nodeReturns : number of values stored for this tagArgs : $tag - tag name$value - value to store for the tag
remove_tag
Title : remove_tagUsage : $node->remove_tag($tag)Function: Remove the tag and all values for this tagReturns : boolean representing success (0 if tag does not exist)Args : $tag - tagname to remove
remove_all_tags
Title : remove_all_tagsUsage : $node->remove_all_tags()Function: Removes all tagsReturns : NoneArgs : None
get_all_tags
Title : get_all_tagsUsage : my @tags = $node->get_all_tags()Function: Gets all the tag names for this NodeReturns : Array of tagnamesArgs : None
get_tag_values
Title : get_tag_valuesUsage : my @values = $node->get_tag_values($tag)Function: Gets the values for given tag ($tag)Returns : Array of values or empty list if tag does not existArgs : $tag - tag name
has_tag
Title : has_tagUsage : $node->has_tag($tag)Function: Boolean test if tag exists in the NodeReturns : BooleanArgs : $tag - tagname
Helper Functions
id_output
Title : id_outputUsage : my $id = $node->id_output;Function: Return an id suitable for output in format like newickso that if it contains spaces or ():; characters it is properlyquotedReturns : $id string if $node->id has a valueArgs : none