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 defines a node object and its methods. The node is fairly syntactically rich in terms of navigation, and additional getters are provided to further ease navigation from node to node. Typical first daughter -> next sister traversal and recursion is possible, but there are also shrinkwrapped methods that return for example all terminal descendants of the focal node, or all internals, etc.
Node objects are inserted into tree objects, although technically the tree object is only a container holding all the nodes together. Unless there are orphans all nodes can be reached without recourse to the tree object.
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_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_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.
- 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
# 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::Taxa::TaxonLinker
-
This object inherits from Bio::Phylo::Taxa::TaxonLinker, so methods defined there are also applicable here.
- Bio::Phylo::Listable
-
This object inherits from Bio::Phylo::Listable, 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