NAME

Bio::Phylo::Forest::Node - Node in a phylogenetic tree

SYNOPSIS

# some way to get nodes:
use Bio::Phylo::IO;
my $string = '((A,B),C);';
my $forest = Bio::Phylo::IO->parse(
   -format => 'newick',
   -string => $string
);

# prints 'Bio::Phylo::Forest'
print ref $forest;

foreach my $tree ( @{ $forest->get_entities } ) {

   # prints 'Bio::Phylo::Forest::Tree'
   print ref $tree;

   foreach my $node ( @{ $tree->get_entities } ) {

      # prints 'Bio::Phylo::Forest::Node'
      print ref $node;

      # node has a parent, i.e. is not root
      if ( $node->get_parent ) {
         $node->set_branch_length(1);
      }

      # node is root
      else {
         $node->set_branch_length(0);
      }
   }
}

DESCRIPTION

This module has the getters and setters that alter the state of a node object. Useful behaviours (which are also available) are defined in the Bio::Phylo::Forest::NodeRole package.

METHODS

set_parent()

Sets argument as invocant's parent.

Type    : Mutator
Title   : set_parent
Usage   : $node->set_parent($parent);
Function: Assigns a node's parent.
Returns : Modified object.
Args    : If no argument is given, the current
          parent is set to undefined. A valid
          argument is Bio::Phylo::Forest::Node
          object.
set_raw_parent()

Sets argument as invocant's parent. This method does NO sanity checks on the rest of the topology. Use with caution.

Type    : Mutator
Title   : set_raw_parent
Usage   : $node->set_raw_parent($parent);
Function: Assigns a node's parent.
Returns : Modified object.
Args    : If no argument is given, the current
          parent is set to undefined. A valid
          argument is Bio::Phylo::Forest::Node
          object.
set_child()

Sets argument as invocant's child.

Type    : Mutator
Title   : set_child
Usage   : $node->set_child($child);
Function: Assigns a new child to $node
Returns : Modified object.
Args    : A valid argument consists of a
          Bio::Phylo::Forest::Node object.
set_raw_child()

Sets argument as invocant's child. This method does NO sanity checks on the rest of the topology. Use with caution.

Type    : Mutator
Title   : set_raw_child
Usage   : $node->set_raw_child($child);
Function: Assigns a new child to $node
Returns : Modified object.
Args    : A valid argument consists of a
          Bio::Phylo::Forest::Node object.
set_branch_length()

Sets argument as invocant's branch length.

Type    : Mutator
Title   : set_branch_length
Usage   : $node->set_branch_length(0.423e+2);
Function: Assigns a node's branch length.
Returns : Modified object.
Args    : If no argument is given, the
          current branch length is set
          to undefined. A valid argument
          is a number in any of Perl's formats.
set_tree()

Sets what tree invocant belongs to

Type    : Mutator
Title   : set_tree
Usage   : $node->set_tree($tree);
Function: Sets what tree invocant belongs to
Returns : Invocant
Args    : Bio::Phylo::Forest::Tree
Comments: This method is called automatically 
          when inserting or deleting nodes in
          trees.
set_rank()

Sets the taxonomic rank of the node

Type    : Mutator
Title   : set_rank
Usage   : $node->set_rank('genus');
Function: Sets the taxonomic rank of the node
Returns : Invocant
Args    : String
Comments: Free-form, but highly recommended to use same rank names as in Bio::Taxon
get_parent()

Gets invocant's parent.

Type    : Accessor
Title   : get_parent
Usage   : my $parent = $node->get_parent;
Function: Retrieves a node's parent.
Returns : Bio::Phylo::Forest::Node
Args    : NONE
get_branch_length()

Gets invocant's branch length.

Type    : Accessor
Title   : get_branch_length
Usage   : my $branch_length = $node->get_branch_length;
Function: Retrieves a node's branch length.
Returns : FLOAT
Args    : NONE
Comments: Test for "defined($node->get_branch_length)"
          for zero-length (but defined) branches. Testing
          "if ( $node->get_branch_length ) { ... }"
          yields false for zero-but-defined branches!
get_children()

Gets invocant's immediate children.

Type    : Query
Title   : get_children
Usage   : my @children = @{ $node->get_children };
Function: Returns an array reference of immediate
          descendants, ordered from left to right.
Returns : Array reference of
          Bio::Phylo::Forest::Node objects.
Args    : NONE
get_tree()

Returns the tree invocant belongs to

Type    : Query
Title   : get_tree
Usage   : my $tree = $node->get_tree;
Function: Returns the tree $node belongs to
Returns : Bio::Phylo::Forest::Tree
Args    : NONE
get_rank()

Gets the taxonomic rank of the node

Type    : Mutator
Title   : get_rank
Usage   : my $rank = $node->get_rank;
Function: Gets the taxonomic rank of the node
Returns : String
Args    : NONE
Comments: 
# podinherit_insert_token

SEE ALSO

There is a mailing list at https://groups.google.com/forum/#!forum/bio-phylo for any user or developer questions and discussions.

Bio::Phylo::Forest::NodeRole

This object inherits from Bio::Phylo::Forest::NodeRole, so methods defined there are also applicable here.

Bio::Phylo::Manual

Also see the manual: Bio::Phylo::Manual and http://rutgervos.blogspot.com.

CITATION

If you use Bio::Phylo in published research, please cite it:

Rutger A Vos, Jason Caravas, Klaas Hartmann, Mark A Jensen and Chase Miller, 2011. Bio::Phylo - phyloinformatic analysis using Perl. BMC Bioinformatics 12:63. http://dx.doi.org/10.1186/1471-2105-12-63