Bio::Tree NodeI
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Tree::NodeI - Interface describing a Tree Node
Package variables
No package variables defined.
Included modules
Bio::Root::RootI
Inherit
Bio::Root::RootI
Synopsis
    # get a Tree::NodeI somehow
    # like from a TreeIO
    use Bio::TreeIO;
    # read in a clustalw NJ in phylip/newick format
    my $treeio = new Bio::TreeIO(-format => 'newick', -file => 'file.dnd');
    my $tree = $treeio->next_tree; # we'll assume it worked for demo purposes

    my $rootnode = $tree->get_root_node;

    # process just the next generation
    foreach my $node ( $tree->each_Descendent() ) {
	print "branch len is ", $node->branch_length, "\n";
    }
    # process all the children
    foreach my $node ( $tree->get_Descendents() ) {
	if( $node->is_Leaf ) { 
	    print "node is a leaf ... "; 
	}
	print "branch len is ", $node->branch_length, "\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.
Methods
add_DescendentDescriptionCode
each_DescendentDescriptionCode
get_DescendentsDescriptionCode
is_LeafDescriptionCode
descendent_countDescriptionCode
to_stringDescriptionCode
heightDescriptionCode
branch_lengthDescriptionCode
idDescriptionCode
descriptionDescriptionCode
bootstrapDescriptionCode
ancestorDescriptionCode
invalidate_heightDescriptionCode
Methods description
add_Descendentcode    nextTop
 Title   : add_Descendent
 Usage   : $node->add_Descendant($node);
 Function: Adds a descendent to a node
 Returns : number of current descendents for this node
 Args    : Bio::Node::NodeI
each_DescendentcodeprevnextTop
 Title   : each_Descendent
 Usage   : my @nodes = $node->each_Descendent;
 Function: all the descendents for this Node (but not their descendents 
					      i.e. not a recursive fetchall)
 Returns : Array of Bio::Tree::NodeI objects
 Args    : none
get_DescendentscodeprevnextTop
 Title   : get_Descendents
 Usage   : my @nodes = $node->get_Descendents;
 Function: Recursively fetch all the nodes and their descendents
           *NOTE* This is different from each_Descendent
 Returns : Array or Bio::Tree::NodeI objects
 Args    : none
is_LeafcodeprevnextTop
 Title   : is_Leaf
 Usage   : if( $node->is_Leaf ) 
 Function: Get Leaf status
 Returns : boolean
 Args    : none
descendent_countcodeprevnextTop
 Title   : descendent_count
 Usage   : my $count = $node->descendent_count;
 Function: Counts the number of descendents a node has 
           (and all of their subnodes)
 Returns : integer
 Args    : none
to_stringcodeprevnextTop
 Title   : to_string
 Usage   : my $str = $node->to_string()
 Function: For debugging, provide a node as a string
 Returns : string
 Args    : none
heightcodeprevnextTop
 Title   : height
 Usage   : my $len = $node->height
 Function: Returns the height of the tree starting at this
           node.  Height is the maximum branchlength.
 Returns : The longest length (weighting branches with branch_length) to a leaf
 Args    : none
branch_lengthcodeprevnextTop
 Title   : branch_length
 Usage   : $obj->branch_length()
 Function: 
 Example : 
 Returns : value of branch_length
 Args    : newvalue (optional)
idcodeprevnextTop
 Title   : id
 Usage   : $obj->id($newval)
 Function: 
 Example : 
 Returns : value of id
 Args    : newvalue (optional)
descriptioncodeprevnextTop
 Title   : description
 Usage   : $obj->description($newval)
 Function: 
 Example : 
 Returns : value of description
 Args    : newvalue (optional)
bootstrapcodeprevnextTop
 Title   : bootstrap
 Usage   : $obj->bootstrap($newval)
 Function: 
 Example : 
 Returns : value of bootstrap
 Args    : newvalue (optional)
ancestorcodeprevnextTop
 Title   : ancestor
 Usage   : my $node = $node->ancestor;
 Function: Get/Set a Node's ancestor node
 Returns : Null if this is top level node
 Args    : none
invalidate_heightcodeprevnextTop
 Title   : invalidate_height
 Usage   : private helper method
 Function: Invalidate our cached value of the node'e height in the tree
 Returns : nothing
 Args    : none
Methods code
add_DescendentdescriptionprevnextTop
sub add_Descendent {
   my ($self,@args) = @_;

   $self->throw_not_implemented();
}
each_DescendentdescriptionprevnextTop
sub each_Descendent {
   my ($self) = @_;
   $self->throw_not_implemented();
}
get_DescendentsdescriptionprevnextTop
sub get_Descendents {
   my ($self) = @_;
   my @nodes;
   foreach my $node ( $self->each_Descendent ) {
       push @nodes, ($node->get_Descendents, $node);
   }
   return @nodes;
}
is_LeafdescriptionprevnextTop
sub is_Leaf {
    my ($self) = @_;
    $self->throw_not_implemented();
}
descendent_countdescriptionprevnextTop
sub descendent_count {
   my ($self) = @_;
   my $count = 0;
   
   foreach my $node ( $self->each_Descendent ) { 
       $count += 1 + $node->descendent_count;
   }
   return $count;
}
to_stringdescriptionprevnextTop
sub to_string {
   my ($self) = @_;
   return sprintf("%s%s",defined $self->id ? $self->id : '',
		  defined $self->branch_length ? 
		  ":" . $self->branch_length : ' ');
}
heightdescriptionprevnextTop
sub height {
   my ($self) = @_;
   
   if( $self->is_Leaf ) { 
       if( !defined $self->branch_length ) { 
	   $self->debug(sprintf("Trying to calculate height of a node when a Node (%s) has an undefined branch_length",$self->id || '?' ));
	   return 0;
       }
       return $self->branch_length;
   }
   my $max = 0;
   foreach my $subnode ( $self->each_Descendent ) { 
       my $s = $subnode->height;
       if( $s > $max ) { $max = $s; }
   }
   return $max + ($self->branch_length || 0);
}
branch_lengthdescriptionprevnextTop
sub branch_length {
    my ($self)= @_;
    $self->throw_not_implemented();
}
iddescriptionprevnextTop
sub id {
    my ($self)= @_;
    $self->throw_not_implemented();
}
descriptiondescriptionprevnextTop
sub description {
    my ($self) = @_;
    $self->throw_not_implemented();
}
bootstrapdescriptionprevnextTop
sub bootstrap {
    my ($self) = @_;
    $self->throw_not_implemented();
}
ancestordescriptionprevnextTop
sub ancestor {
   my ($self,@args) = @_;
    $self->throw_not_implemented();
}
invalidate_heightdescriptionprevnextTop
sub invalidate_height {
     shift->throw_not_implemented();
}
General documentation
FEEDBACKTop
Mailing ListsTop
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.
  bioperl-l@bioperl.org              - General discussion
  http://bioperl.org/MailList.shtml  - About the mailing lists
Reporting BugsTop
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
email or the web:
  bioperl-bugs@bioperl.org
  http://bioperl.org/bioperl-bugs/
AUTHOR - Jason StajichTop
Email jason@bioperl.org
Describe contact details here
CONTRIBUTORSTop
Additional contributors names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Decorated Interface methodsTop
Get/Set methodsTop