Phylo/Forest/NodeRole.pm

filter: Statementstmt 73.7% 613 / 831 Branchbran 62.2% 224 / 360 Conditioncond 68.7% 79 / 115 MC/DCmcdc 51.4% 36 / 70 Subroutinesub 69.3% 70 / 101 Podpod 75.3% 58 / 77 totaltotal 69.5% 1080 / 1554 CC 254 SCAR 29.6
CC
254
Cov
70%
_visit_breadth_first
156.0
to_dom
84.2
new_from_bioperl
56.0
CRAP 19.3
« Phylo/Matrices/Datum.pm ↑ Summary Phylo/NeXML/Meta/XMLLiteral.pm »
1 package Bio::Phylo::Forest::NodeRole;
2 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use Bio::Phylo::Util::MOP;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use base qw'Bio::Phylo::Taxa::TaxonLinker Bio::Phylo::Listable';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 34 ▶use Bio::Phylo::Util::OptionalInterface 'Bio::Tree::NodeI';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 34 ▶use Bio::Phylo::Util::CONSTANT qw':objecttypes /looks_like/';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 34 ▶use Bio::Phylo::Util::Exceptions 'throw';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 34 ▶use Bio::Phylo::Util::Math ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 34 ▶use Bio::Phylo::NeXML::Writable;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 34 ▶use Bio::Phylo::Factory;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 34 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 34 ▶use List::Util qw[sum min max];
Subroutine BEGIN: called CC=1 SCAR=0.0
14 34 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 34 my $LOADED_WRAPPERS = 0;
17  
18 # store type constant
19 34 my ( $TYPE_CONSTANT, $CONTAINER_CONSTANT ) = ( _NODE_, _TREE_ );
20  
21 # logger singleton
22 34 my $logger = __PACKAGE__->get_logger;
23  
24 # factory object
25 34 my $fac = Bio::Phylo::Factory->new;
26  
27 =head1 NAME
28  
29 Bio::Phylo::Forest::NodeRole - Extra behaviours for a node in a phylogenetic tree
30  
31 =head1 SYNOPSIS
32  
33 # some way to get nodes:
34 use Bio::Phylo::IO;
35 my $string = '((A,B),C);';
36 my $forest = Bio::Phylo::IO->parse(
37 -format => 'newick',
38 -string => $string
39 );
40  
41 # prints 'Bio::Phylo::Forest'
42 print ref $forest;
43  
44 foreach my $tree ( @{ $forest->get_entities } ) {
45  
46 # prints 'Bio::Phylo::Forest::Tree'
47 print ref $tree;
48  
49 foreach my $node ( @{ $tree->get_entities } ) {
50  
51 # prints 'Bio::Phylo::Forest::Node'
52 print ref $node;
53  
54 # node has a parent, i.e. is not root
55 if ( $node->get_parent ) {
56 $node->set_branch_length(1);
57 }
58  
59 # node is root
60 else {
61 $node->set_branch_length(0);
62 }
63 }
64 }
65  
66 =head1 DESCRIPTION
67  
68 This module defines a node object and its methods. The node is fairly
69 syntactically rich in terms of navigation, and additional getters are provided to
70 further ease navigation from node to node. Typical first daughter -> next sister
71 traversal and recursion is possible, but there are also shrinkwrapped methods
72 that return for example all terminal descendants of the focal node, or all
73 internals, etc.
74  
75 Node objects are inserted into tree objects, although technically the tree
76 object is only a container holding all the nodes together. Unless there are
77 orphans all nodes can be reached without recourse to the tree object.
78  
79 =head1 METHODS
80  
81 =over
82  
83 =item new()
84  
85 Node constructor.
86  
87 Type : Constructor
88 Title : new
89 Usage : my $node = Bio::Phylo::Forest::Node->new;
90 Function: Instantiates a Bio::Phylo::Forest::Node object
91 Returns : Bio::Phylo::Forest::Node
92 Args : All optional:
93 -parent => $parent,
94 -taxon => $taxon,
95 -branch_length => 0.423e+2,
96 -first_daughter => $f_daughter,
97 -last_daughter => $l_daughter,
98 -next_sister => $n_sister,
99 -previous_sister => $p_sister,
100 -name => 'node_name',
101 -desc => 'this is a node',
102 -score => 0.98,
103 -generic => {
104 -posterior => 0.98,
105 -bootstrap => 0.80
106 }
107  
108 =cut
109  
110 9120 ▶ sub new : Constructor {
Subroutine new: called CC=5 SCAR=30.4
Pod documented
111  
112 # could be child class
113 9120 my $class = shift;
114  
115 # process bioperl args
116 9120 my %args = looks_like_hash @_;
117 9120 ▶ if ( exists $args{'-leaf'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-leaf"}) 0 9120 9120
118 0 delete $args{'-leaf'};
119 }
120 9120 ▶ if ( exists $args{'-id'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-id"}) 0 9120 9120
121 0 my $name = $args{'-id'};
122 0 delete $args{'-id'};
123 0 $args{'-name'} = $name;
124 }
125 9120 ▶ if ( exists $args{'-nhx'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-nhx"}) 0 9120 9120
126 0 my $hash = $args{'-nhx'};
127 0 delete $args{'-nhx'};
128 0 $args{'-generic'} = $hash;
129 }
130  
131 # if ( not exists $args{'-tag'} ) {
132 # $args{'-tag'} = __PACKAGE__->_tag;
133 # }
134 # go up inheritance tree, eventually get an ID
135 9120 my $self = $class->SUPER::new(%args);
136 9120 ▶ if ( not $LOADED_WRAPPERS ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($LOADED_WRAPPERS) 29 9091 9120
137 0 ▶ eval do { local $/; <DATA> };
Subroutine add_Descendent: not called CC=1 SCAR=6.5
Subroutine add_tag_value: not called CC=2 SCAR=17.3
Subroutine ancestor: not called CC=2 SCAR=17.3
Subroutine bootstrap: not called CC=3 SCAR=24.1
Subroutine branch_length: not called CC=2 SCAR=17.3
Subroutine depth: not called CC=1 SCAR=6.5
Subroutine descendent_count: not called CC=2 SCAR=17.3
Subroutine description: not called CC=2 SCAR=17.3
Subroutine each_Descendent: not called CC=2 SCAR=17.3
Subroutine get_all_Descendents: not called CC=2 SCAR=17.3
Subroutine get_all_tags: not called CC=1 SCAR=6.5
Subroutine get_tag_values: not called CC=2 SCAR=17.3
Subroutine has_tag: not called CC=1 SCAR=6.5
Subroutine height: not called CC=1 SCAR=6.5
Subroutine id: not called CC=2 SCAR=17.3
Subroutine id_output: not called CC=1 SCAR=6.5
Subroutine internal_id: not called CC=1 SCAR=6.5
Subroutine invalidate_height: not called CC=1 SCAR=6.5
Subroutine remove_all_tags: not called CC=1 SCAR=6.5
Subroutine remove_tag: not called CC=1 SCAR=6.5
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 10 branches
BranchTrueFalseTotal
if (@_) 0 0 0
if (@_) 0 0 0
if (defined $bs and &looks_like_number($bs)) 0 0 0
if (@_) 0 0 0
if (my $desc = get_descendants()) 0 0 0
if (@_) 0 0 0
if (my $children = $self->get_children) 0 0 0
if (my $desc = $self->get_descendants) 0 0 0
ref $values ? : 0 0 0
if (@_) 0 0 0
Condition0%0/3
defined $bs and &looks_like_number($bs)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $bs and &looks_like_number($bs)
defined $bs &looks_like_number($bs)
Truth table0%0/3
A and B
A= defined $bsB= &looks_like_number($bs)
ABresult
0X0
100
111
138 29 $LOADED_WRAPPERS++;
139 }
140 9120 return $self;
141 34 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
142  
143 =item new_from_bioperl()
144  
145 Node constructor from bioperl L<Bio::Tree::NodeI> argument.
146  
147 Type : Constructor
148 Title : new_from_bioperl
149 Usage : my $node =
150 Bio::Phylo::Forest::Node->new_from_bioperl(
151 $bpnode
152 );
153 Function: Instantiates a Bio::Phylo::Forest::Node object
154 from a bioperl node object.
155 Returns : Bio::Phylo::Forest::Node
156 Args : An objects that implements Bio::Tree::NodeI
157 Notes : The following BioPerl properties are copied:
158 BioPerl output: Bio::Phylo output:
159 ------------------------------------------------
160 id get_name
161 branch_length get_branch_length
162 description get_desc
163 bootstrap get_generic('bootstrap')
164
165 In addition all BioPerl tags and values are copied
166 to set_generic( 'tag' => 'value' );
167  
168 =cut
169  
170 0 ▶ sub new_from_bioperl {
Subroutine new_from_bioperl: not called CC=7 SCAR=40.3
Pod documented
171 0 my ( $class, $bpnode ) = @_;
172 0 my $node = $class->new;
173  
174 # copy name
175 0 my $name = $bpnode->id;
176 0 ▶ $node->set_name($name) if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 0 0
177  
178 # copy branch length
179 0 my $branch_length = $bpnode->branch_length;
180 0 ▶ $node->set_branch_length($branch_length) if defined $branch_length;
Branch: 1 branch
BranchTrueFalseTotal
if defined $branch_length 0 0 0
181  
182 # copy description
183 0 my $desc = $bpnode->description;
184 0 ▶ $node->set_desc($desc) if defined $desc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $desc 0 0 0
185  
186 # copy bootstrap
187 0 my $bootstrap = $bpnode->bootstrap;
188 0 ▶ $node->set_score($bootstrap)
Branch: 1 branch
BranchTrueFalseTotal
if defined $bootstrap and &looks_like_number($bootstrap) 0 0 0
Condition0%0/3
defined $bootstrap and &looks_like_number($bootstrap)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $bootstrap and &looks_like_number($bootstrap)
defined $bootstrap &looks_like_number($bootstrap)
Truth table0%0/3
A and B
A= defined $bootstrapB= &looks_like_number($bootstrap)
ABresult
0X0
100
111
189 if defined $bootstrap and looks_like_number $bootstrap;
190  
191 # copy other tags
192 0 for my $tag ( $bpnode->get_all_tags ) {
193 0 my @values = $bpnode->get_tag_values($tag);
194 0 $node->set_generic( $tag => \@values );
195 }
196 0 return $node;
197 }
198  
199 =item prune_child()
200  
201 Removes argument child node (and its descendants) from invocants children.
202  
203 Type : Mutator
204 Title : prune_child
205 Usage : $parent->prune_child($child);
206 Function: Removes $child (and its descendants) from $parent's children
207 Returns : Modified object.
208 Args : A valid argument is Bio::Phylo::Forest::Node object.
209  
210 =cut
211  
212 407 ▶ sub prune_child {
Subroutine prune_child: called CC=1 SCAR=0.0
Pod documented
213 407 my ( $self, $child ) = @_;
214 407 $self->delete($child);
215 407 return $self;
216 }
217  
218 =item collapse()
219  
220 Collapse node.
221  
222 Type : Mutator
223 Title : collapse
224 Usage : $node->collapse;
225 Function: Attaches invocant's children to invocant's parent.
226 Returns : Modified object.
227 Args : NONE
228 Comments: If defined, adds invocant's branch
229 length to that of its children. If
230 $node is in a tree, removes itself
231 from that tree.
232  
233 =cut
234  
235 130 ▶ sub collapse {
Subroutine collapse: called CC=7 SCAR=20.9
Pod documented
236 130 my $self = shift;
237  
238 # can't collapse root
239 130 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) { } 130 0 130
240  
241 # can't collapse terminal nodes
242 130 ▶ if ( my @children = @{ $self->get_children } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@children) = @{$self->get_children;}) { } 130 0 130
243  
244 # add node's branch length to that of children
245 130 my $length = $self->get_branch_length;
246 130 for my $child (@children) {
247 260 ▶ if ( defined $length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $length) 260 0 260
248 260 ▶ my $child_length = $child->get_branch_length || 0;
Condition50%1/2
$child->get_branch_length || 0
l!l
2600
MC/DC0%0/1
$child->get_branch_length || 0
$child->get_branch_length
Truth table50%1/2
A
A= $child->get_branch_length
Aresult
11
00
249 260 $child->set_branch_length( $length + $child_length );
250 }
251  
252 # attach children to node's parent
253 260 $child->set_parent($parent);
254 }
255  
256 # prune node from parent
257 130 $parent->prune_child($self);
258  
259 # delete node from tree
260 130 ▶ if ( my $tree = $self->get_tree ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tree = $self->get_tree) 130 0 130
261 130 $tree->delete($self);
262 }
263 }
264 else {
265 0 return $self;
266 }
267 }
268 else {
269 0 return $self;
270 }
271 }
272  
273 =item set_first_daughter()
274  
275 Sets argument as invocant's first daughter.
276  
277 Type : Mutator
278 Title : set_first_daughter
279 Usage : $node->set_first_daughter($f_daughter);
280 Function: Assigns a node's leftmost daughter.
281 Returns : Modified object.
282 Args : Undefines the first daughter if no
283 argument given. A valid argument is
284 a Bio::Phylo::Forest::Node object.
285  
286 =cut
287  
288 336 ▶ sub set_first_daughter {
Subroutine set_first_daughter: called CC=1 SCAR=0.0
Pod documented
289 336 my ( $self, $fd ) = @_;
290 336 $self->set_child( $fd, 0 );
291 335 return $self;
292 }
293  
294 =item set_last_daughter()
295  
296 Sets argument as invocant's last daughter.
297  
298 Type : Mutator
299 Title : set_last_daughter
300 Usage : $node->set_last_daughter($l_daughter);
301 Function: Assigns a node's rightmost daughter.
302 Returns : Modified object.
303 Args : A valid argument consists of a
304 Bio::Phylo::Forest::Node object. If
305 no argument is given, the value is
306 set to undefined.
307  
308 =cut
309  
310 336 ▶ sub set_last_daughter {
Subroutine set_last_daughter: called CC=1 SCAR=0.0
Pod documented
311 336 my ( $self, $ld ) = @_;
312 336 $self->set_child( $ld, scalar @{ $self->get_children } );
313 335 return $self;
314 }
315  
316 =item set_previous_sister()
317  
318 Sets argument as invocant's previous sister.
319  
320 Type : Mutator
321 Title : set_previous_sister
322 Usage : $node->set_previous_sister($p_sister);
323 Function: Assigns a node's previous sister (to the left).
324 Returns : Modified object.
325 Args : A valid argument consists of
326 a Bio::Phylo::Forest::Node object.
327 If no argument is given, the value
328 is set to undefined.
329  
330 =cut
331  
332 237 ▶ sub set_previous_sister {
Subroutine set_previous_sister: called CC=7 SCAR=19.6
Pod documented
333 237 my ( $self, $ps ) = @_;
334 237 ▶ if ( $ps and looks_like_object $ps, $TYPE_CONSTANT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ps and &looks_like_object($ps, $TYPE_CONSTANT)) 6 230 236
Condition100%3/3
$ps and &looks_like_object($ps, $TYPE_CONSTANT)
!ll&&!rl&&r
23016
MC/DC50%1/2
$ps and &looks_like_object($ps, $TYPE_CONSTANT)
$ps &looks_like_object($ps, $TYPE_CONSTANT)
Truth table66%2/3
A and B
A= $psB= &looks_like_object($ps, $TYPE_CONSTANT)
ABresult
0X0
100
111
335 6 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) 6 0 6
336 6 my $children = $parent->get_children;
337 6 my $j = 0;
338 6 ▶ FINDSELF: for ( my $i = $#{$children} ; $i >= 0 ; $i-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 13 0 13
339 13 ▶ if ( $children->[$i] == $self ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($children->[$i] == $self) 6 7 13
340 6 $j = $i - 1;
341 6 last FINDSELF;
342 }
343 }
344 6 ▶ $j = 0 if $j == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $j == -1 6 0 6
345 6 $parent->set_child( $ps, $j );
346 }
347 }
348 236 return $self;
349 }
350  
351 =item set_next_sister()
352  
353 Sets argument as invocant's next sister.
354  
355 Type : Mutator
356 Title : set_next_sister
357 Usage : $node->set_next_sister($n_sister);
358 Function: Assigns or retrieves a node's
359 next sister (to the right).
360 Returns : Modified object.
361 Args : A valid argument consists of a
362 Bio::Phylo::Forest::Node object.
363 If no argument is given, the
364 value is set to undefined.
365  
366 =cut
367  
368 237 ▶ sub set_next_sister {
Subroutine set_next_sister: called CC=6 SCAR=17.9
Pod documented
369 237 my ( $self, $ns ) = @_;
370 237 ▶ if ( $ns and looks_like_object $ns, $TYPE_CONSTANT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns and &looks_like_object($ns, $TYPE_CONSTANT)) 6 230 236
Condition100%3/3
$ns and &looks_like_object($ns, $TYPE_CONSTANT)
!ll&&!rl&&r
23016
MC/DC50%1/2
$ns and &looks_like_object($ns, $TYPE_CONSTANT)
$ns &looks_like_object($ns, $TYPE_CONSTANT)
Truth table66%2/3
A and B
A= $nsB= &looks_like_object($ns, $TYPE_CONSTANT)
ABresult
0X0
100
111
371 6 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) 6 0 6
372 6 my $children = $parent->get_children;
373 6 my $last = scalar @{$children};
374 6 my $j = $last;
375 6 FINDSELF: for my $i ( 0 .. $#{$children} ) {
376 16 ▶ if ( $children->[$i] == $self ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($children->[$i] == $self) 6 10 16
377 6 $j = $i + 1;
378 6 last FINDSELF;
379 }
380 }
381 6 $parent->set_child( $ns, $j );
382 }
383 }
384 236 return $self;
385 }
386  
387 =item set_node_below()
388  
389 Sets new (unbranched) node below invocant.
390  
391 Type : Mutator
392 Title : set_node_below
393 Usage : my $new_node = $node->set_node_below;
394 Function: Creates a new node below $node
395 Returns : New node if tree was modified, undef otherwise
396 Args : NONE
397  
398 =cut
399  
400 0 ▶ sub set_node_below {
Subroutine set_node_below: not called CC=2 SCAR=17.9
Pod documented
401 0 my $self = shift;
402  
403 # can't set node below root
404 0 ▶ if ( $self->is_root ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_root) 0 0 0
405 0 return;
406 }
407  
408 # instantiate new node from $self's class
409 0 my $new_node = ( ref $self )->new(@_);
410  
411 # attach new node to $child's parent
412 0 my $parent = $self->get_parent;
413 0 $parent->set_child($new_node);
414  
415 # insert new node in tree
416 # if ( my $tree = $self->_get_container ) {
417 # $tree->insert( $new_node );
418 # }
419 # attach $self to new node
420 0 $new_node->set_child($self);
421  
422 # done
423 0 return $new_node;
424 }
425  
426 =item set_root_below()
427  
428 Reroots below invocant.
429  
430 Type : Mutator
431 Title : set_root_below
432 Usage : $node->set_root_below;
433 Function: Creates a new tree root below $node
434 Returns : New root if tree was modified, undef otherwise
435 Args : NONE
436 Comments: This implementation is a port of @lh3's kn_reroot algorithm
437 found here: http://lh3lh3.users.sourceforge.net/knhx.js
438  
439 =cut
440  
441 9 ▶ sub set_root_below {
Subroutine set_root_below: called CC=17 SCAR=29.9
Pod documented
442 9 my $node = shift;
443 9 ▶ my $dist = shift || 0;
Condition100%2/2
shift() || 0
l!l
18
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
444 9 ▶ my $force = shift || 0;
Condition50%1/2
shift() || 0
l!l
09
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
445 9 my $tree = $node->get_tree;
446 9 my $root = $tree->get_root;
447
448 # do nothing if the focal node already is the root,
449 # or already has the root below it
450 9 ▶ return if $node->get_id == $root->get_id;
Branch: 1 branch
BranchTrueFalseTotal
if $node->get_id == $root->get_id 1 8 9
451 8 ▶ return if $node->get_parent and $node->get_parent->get_id == $root->get_id and not $force;
Branch: 1 branch
BranchTrueFalseTotal
if $node->get_parent and $node->get_parent->get_id == $root->get_id and not $force 1 7 8
Condition66%4/6
$node->get_parent and $node->get_parent->get_id == $root->get_id and not $force
!ll&&!rl&&r
701
$node->get_parent and $node->get_parent->get_id == $root->get_id
!ll&&!rl&&r
071
MC/DC33%1/3
$node->get_parent and $node->get_parent->get_id == $root->get_id and not $force
$node->get_parent $node->get_parent->get_id == $root->get_id not $force
Truth table50%2/4
A and B and not(C)
A= $node->get_parentB= $node->get_parent->get_id == $root->get_idC= not $force
ABCresult
0XX0
10X0
1100
1111
452
453 # p: the central multi-parent node
454 # q: the new parent, previous a child of p
455 # r: old parent
456 # i: previous position of q in p
457 # d: previous distance p->d
458 7 my ( $q, $s, $new_root );
459 7 my $p = $node->get_parent;
460 7 my $i = $p->get_index_of( $node );
461 7 my $r = $p->get_parent;
462 7 my $d = $p->get_branch_length;
463 7 ▶ my $tmp = $node->get_branch_length || 0;
Condition100%2/2
$node->get_branch_length || 0
l!l
25
MC/DC100%1/1
$node->get_branch_length || 0
$node->get_branch_length
Truth table100%2/2
A
A= $node->get_branch_length
Aresult
11
00
464
465 # adjust $dist to a useable value
466 7 ▶ $dist = $tmp / 2 if ($dist < 0.0 || $dist > $tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $dist < 0 or $dist > $tmp 0 7 7
Condition33%1/3
$dist < 0 or $dist > $tmp
l!l&&r!l&&!r
007
MC/DC0%0/2
$dist < 0 or $dist > $tmp
$dist < 0 $dist > $tmp
Truth table33%1/3
A or B
A= $dist < 0B= $dist > $tmp
ABresult
1X1
011
000
467  
468 # instantiate new root, add $node as first child with new length
469 7 $q = $new_root = $fac->create_node( '-name' => 'root' );
470 7 $q->set_raw_child( $node => 0 );
471 7 $node->set_raw_parent( $q );
472 7 $node->set_branch_length( $dist );
473
474 # add $node's parent as child with new length
475 7 $q->set_raw_child( $p => 1 );
476 7 $p->set_raw_parent( $q );
477 7 $p->set_branch_length( $tmp - $dist );
478
479 # traverse along previous ancestors, swap them
480 # and update the branch lengths
481 7 ▶ while ( $r ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r) 18 7 25
482 18 $s = $r->get_parent; # store r's parent
483 18 $p->set_raw_child( $r => $i ); # change r to p's child
484 18 $i = $r->get_index_of( $p ); # update $i
485 18 $r->set_raw_parent( $p ); # update r's parent
486
487 # swap r->d and d, i.e. update r->d
488 18 $tmp = $r->get_branch_length;
489 18 $r->set_branch_length( $d );
490 18 $d = $tmp;
491
492 # update p, q and r
493 18 $q = $p; $p = $r; $r = $s;
494 }
495
496 # now $p is the root node
497 7 my @children = @{ $p->get_children };
498 7 ▶ if ( scalar(@children) == 2 ) { # remove p and link the other child of p to q
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @children == 2) { } 7 0 7
499 7 $r = $children[1 - $i]; # get the other child
500 7 $i = $q->get_index_of( $p ); # the position of p in q
501 7 ▶ my $bl = ( $r->get_branch_length || 0 ) + ( $p->get_branch_length || 0 );
Condition100%4/4
$r->get_branch_length || 0
l!l
25
$p->get_branch_length || 0
l!l
25
MC/DC100%1/1
$r->get_branch_length || 0
$r->get_branch_length
MC/DC100%1/1
$p->get_branch_length || 0
$p->get_branch_length
Truth table100%2/2
A
A= $r->get_branch_length
Aresult
11
00
Truth table100%2/2
A
A= $p->get_branch_length
Aresult
11
00
502 7 $r->set_branch_length( $bl );
503
504 # link r to q
505 7 $q->set_raw_child( $r => $i );
506 7 $r->set_raw_parent( $q );
507 }
508
509 # remove one child in p
510 else {
511 0 my $k = 0;
512 0 for my $j ( 0 .. $#children ) {
513 0 $children[$k] = $children[$j];
514 0 ▶ $k++ if $j != $i;
Branch: 1 branch
BranchTrueFalseTotal
if $j != $i 0 0 0
515 }
516 0 pop @children;
517 0 $p->clear();
518 0 ▶ $p->insert( @children ) if @children;
Branch: 1 branch
BranchTrueFalseTotal
if @children 0 0 0
519 }
520 7 $tree->insert($new_root);
521 7 return $new_root;
522 }
523  
524  
525 =back
526  
527 =head2 ACCESSORS
528  
529 =over
530  
531 =item get_first_daughter()
532  
533 Gets invocant's first daughter.
534  
535 Type : Accessor
536 Title : get_first_daughter
537 Usage : my $f_daughter = $node->get_first_daughter;
538 Function: Retrieves a node's leftmost daughter.
539 Returns : Bio::Phylo::Forest::Node
540 Args : NONE
541  
542 =cut
543  
544 49039 ▶ sub get_first_daughter {
Subroutine get_first_daughter: called CC=1 SCAR=0.0
Pod documented
545 49039 return $_[0]->get_child(0);
546 }
547  
548 =item get_last_daughter()
549  
550 Gets invocant's last daughter.
551  
552 Type : Accessor
553 Title : get_last_daughter
554 Usage : my $l_daughter = $node->get_last_daughter;
555 Function: Retrieves a node's rightmost daughter.
556 Returns : Bio::Phylo::Forest::Node
557 Args : NONE
558  
559 =cut
560  
561 22 ▶ sub get_last_daughter {
Subroutine get_last_daughter: called CC=1 SCAR=0.0
Pod documented
562 22 return $_[0]->get_child(-1);
563 }
564  
565 =item get_previous_sister()
566  
567 Gets invocant's previous sister.
568  
569 Type : Accessor
570 Title : get_previous_sister
571 Usage : my $p_sister = $node->get_previous_sister;
572 Function: Retrieves a node's previous sister (to the left).
573 Returns : Bio::Phylo::Forest::Node
574 Args : NONE
575  
576 =cut
577  
578 230 ▶ sub get_previous_sister {
Subroutine get_previous_sister: called CC=4 SCAR=13.9
Pod documented
579 230 my $self = shift;
580 230 my $id = $self->get_id;
581 230 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) 230 0 230
582 230 my $children = $parent->get_children;
583 230 ▶ for ( my $i = $#{$children} ; $i >= 1 ; $i-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 1) 280 111 391
584 280 ▶ if ( $children->[$i]->get_id == $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($children->[$i]->get_id == $id) 119 161 280
585 119 return $children->[ $i - 1 ];
586 }
587 }
588 }
589 111 return;
590 }
591  
592 =item get_next_sister()
593  
594 Gets invocant's next sister.
595  
596 Type : Accessor
597 Title : get_next_sister
598 Usage : my $n_sister = $node->get_next_sister;
599 Function: Retrieves a node's next sister (to the right).
600 Returns : Bio::Phylo::Forest::Node
601 Args : NONE
602  
603 =cut
604  
605 8298 ▶ sub get_next_sister {
Subroutine get_next_sister: called CC=4 SCAR=13.9
Pod documented
606 8298 my $self = shift;
607 8298 my $id = $self->get_id;
608 8298 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) 8083 215 8298
609 8083 my $children = $parent->get_children;
610 8083 for my $i ( 0 .. $#{$children} ) {
611 12540 ▶ if ( $children->[$i]->get_id == $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($children->[$i]->get_id == $id) 8083 4457 12540
612 8083 return $children->[ $i + 1 ];
613 }
614 }
615 }
616 215 return;
617 }
618  
619 =item get_ancestors()
620  
621 Gets invocant's ancestors.
622  
623 Type : Query
624 Title : get_ancestors
625 Usage : my @ancestors = @{ $node->get_ancestors };
626 Function: Returns an array reference of ancestral nodes,
627 ordered from young to old (i.e. $ancestors[-1] is root).
628 Returns : Array reference of Bio::Phylo::Forest::Node
629 objects.
630 Args : NONE
631  
632 =cut
633  
634 71 ▶ sub get_ancestors {
Subroutine get_ancestors: called CC=3 SCAR=11.0
Pod documented
635 71 my $self = shift;
636 71 my @ancestors;
637 71 my $node = $self;
638 71 ▶ if ( $node = $node->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node = $node->get_parent) { } 69 2 71
639 69 ▶ while ($node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node) 219 69 288
640 219 push @ancestors, $node;
641 219 $node = $node->get_parent;
642 }
643 69 return \@ancestors;
644 }
645 else {
646 2 return;
647 }
648 }
649  
650 =item get_root()
651  
652 Gets root relative to the invocant, i.e. by walking up the path of ancestors
653  
654 Type : Query
655 Title : get_root
656 Usage : my $root = $node->get_root;
657 Function: Gets root relative to the invocant
658 Returns : Bio::Phylo::Forest::Node
659 Args : NONE
660  
661 =cut
662  
663 3 ▶ sub get_root {
Subroutine get_root: called CC=2 SCAR=7.6
Pod documented
664 3 my $self = shift;
665 3 ▶ if ( my $anc = $self->get_ancestors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $anc = $self->get_ancestors) { } 3 0 3
666 3 return $anc->[-1];
667 }
668 else {
669 0 return $self;
670 }
671 }
672  
673 =item get_farthest_node()
674  
675 Gets node farthest away from the invocant. By default this is nodal distance,
676 but when supplied an optional true argument it is based on patristic distance
677 instead.
678  
679 Type : Query
680 Title : get_farthest_node
681 Usage : my $farthest = $node->get_farthest_node;
682 Function: Gets node farthest away from the invocant.
683 Returns : Bio::Phylo::Forest::Node
684 Args : Optional, TRUE value to use patristic instead of nodal distance
685  
686 =cut
687  
688 3 ▶ sub get_farthest_node {
Subroutine get_farthest_node: called CC=5 SCAR=16.1
Pod documented
689 3 my ( $self, $patristic ) = @_;
690 3 ▶ my $criterion = $patristic ? 'patristic' : 'nodal';
Branch: 1 branch
BranchTrueFalseTotal
$patristic ? : 2 1 3
691 3 my $method = sprintf 'calc_%s_distance', $criterion;
692 3 my $root = $self->get_root;
693 3 ▶ if ( my $terminals = $root->get_terminals ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $terminals = $root->get_terminals) { } 3 0 3
694 3 my ( $furthest_distance, $furthest_node ) = (0);
695 3 for my $tip ( @{$terminals} ) {
696 24 my $distance = $self->$method($tip);
697 24 ▶ if ( $distance > $furthest_distance ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($distance > $furthest_distance) 13 11 24
698 13 $furthest_distance = $distance;
699 13 $furthest_node = $tip;
700 }
701 }
702 3 return $furthest_node;
703 }
704 else {
705 0 $logger->error("no terminals!");
706 }
707 }
708  
709 =item get_sisters()
710  
711 Gets invocant's sisters.
712  
713 Type : Query
714 Title : get_sisters
715 Usage : my @sisters = @{ $node->get_sisters };
716 Function: Returns an array reference of sisters,
717 ordered from left to right.
718 Returns : Array reference of
719 Bio::Phylo::Forest::Node objects.
720 Args : NONE
721  
722 =cut
723  
724 2 ▶ sub get_sisters {
Subroutine get_sisters: called CC=2 SCAR=7.0
Pod documented
725 2 my $self = shift;
726 2 my $sisters;
727 2 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) 2 0 2
728 2 $sisters = $parent->get_children;
729 }
730 2 return $sisters;
731 }
732  
733 =item get_child()
734  
735 Gets invocant's i'th child.
736  
737 Type : Query
738 Title : get_child
739 Usage : my $child = $node->get_child($i);
740 Function: Returns the child at index $i
741 Returns : A Bio::Phylo::Forest::Node object.
742 Args : An index (integer) $i
743 Comments: if no index is specified, first
744 child is returned
745  
746 =cut
747  
748 49066 ▶ sub get_child {
Subroutine get_child: called CC=2 SCAR=7.0
Pod documented
749 49066 my ( $self, $i ) = @_;
750 49066 ▶ $i = 0 if not defined $i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $i 0 49066 49066
751 49066 my $children = $self->get_children;
752 49066 return $children->[$i];
753 }
754  
755 =item get_descendants()
756  
757 Gets invocant's descendants.
758  
759 Type : Query
760 Title : get_descendants
761 Usage : my @descendants = @{ $node->get_descendants };
762 Function: Returns an array reference of
763 descendants, recursively ordered
764 breadth first.
765 Returns : Array reference of
766 Bio::Phylo::Forest::Node objects.
767 Args : none.
768  
769 =cut
770  
771 572 ▶ sub get_descendants {
Subroutine get_descendants: called CC=2 SCAR=6.9
Pod documented
772 572 my $self = shift;
773 572 my @current = ($self);
774 572 my @desc;
775 572 ▶ while ( $self->_desc(@current) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_desc(@current)) 3622 572 4194
776 3622 @current = $self->_desc(@current);
777 3622 push @desc, @current;
778 }
779 572 return \@desc;
780 }
781  
782 =begin comment
783  
784 Type : Internal method
785 Title : _desc
786 Usage : $node->_desc(\@nodes);
787 Function: Performs recursion for Bio::Phylo::Forest::Node::get_descendants()
788 Returns : A Bio::Phylo::Forest::Node object.
789 Args : A Bio::Phylo::Forest::Node object.
790 Comments: This method works in conjunction with
791 Bio::Phylo::Forest::Node::get_descendants() - the latter simply calls
792 the former with a set of nodes, and the former returns their
793 children. Bio::Phylo::Forest::Node::get_descendants() then calls
794 Bio::Phylo::Forest::Node::_desc with this set of children, and so on
795 until all nodes are terminals. A first_daughter ->
796 next_sister postorder traversal in a single method would
797 have been more elegant - though not more efficient, in
798 terms of visited nodes.
799  
800 =end comment
801  
802 =cut
803  
804 7816 ▶ sub _desc {
Subroutine _desc: called CC=3 SCAR=11.0
805 7816 my $self = shift;
806 7816 my @current = @_;
807 7816 my @return;
808 7816 foreach (@current) {
809 40330 my $children = $_->get_children;
810 40330 ▶ if ($children) {
Branch: 1 branch
BranchTrueFalseTotal
if ($children) 40330 0 40330
811 40330 push @return, @{$children};
812 }
813 }
814 7816 return @return;
815 }
816  
817 =item get_terminals()
818  
819 Gets invocant's terminal descendants.
820  
821 Type : Query
822 Title : get_terminals
823 Usage : my @terminals = @{ $node->get_terminals };
824 Function: Returns an array reference
825 of terminal descendants.
826 Returns : Array reference of
827 Bio::Phylo::Forest::Node objects.
828 Args : NONE
829  
830 =cut
831  
832 562 ▶ sub get_terminals {
Subroutine get_terminals: called CC=2 SCAR=7.2
Pod documented
833 562 my $self = shift;
834 562 ▶ if ( $self->is_terminal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_terminal) { } 0 562 562
835 0 return [$self];
836 }
837 else {
838 562 return [ grep { $_->is_terminal } @{ $self->get_descendants } ];
839 }
840 }
841  
842 =item get_internals()
843  
844 Gets invocant's internal descendants.
845  
846 Type : Query
847 Title : get_internals
848 Usage : my @internals = @{ $node->get_internals };
849 Function: Returns an array reference
850 of internal descendants.
851 Returns : Array reference of
852 Bio::Phylo::Forest::Node objects.
853 Args : NONE
854  
855 =cut
856  
857 1 ▶ sub get_internals {
Subroutine get_internals: called CC=4 SCAR=13.9
Pod documented
858 1 my $self = shift;
859 1 my @internals;
860 1 my $desc = $self->get_descendants;
861 1 ▶ if ( @{$desc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$desc;}) 1 0 1
862 1 foreach ( @{$desc} ) {
863 14 ▶ if ( $_->is_internal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->is_internal) 6 8 14
864 6 push @internals, $_;
865 }
866 }
867 }
868 1 return \@internals;
869 }
870  
871 =item get_mrca()
872  
873 Gets invocant's most recent common ancestor shared with argument.
874  
875 Type : Query
876 Title : get_mrca
877 Usage : my $mrca = $node->get_mrca($other_node);
878 Function: Returns the most recent common ancestor
879 of $node and $other_node.
880 Returns : Bio::Phylo::Forest::Node
881 Args : A Bio::Phylo::Forest::Node
882 object in the same tree.
883  
884 =cut
885  
886 40 ▶ sub get_mrca {
Subroutine get_mrca: called CC=7 SCAR=19.5
Pod documented
887 40 my ( $self, $other_node ) = @_;
888 40 ▶ if ( $self->get_id == $other_node->get_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_id == $other_node->get_id) 7 33 40
889 7 return $self;
890 }
891 33 ▶ my $self_anc = $self->get_ancestors || [$self];
Condition50%1/2
$self->get_ancestors || [$self]
l!l
330
MC/DC0%0/1
$self->get_ancestors || [$self]
$self->get_ancestors
Truth table50%1/2
A
A= $self->get_ancestors
Aresult
11
00
892 33 ▶ my $other_anc = $other_node->get_ancestors || [$other_node];
Condition100%2/2
$other_node->get_ancestors || [$other_node]
l!l
321
MC/DC100%1/1
$other_node->get_ancestors || [$other_node]
$other_node->get_ancestors
Truth table100%2/2
A
A= $other_node->get_ancestors
Aresult
11
00
893 33 for my $i ( 0 .. $#{$self_anc} ) {
894 67 my $self_anc_id = $self_anc->[$i]->get_id;
895 67 for my $j ( 0 .. $#{$other_anc} ) {
896 200 ▶ if ( $self_anc_id == $other_anc->[$j]->get_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self_anc_id == $other_anc->[$j]->get_id) 32 168 200
897 32 return $self_anc->[$i];
898 }
899 }
900 }
901 1 return $self_anc->[-1];
902 }
903  
904 =item get_leftmost_terminal()
905  
906 Gets invocant's leftmost terminal descendant.
907  
908 Type : Query
909 Title : get_leftmost_terminal
910 Usage : my $leftmost_terminal =
911 $node->get_leftmost_terminal;
912 Function: Returns the leftmost
913 terminal descendant of $node.
914 Returns : Bio::Phylo::Forest::Node
915 Args : NONE
916  
917 =cut
918  
919 4 ▶ sub get_leftmost_terminal {
Subroutine get_leftmost_terminal: called CC=3 SCAR=11.0
Pod documented
920 4 my $self = shift;
921 4 my $daughter = $self;
922 4 ▶ FIRST_DAUGHTER: while ($daughter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($daughter) 10 0 10
923 10 ▶ if ( my $grand_daughter = $daughter->get_first_daughter ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $grand_daughter = $daughter->get_first_daughter) { } 6 4 10
924 6 $daughter = $grand_daughter;
925 6 next FIRST_DAUGHTER;
926 }
927 else {
928 4 last FIRST_DAUGHTER;
929 }
930 }
931 4 return $daughter;
932 }
933  
934 =item get_rightmost_terminal()
935  
936 Gets invocant's rightmost terminal descendant
937  
938 Type : Query
939 Title : get_rightmost_terminal
940 Usage : my $rightmost_terminal =
941 $node->get_rightmost_terminal;
942 Function: Returns the rightmost
943 terminal descendant of $node.
944 Returns : Bio::Phylo::Forest::Node
945 Args : NONE
946  
947 =cut
948  
949 4 ▶ sub get_rightmost_terminal {
Subroutine get_rightmost_terminal: called CC=3 SCAR=11.0
Pod documented
950 4 my $self = shift;
951 4 my $daughter = $self;
952 4 ▶ LAST_DAUGHTER: while ($daughter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($daughter) 20 0 20
953 20 ▶ if ( my $grand_daughter = $daughter->get_last_daughter ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $grand_daughter = $daughter->get_last_daughter) { } 16 4 20
954 16 $daughter = $grand_daughter;
955 16 next LAST_DAUGHTER;
956 }
957 else {
958 4 last LAST_DAUGHTER;
959 }
960 }
961 4 return $daughter;
962 }
963  
964 =item get_subtree()
965  
966 Returns the tree subtended by the invocant
967  
968 Type : Query
969 Title : get_subtree
970 Usage : my $tree = $node->get_subtree;
971 Function: Returns the tree subtended by the invocant
972 Returns : Bio::Phylo::Forest::Tree
973 Args : NONE
974  
975 =cut
976  
977 0 ▶ sub get_subtree {
Subroutine get_subtree: not called CC=1 SCAR=6.9
Pod documented
978 0 my $self = shift;
979 0 my $tree = $fac->create_tree;
980 $self->visit_depth_first(
981 0 ▶ '-pre' => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
982 0 my $node = shift;
983 0 my $clone = $node->clone;
984 0 $node->set_generic( 'clone' => $clone );
985 0 $tree->insert($clone);
986 0 ▶ if ( my $parent = $node->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $node->get_parent) 0 0 0
987 0 ▶ if ( my $pclone = $parent->get_generic('clone') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pclone = $parent->get_generic('clone')) { } 0 0 0
988 0 $clone->set_parent($pclone);
989 }
990 else {
991 0 $clone->set_parent;
992 }
993 }
994 },
995 0 ▶ '-post' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
996 0 my $node = shift;
997 0 my $gen = $node->get_generic;
998 0 delete $gen->{'clone'};
999 }
1000 0 );
1001 0 return $tree->_analyze;
1002 }
1003  
1004 =item get_subtrees()
1005  
1006 Returns the subtree rooted at the common ancestor of u and v, and the respective
1007 subtrees that contain u and v
1008  
1009 Type : Query
1010 Title : get_subtrees
1011 Usage : my ( $found_u, $found_v, $subtree, $subtree_u, $subtree_v ) = $root->get_subtrees($u,$v);
1012 Function: Returns the tree subtended by the invocant
1013 Returns : A list containing the following variables:
1014 - boolean: did we find u
1015 - boolean: did we find v
1016 - Bio::Phylo::Forest::Node - the root node of the connecting subtree
1017 - Bio::Phylo::Forest::Node - the root node of the subtree for $u
1018 - Bio::Phylo::Forest::Node - the root node of the subtree for $v
1019 Args : Two nodes, $u and $v
1020 Comments: This is a recursive method that is used by the RANKPROB calculations (see
1021 below). Typically you would invoke this method on the root node of the tree
1022 containing $u and $v, and the method then recurses up the tree. The tree must
1023 be bifurcating, or an exception is thrown.
1024  
1025 =cut
1026  
1027 1904 ▶ sub get_subtrees {
Subroutine get_subtrees: called CC=21 SCAR=30.4
Pod documented
1028 1904 my ($node,$u,$v) = @_;
1029
1030 # node is terminal
1031 1904 my @child = @{ $node->get_children };
1032 1904 ▶ if ( not @child ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @child) { } 1008 896 1904
elsif (@child != 2) { } 0 896 896
1033 1008 return undef, undef, undef, undef, undef;
1034 }
1035 elsif ( @child != 2 ) {
1036 0 throw 'BadArgs' => "Tree must be bifurcating";
1037 }
1038
1039 # recurse left and right
1040 896 my ( $found_ul, $found_vl, $subtree_l, $subtree_ul, $subtree_vl ) = $child[0]->get_subtrees( $u, $v );
1041 896 my ( $found_ur, $found_vr, $subtree_r, $subtree_ur, $subtree_vr ) = $child[1]->get_subtrees( $u, $v );
1042
1043 # both were left descendants of focal node, return result
1044 896 ▶ if ( $found_ul and $found_vl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found_ul and $found_vl) 16 880 896
Condition100%3/3
$found_ul and $found_vl
!ll&&!rl&&r
7988216
MC/DC100%2/2
$found_ul and $found_vl
$found_ul $found_vl
Truth table100%3/3
A and B
A= $found_ulB= $found_vl
ABresult
0X0
100
111
1045 16 return $found_ul, $found_vl, $subtree_l, $subtree_ul, $subtree_vl;
1046 }
1047
1048 # both were right descendants of focal node, return result
1049 880 ▶ if ( $found_ur and $found_vr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found_ur and $found_vr) 24 856 880
Condition100%3/3
$found_ur and $found_vr
!ll&&!rl&&r
7966024
MC/DC100%2/2
$found_ur and $found_vr
$found_ur $found_vr
Truth table100%3/3
A and B
A= $found_urB= $found_vr
ABresult
0X0
100
111
1050 24 return $found_ur, $found_vr, $subtree_r, $subtree_ur, $subtree_vr;
1051 }
1052
1053 # have we found either?
1054 856 ▶ my $found_u = ( $found_ul or $found_ur or $node->is_equal($u) );
Condition100%6/6
$found_ul || $found_ur || $node->is_equal($u)
l!l&&r!l&&!r
142112602
$found_ul or $found_ur
l!l&&r!l&&!r
8260714
MC/DC100%3/3
$found_ul || $found_ur || $node->is_equal($u)
$found_ul $found_ur $node->is_equal($u)
Truth table100%4/4
A or B || C
A= $found_ulB= $found_urC= $node->is_equal($u)
ABCresult
1XX1
01X1
0011
0000
1055 856 ▶ my $found_v = ( $found_vl or $found_vr or $node->is_equal($v) );
Condition100%6/6
$found_vl || $found_vr || $node->is_equal($v)
l!l&&r!l&&!r
142112602
$found_vl or $found_vr
l!l&&r!l&&!r
8260714
MC/DC100%3/3
$found_vl || $found_vr || $node->is_equal($v)
$found_vl $found_vr $node->is_equal($v)
Truth table100%4/4
A or B || C
A= $found_vlB= $found_vrC= $node->is_equal($v)
ABCresult
1XX1
01X1
0011
0000
1056
1057 # initialize and assign subtrees
1058 856 my ( $subtree_u, $subtree_v );
1059 856 ▶ $subtree_u = $subtree_ul if $found_ul;
Branch: 1 branch
BranchTrueFalseTotal
if $found_ul 82 774 856
1060 856 ▶ $subtree_v = $subtree_vl if $found_vl;
Branch: 1 branch
BranchTrueFalseTotal
if $found_vl 82 774 856
1061 856 ▶ $subtree_u = $subtree_ur if $found_ur;
Branch: 1 branch
BranchTrueFalseTotal
if $found_ur 60 796 856
1062 856 ▶ $subtree_v = $subtree_vr if $found_vr;
Branch: 1 branch
BranchTrueFalseTotal
if $found_vr 60 796 856
1063 856 ▶ if ( $found_u and (not $found_v) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($found_u and not $found_v) { } 142 714 856
elsif ($found_v and not $found_u) { } 142 1032 1174
Condition100%3/3
$found_u and not $found_v
!ll&&!rl&&r
602112142
MC/DC100%2/2
$found_u and not $found_v
$found_u not $found_v
Truth table100%3/3
A and not(B)
A= $found_uB= not $found_v
ABresult
0X0
100
111
1064 142 $subtree_u = $node;
1065 }
1066 ▶ elsif ( $found_v and (not $found_u) ) {
Condition100%3/3
$found_v and not $found_u
!ll&&!rl&&r
460112142
MC/DC100%2/2
$found_v and not $found_u
$found_v not $found_u
Truth table100%3/3
A and not(B)
A= $found_vB= not $found_u
ABresult
0X0
100
111
1067 142 $subtree_v = $node;
1068 }
1069 856 ▶ $subtree_u = $node if $node->is_equal($u);
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_equal($u) 112 744 856
1070 856 ▶ $subtree_v = $node if $node->is_equal($v);
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_equal($v) 112 744 856
1071
1072 # return results
1073 856 return $found_u, $found_v, $node, $subtree_u, $subtree_v;
1074 }
1075  
1076 =back
1077  
1078 =head2 TESTS
1079  
1080 =over
1081  
1082 =item is_terminal()
1083  
1084 Tests if invocant is a terminal node.
1085  
1086 Type : Test
1087 Title : is_terminal
1088 Usage : if ( $node->is_terminal ) {
1089 # do something
1090 }
1091 Function: Returns true if node has
1092 no children (i.e. is terminal).
1093 Returns : BOOLEAN
1094 Args : NONE
1095  
1096 =cut
1097  
1098 37483 ▶ sub is_terminal {
Subroutine is_terminal: called CC=1 SCAR=0.0
Pod documented
1099 37483 return !shift->get_first_daughter;
1100 }
1101  
1102 =item is_internal()
1103  
1104 Tests if invocant is an internal node.
1105  
1106 Type : Test
1107 Title : is_internal
1108 Usage : if ( $node->is_internal ) {
1109 # do something
1110 }
1111 Function: Returns true if node
1112 has children (i.e. is internal).
1113 Returns : BOOLEAN
1114 Args : NONE
1115  
1116 =cut
1117  
1118 147 ▶ sub is_internal {
Subroutine is_internal: called CC=1 SCAR=0.0
Pod documented
1119 147 return !!shift->get_first_daughter;
1120 }
1121  
1122 =item is_preterminal()
1123  
1124 Tests if all direct descendents are terminal
1125  
1126 Type : Test
1127 Title : is_preterminal
1128 Usage : if ( $node->is_preterminal ) {
1129 # do something
1130 }
1131 Function: Returns true if all direct descendents are terminal
1132 Returns : BOOLEAN
1133 Args : NONE
1134  
1135 =cut
1136  
1137 9 ▶ sub is_preterminal {
Subroutine is_preterminal: called CC=3 SCAR=11.0
Pod documented
1138 9 my $self = shift;
1139 9 my $children = $self->get_children;
1140 9 for my $child ( @{$children} ) {
1141 11 ▶ return 0 if $child->is_internal;
Branch: 1 branch
BranchTrueFalseTotal
if $child->is_internal 1 10 11
1142 }
1143 8 return !!scalar @{$children};
1144 }
1145  
1146 =item is_first()
1147  
1148 Tests if invocant is first sibling in left-to-right order.
1149  
1150 Type : Test
1151 Title : is_first
1152 Usage : if ( $node->is_first ) {
1153 # do something
1154 }
1155 Function: Returns true if first sibling
1156 in left-to-right order.
1157 Returns : BOOLEAN
1158 Args : NONE
1159  
1160 =cut
1161  
1162 0 ▶ sub is_first {
Subroutine is_first: not called CC=1 SCAR=6.9
Pod documented
1163 0 return !shift->get_previous_sister;
1164 }
1165  
1166 =item is_last()
1167  
1168 Tests if invocant is last sibling in left-to-right order.
1169  
1170 Type : Test
1171 Title : is_last
1172 Usage : if ( $node->is_last ) {
1173 # do something
1174 }
1175 Function: Returns true if last sibling
1176 in left-to-right order.
1177 Returns : BOOLEAN
1178 Args : NONE
1179  
1180 =cut
1181  
1182 0 ▶ sub is_last {
Subroutine is_last: not called CC=1 SCAR=6.9
Pod documented
1183 0 return !shift->get_next_sister;
1184 }
1185  
1186 =item is_root()
1187  
1188 Tests if invocant is a root.
1189  
1190 Type : Test
1191 Title : is_root
1192 Usage : if ( $node->is_root ) {
1193 # do something
1194 }
1195 Function: Returns true if node is a root
1196 Returns : BOOLEAN
1197 Args : NONE
1198  
1199 =cut
1200  
1201 528 ▶ sub is_root {
Subroutine is_root: called CC=1 SCAR=0.0
Pod documented
1202 528 return !shift->get_parent;
1203 }
1204  
1205 =item is_descendant_of()
1206  
1207 Tests if invocant is descendant of argument.
1208  
1209 Type : Test
1210 Title : is_descendant_of
1211 Usage : if ( $node->is_descendant_of($grandparent) ) {
1212 # do something
1213 }
1214 Function: Returns true if the node is
1215 a descendant of the argument.
1216 Returns : BOOLEAN
1217 Args : putative ancestor - a
1218 Bio::Phylo::Forest::Node object.
1219  
1220 =cut
1221  
1222 9203 ▶ sub is_descendant_of {
Subroutine is_descendant_of: called CC=4 SCAR=13.9
Pod documented
1223 9203 my ( $self, $ancestor ) = @_;
1224 9203 my $ancestor_id = $ancestor->get_id;
1225 9203 ▶ while ($self) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self) 126961 0 126961
1226 126961 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) { } 117761 9200 126961
1227 117761 $self = $parent;
1228 }
1229 else {
1230 9200 return;
1231 }
1232 117761 ▶ if ( $self->get_id == $ancestor_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_id == $ancestor_id) 3 117758 117761
1233 3 return 1;
1234 }
1235 }
1236 }
1237  
1238 =item is_ancestor_of()
1239  
1240 Tests if invocant is ancestor of argument.
1241  
1242 Type : Test
1243 Title : is_ancestor_of
1244 Usage : if ( $node->is_ancestor_of($grandchild) ) {
1245 # do something
1246 }
1247 Function: Returns true if the node
1248 is an ancestor of the argument.
1249 Returns : BOOLEAN
1250 Args : putative descendant - a
1251 Bio::Phylo::Forest::Node object.
1252  
1253 =cut
1254  
1255 9202 ▶ sub is_ancestor_of {
Subroutine is_ancestor_of: called CC=2 SCAR=6.9
Pod documented
1256 9202 my ( $self, $child ) = @_;
1257 9202 ▶ if ( $child->is_descendant_of($self) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->is_descendant_of($self)) { } 3 9199 9202
1258 3 return 1;
1259 }
1260 else {
1261 9199 return;
1262 }
1263 }
1264  
1265 =item is_sister_of()
1266  
1267 Tests if invocant is sister of argument.
1268  
1269 Type : Test
1270 Title : is_sister_of
1271 Usage : if ( $node->is_sister_of($sister) ) {
1272 # do something
1273 }
1274 Function: Returns true if the node is
1275 a sister of the argument.
1276 Returns : BOOLEAN
1277 Args : putative sister - a
1278 Bio::Phylo::Forest::Node object.
1279  
1280 =cut
1281  
1282 4 ▶ sub is_sister_of {
Subroutine is_sister_of: called CC=4 SCAR=13.9
Pod documented
1283 4 my ( $self, $sister ) = @_;
1284 4 my ( $self_parent, $sister_parent ) =
1285 ( $self->get_parent, $sister->get_parent );
1286 4 ▶ if ( $self_parent
Branch: 1 branch
BranchTrueFalseTotal
if ($self_parent and $sister_parent and $self_parent->get_id == $sister_parent->get_id) { } 1 3 4
Condition100%6/6
$self_parent and $sister_parent and $self_parent->get_id == $sister_parent->get_id
!ll&&!rl&&r
211
$self_parent and $sister_parent
!ll&&!rl&&r
112
MC/DC100%3/3
$self_parent and $sister_parent and $self_parent->get_id == $sister_parent->get_id
$self_parent $sister_parent $self_parent->get_id == $sister_parent->get_id
Truth table100%4/4
A and B and C
A= $self_parentB= $sister_parentC= $self_parent->get_id == $sister_parent->get_id
ABCresult
0XX0
10X0
1100
1111
1287 && $sister_parent
1288 && $self_parent->get_id == $sister_parent->get_id )
1289 {
1290 1 return 1;
1291 }
1292 else {
1293 3 return;
1294 }
1295 }
1296  
1297 =item is_child_of()
1298  
1299 Tests if invocant is child of argument.
1300  
1301 Type : Test
1302 Title : is_child_of
1303 Usage : if ( $node->is_child_of($parent) ) {
1304 # do something
1305 }
1306 Function: Returns true if the node is
1307 a child of the argument.
1308 Returns : BOOLEAN
1309 Args : putative parent - a
1310 Bio::Phylo::Forest::Node object.
1311  
1312 =cut
1313  
1314 9508 ▶ sub is_child_of {
Subroutine is_child_of: called CC=2 SCAR=6.9
Pod documented
1315 9508 my ( $self, $node ) = @_;
1316 9508 ▶ if ( my $parent = $self->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $self->get_parent) 588 8920 9508
1317 588 return $parent->get_id == $node->get_id;
1318 }
1319 8920 return 0;
1320 }
1321  
1322 =item is_outgroup_of()
1323  
1324 Test if invocant is outgroup of argument nodes.
1325  
1326 Type : Test
1327 Title : is_outgroup_of
1328 Usage : if ( $node->is_outgroup_of(\@ingroup) ) {
1329 # do something
1330 }
1331 Function: Tests whether the set of
1332 \@ingroup is monophyletic
1333 with respect to the $node.
1334 Returns : BOOLEAN
1335 Args : A reference to an array of
1336 Bio::Phylo::Forest::Node objects;
1337 Comments: This method is essentially the same as
1338 &Bio::Phylo::Forest::Tree::is_monophyletic.
1339  
1340 =cut
1341  
1342 2 ▶ sub is_outgroup_of {
Subroutine is_outgroup_of: called CC=4 SCAR=13.9
Pod documented
1343 2 my ( $outgroup, $nodes ) = @_;
1344 2 for my $i ( 0 .. $#{$nodes} ) {
1345 3 for my $j ( ( $i + 1 ) .. $#{$nodes} ) {
1346 2 my $mrca = $nodes->[$i]->get_mrca( $nodes->[$j] );
1347 2 ▶ return if $mrca->is_ancestor_of($outgroup);
Branch: 1 branch
BranchTrueFalseTotal
if $mrca->is_ancestor_of($outgroup) 1 1 2
1348 }
1349 }
1350 1 return 1;
1351 }
1352  
1353 =item can_contain()
1354  
1355 Test if argument(s) can be a child/children of invocant.
1356  
1357 Type : Test
1358 Title : can_contain
1359 Usage : if ( $parent->can_contain(@children) ) {
1360 # do something
1361 }
1362 Function: Test if arguments can be children of invocant.
1363 Returns : BOOLEAN
1364 Args : An array of Bio::Phylo::Forest::Node objects;
1365 Comments: This method is an override of
1366 Bio::Phylo::Listable::can_contain. Since node
1367 objects hold a list of their children, they
1368 inherit from the listable class and so they
1369 need to be able to validate the contents
1370 of that list before they are inserted.
1371  
1372 =cut
1373  
1374 18984 ▶ sub can_contain {
Subroutine can_contain: called CC=3 SCAR=11.1
Pod documented
1375 18984 my $self = shift;
1376 18984 my $type = $self->_type;
1377 18984 for (@_) {
1378 19004 ▶ return 0 if $type != $_->_type;
Branch: 1 branch
BranchTrueFalseTotal
if $type != $_->_type 0 19004 19004
1379 }
1380 18984 return 1;
1381 }
1382  
1383 =back
1384  
1385 =head2 CALCULATIONS
1386  
1387 =over
1388  
1389 =item calc_path_to_root()
1390  
1391 Calculates path to root.
1392  
1393 Type : Calculation
1394 Title : calc_path_to_root
1395 Usage : my $path_to_root =
1396 $node->calc_path_to_root;
1397 Function: Returns the sum of branch
1398 lengths from $node to the root.
1399 Returns : FLOAT
1400 Args : NONE
1401  
1402 =cut
1403  
1404 81 ▶ sub calc_path_to_root {
Subroutine calc_path_to_root: called CC=4 SCAR=13.9
Pod documented
1405 81 my $self = shift;
1406 81 my $node = $self;
1407 81 my $path = 0;
1408 81 ▶ while ($node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node) 379 0 379
1409 379 my $branch_length = $node->get_branch_length;
1410 379 ▶ if ( defined $branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch_length) 379 0 379
1411 379 $path += $branch_length;
1412 }
1413 379 ▶ if ( my $parent = $node->get_parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $node->get_parent) { } 298 81 379
1414 298 $node = $parent;
1415 }
1416 else {
1417 81 last;
1418 }
1419 }
1420 81 return $path;
1421 }
1422  
1423 =item calc_nodes_to_root()
1424  
1425 Calculates number of nodes to root.
1426  
1427 Type : Calculation
1428 Title : calc_nodes_to_root
1429 Usage : my $nodes_to_root =
1430 $node->calc_nodes_to_root;
1431 Function: Returns the number of nodes
1432 from $node to the root.
1433 Returns : INT
1434 Args : NONE
1435  
1436 =cut
1437  
1438 2 ▶ sub calc_nodes_to_root {
Subroutine calc_nodes_to_root: called CC=4 SCAR=13.9
Pod documented
1439 2 my $self = shift;
1440 2 my ( $nodes, $parent ) = ( 0, $self );
1441 2 ▶ while ($parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent) 2 1 3
1442 2 $nodes++;
1443 2 $parent = $parent->get_parent;
1444 2 ▶ if ($parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent) 1 1 2
1445 1 ▶ if ( my $cntr = $parent->calc_nodes_to_root ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cntr = $parent->calc_nodes_to_root) 1 0 1
1446 1 $nodes += $cntr;
1447 1 last;
1448 }
1449 }
1450 }
1451 2 return $nodes;
1452 }
1453  
1454 =item calc_max_nodes_to_tips()
1455  
1456 Calculates maximum number of nodes to tips.
1457  
1458 Type : Calculation
1459 Title : calc_max_nodes_to_tips
1460 Usage : my $max_nodes_to_tips =
1461 $node->calc_max_nodes_to_tips;
1462 Function: Returns the maximum number
1463 of nodes from $node to tips.
1464 Returns : INT
1465 Args : NONE
1466  
1467 =cut
1468  
1469 1 ▶ sub calc_max_nodes_to_tips {
Subroutine calc_max_nodes_to_tips: called CC=5 SCAR=16.1
Pod documented
1470 1 my $self = shift;
1471 1 my $self_id = $self->get_id;
1472 1 my ( $nodes, $maxnodes ) = ( 0, 0 );
1473 1 foreach my $child ( @{ $self->get_terminals } ) {
1474 8 $nodes = 0;
1475 8 ▶ while ( $child && $child->get_id != $self_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child and $child->get_id != $self_id) 35 8 43
Condition66%2/3
$child and $child->get_id != $self_id
!ll&&!rl&&r
0835
MC/DC50%1/2
$child and $child->get_id != $self_id
$child $child->get_id != $self_id
Truth table66%2/3
A and B
A= $childB= $child->get_id != $self_id
ABresult
0X0
100
111
1476 35 $nodes++;
1477 35 $child = $child->get_parent;
1478 }
1479 8 ▶ if ( $nodes > $maxnodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nodes > $maxnodes) 7 1 8
1480 7 $maxnodes = $nodes;
1481 }
1482 }
1483 1 return $maxnodes;
1484 }
1485  
1486 =item calc_min_nodes_to_tips()
1487  
1488 Calculates minimum number of nodes to tips.
1489  
1490 Type : Calculation
1491 Title : calc_min_nodes_to_tips
1492 Usage : my $min_nodes_to_tips =
1493 $node->calc_min_nodes_to_tips;
1494 Function: Returns the minimum number of
1495 nodes from $node to tips.
1496 Returns : INT
1497 Args : NONE
1498  
1499 =cut
1500  
1501 2 ▶ sub calc_min_nodes_to_tips {
Subroutine calc_min_nodes_to_tips: called CC=6 SCAR=18.0
Pod documented
1502 2 my $self = shift;
1503 2 my $self_id = $self->get_id;
1504 2 my ( $nodes, $minnodes );
1505 2 foreach my $child ( @{ $self->get_terminals } ) {
1506 34 $nodes = 0;
1507 34 ▶ while ( $child && $child->get_id != $self_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child and $child->get_id != $self_id) 166 34 200
Condition66%2/3
$child and $child->get_id != $self_id
!ll&&!rl&&r
034166
MC/DC50%1/2
$child and $child->get_id != $self_id
$child $child->get_id != $self_id
Truth table66%2/3
A and B
A= $childB= $child->get_id != $self_id
ABresult
0X0
100
111
1508 166 $nodes++;
1509 166 $child = $child->get_parent;
1510 }
1511 34 ▶ if ( !$minnodes || $nodes < $minnodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $minnodes or $nodes < $minnodes) 2 32 34
Condition66%2/3
not $minnodes or $nodes < $minnodes
l!l&&r!l&&!r
2032
MC/DC50%1/2
not $minnodes or $nodes < $minnodes
not $minnodes $nodes < $minnodes
Truth table66%2/3
not(A) or B
A= not $minnodesB= $nodes < $minnodes
ABresult
1X1
011
000
1512 2 $minnodes = $nodes;
1513 }
1514 }
1515 2 return $minnodes;
1516 }
1517  
1518 =item calc_max_path_to_tips()
1519  
1520 Calculates longest path to tips.
1521  
1522 Type : Calculation
1523 Title : calc_max_path_to_tips
1524 Usage : my $max_path_to_tips =
1525 $node->calc_max_path_to_tips;
1526 Function: Returns the path length from
1527 $node to the tallest tip.
1528 Returns : FLOAT
1529 Args : NONE
1530  
1531 =cut
1532  
1533 2 ▶ sub calc_max_path_to_tips {
Subroutine calc_max_path_to_tips: called CC=6 SCAR=17.9
Pod documented
1534 2 my $self = shift;
1535 2 my $id = $self->get_id;
1536 2 my ( $length, $maxlength ) = ( 0, 0 );
1537 2 foreach my $child ( @{ $self->get_terminals } ) {
1538 16 $length = 0;
1539 16 ▶ while ( $child && $child->get_id != $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child and $child->get_id != $id) 68 16 84
Condition66%2/3
$child and $child->get_id != $id
!ll&&!rl&&r
01668
MC/DC50%1/2
$child and $child->get_id != $id
$child $child->get_id != $id
Truth table66%2/3
A and B
A= $childB= $child->get_id != $id
ABresult
0X0
100
111
1540 68 my $branch_length = $child->get_branch_length;
1541 68 ▶ if ( defined $branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch_length) 35 33 68
1542 35 $length += $branch_length;
1543 }
1544 68 $child = $child->get_parent;
1545 }
1546 16 ▶ if ( $length > $maxlength ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $maxlength) 7 9 16
1547 7 $maxlength = $length;
1548 }
1549 }
1550 2 return $maxlength;
1551 }
1552  
1553 =item calc_min_path_to_tips()
1554  
1555 Calculates shortest path to tips.
1556  
1557 Type : Calculation
1558 Title : calc_min_path_to_tips
1559 Usage : my $min_path_to_tips =
1560 $node->calc_min_path_to_tips;
1561 Function: Returns the path length from
1562 $node to the shortest tip.
1563 Returns : FLOAT
1564 Args : NONE
1565  
1566 =cut
1567  
1568 2 ▶ sub calc_min_path_to_tips {
Subroutine calc_min_path_to_tips: called CC=7 SCAR=19.6
Pod documented
1569 2 my $self = shift;
1570 2 my $id = $self->get_id;
1571 2 my ( $length, $minlength );
1572 2 foreach my $child ( @{ $self->get_terminals } ) {
1573 16 $length = 0;
1574 16 ▶ while ( $child && $child->get_id != $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child and $child->get_id != $id) 68 16 84
Condition66%2/3
$child and $child->get_id != $id
!ll&&!rl&&r
01668
MC/DC50%1/2
$child and $child->get_id != $id
$child $child->get_id != $id
Truth table66%2/3
A and B
A= $childB= $child->get_id != $id
ABresult
0X0
100
111
1575 68 my $branch_length = $child->get_branch_length;
1576 68 ▶ if ( defined $branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch_length) 35 33 68
1577 35 $length += $branch_length;
1578 }
1579 68 $child = $child->get_parent;
1580 }
1581 16 ▶ if ( !$minlength ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($minlength) 9 7 16
1582 9 $minlength = $length;
1583 }
1584 16 ▶ if ( $length < $minlength ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length < $minlength) 0 16 16
1585 0 $minlength = $length;
1586 }
1587 }
1588 2 return $minlength;
1589 }
1590  
1591 =item calc_patristic_distance()
1592  
1593 Calculates patristic distance between invocant and argument.
1594  
1595 Type : Calculation
1596 Title : calc_patristic_distance
1597 Usage : my $patristic_distance =
1598 $node->calc_patristic_distance($other_node);
1599 Function: Returns the patristic distance
1600 between $node and $other_node.
1601 Returns : FLOAT
1602 Args : Bio::Phylo::Forest::Node
1603  
1604 =cut
1605  
1606 19 ▶ sub calc_patristic_distance {
Subroutine calc_patristic_distance: called CC=6 SCAR=17.9
Pod documented
1607 19 my ( $self, $other_node ) = @_;
1608 19 my $patristic_distance = 0;
1609 19 my $mrca = $self->get_mrca($other_node);
1610 19 my $mrca_id = $mrca->get_id;
1611 19 ▶ while ( $self->get_id != $mrca_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_id != $mrca_id) 38 19 57
1612 38 my $branch_length = $self->get_branch_length;
1613 38 ▶ if ( defined $branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch_length) 37 1 38
1614 37 $patristic_distance += $branch_length;
1615 }
1616 38 $self = $self->get_parent;
1617 }
1618 19 ▶ while ( $other_node and $other_node->get_id != $mrca_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other_node and $other_node->get_id != $mrca_id) 48 19 67
Condition66%2/3
$other_node and $other_node->get_id != $mrca_id
!ll&&!rl&&r
01948
MC/DC50%1/2
$other_node and $other_node->get_id != $mrca_id
$other_node $other_node->get_id != $mrca_id
Truth table66%2/3
A and B
A= $other_nodeB= $other_node->get_id != $mrca_id
ABresult
0X0
100
111
1619 48 my $branch_length = $other_node->get_branch_length;
1620 48 ▶ if ( defined $branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch_length) 43 5 48
1621 43 $patristic_distance += $branch_length;
1622 }
1623 48 $other_node = $other_node->get_parent;
1624 }
1625 19 return $patristic_distance;
1626 }
1627  
1628 =item calc_nodal_distance()
1629  
1630 Calculates node distance between invocant and argument.
1631  
1632 Type : Calculation
1633 Title : calc_nodal_distance
1634 Usage : my $nodal_distance =
1635 $node->calc_nodal_distance($other_node);
1636 Function: Returns the number of nodes
1637 between $node and $other_node.
1638 Returns : INT
1639 Args : Bio::Phylo::Forest::Node
1640  
1641 =cut
1642  
1643 9 ▶ sub calc_nodal_distance {
Subroutine calc_nodal_distance: called CC=5 SCAR=16.1
Pod documented
1644 9 my ( $self, $other_node ) = @_;
1645 9 my $nodal_distance = 0;
1646 9 my $mrca = $self->get_mrca($other_node);
1647 9 my $mrca_id = $mrca->get_id;
1648 9 ▶ while ( $self and $self->get_id != $mrca_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self and $self->get_id != $mrca_id) 18 9 27
Condition66%2/3
$self and $self->get_id != $mrca_id
!ll&&!rl&&r
0918
MC/DC50%1/2
$self and $self->get_id != $mrca_id
$self $self->get_id != $mrca_id
Truth table66%2/3
A and B
A= $selfB= $self->get_id != $mrca_id
ABresult
0X0
100
111
1649 18 $nodal_distance++;
1650 18 $self = $self->get_parent;
1651 }
1652 9 ▶ while ( $other_node and $other_node->get_id != $mrca_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other_node and $other_node->get_id != $mrca_id) 21 9 30
Condition66%2/3
$other_node and $other_node->get_id != $mrca_id
!ll&&!rl&&r
0921
MC/DC50%1/2
$other_node and $other_node->get_id != $mrca_id
$other_node $other_node->get_id != $mrca_id
Truth table66%2/3
A and B
A= $other_nodeB= $other_node->get_id != $mrca_id
ABresult
0X0
100
111
1653 21 $nodal_distance++;
1654 21 $other_node = $other_node->get_parent;
1655 }
1656 9 return $nodal_distance;
1657 }
1658  
1659 =item calc_terminals()
1660  
1661 Calculates number of terminals subtended by the invocant
1662  
1663 Type : Calculation
1664 Title : calc_terminals
1665 Usage : my $ntips = $node->calc_terminals;
1666 Function: Returns the number of terminals subtended by the invocant
1667 Returns : INT
1668 Args : None
1669  
1670 =cut
1671
1672 236 ▶ sub calc_terminals {
Subroutine calc_terminals: called CC=1 SCAR=0.0
Pod documented
1673 236 my $self = shift;
1674 236 my $tips = 0;
1675 236 ▶ $self->visit_level_order( sub { $tips++ if shift->is_terminal } );
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (shift())->is_terminal 704 468 1172
1676 236 return $tips;
1677 }
1678  
1679 =item calc_rankprob_tipcounts()
1680  
1681 Recurses from the root to the tips, returns an array reference at every step whose
1682 first element is a boolean set to true once the query node has been seen. The second
1683 element is an array that contains the number of subtended leaves - 1 for the query
1684 node and for all sisters of the nodes on the path from the query to the root. This
1685 method is used by the RANKPROB calculations (see below)
1686  
1687 Type : Calculation
1688 Title : calc_rankprob_tipcounts
1689 Usage : my @rp = @{ $root->calc_rankprob_tipcounts($node) };
1690 Function: Returns tip counts for RANKPROB
1691 Returns : ARRAY
1692 Args : NONE
1693  
1694 =cut
1695  
1696 358 ▶sub calc_rankprob_tipcounts {
Subroutine calc_rankprob_tipcounts: called CC=7 SCAR=19.6
Pod documented
1697 358 my ($node,$u) = @_;
1698
1699 # focal node (subtree) is empty, i.e. a leaf
1700 358 my @child = @{ $node->get_children };
1701 358 ▶ return [undef,undef] if not @child;
Branch: 1 branch
BranchTrueFalseTotal
unless @child 108 250 358
1702 250 ▶ return [ 1, [ $node->calc_terminals - 1 ] ] if $node->is_equal($u);
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_equal($u) 84 166 250
1703
1704 # recurse left
1705 166 my $x = $child[0]->calc_rankprob_tipcounts( $u );
1706 166 ▶ if ( $x->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->[0]) 58 108 166
1707 58 my $n;
1708
1709 # focal node has no sibling
1710 58 ▶ if ( not $child[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $child[1]) { } 0 58 58
1711 0 $n = 0;
1712 }
1713 else {
1714 58 $n = $child[1]->calc_terminals - 1;
1715 }
1716 58 return [ 1, [ @{ $x->[1] }, $n ] ];
1717 }
1718  
1719 # recurse right
1720 108 my $y = $child[1]->calc_rankprob_tipcounts( $u );
1721 108 ▶ if ( $y->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y->[0]) { } 34 74 108
1722 34 my $n;
1723
1724 # focal node has no sibling
1725 34 ▶ if ( not $child[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $child[0]) { } 0 34 34
1726 0 $n = 0;
1727 }
1728 else {
1729 34 $n = $child[0]->calc_terminals - 1;
1730 }
1731 34 return [ 1, [ @{ $y->[1] }, $n ] ];
1732 }
1733
1734 # $u is neither left or right from here
1735 else {
1736 74 return [undef,undef];
1737 }
1738 }
1739  
1740 =item calc_rankprob()
1741  
1742 Calculates the probabilities for all rank orderings that the invocant node can
1743 occupy among all possible labeled histories. Uses Stadler's RANKPROB algorithm as
1744 described in:
1745  
1746 B<Gernhard, T.> et al., 2006. Estimating the relative order of speciation
1747 or coalescence events on a given phylogeny. I<Evolutionary Bioinformatics Online>.
1748 B<2>:285. L<http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2674681/>.
1749  
1750 Type : Calculation
1751 Title : calc_rankprob
1752 Usage : my @rp = @{ $root->calc_rankprob($node) };
1753 Function: Returns the rank probabilities of the invocant node
1754 Returns : ARRAY, indices are ranks, values are probabilities
1755 Args : NONE
1756  
1757 =cut
1758  
1759 76 ▶sub calc_rankprob {
Subroutine calc_rankprob: called CC=6 SCAR=17.9
Pod documented
1760 76 my ($t,$u) = @_;
1761 76 my $x = $t->calc_rankprob_tipcounts($u);
1762 76 $x = $x->[1];
1763 76 my $lhsm = $x->[0];
1764 76 my $k = scalar(@$x);
1765 76 my $start = 1;
1766 76 my $end = 1;
1767 76 my $rp = [0,1];
1768 76 my $step = 1;
1769 76 ▶ while ( $step < $k ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($step < $k) 68 76 144
1770 68 my $rhsm = $x->[$step];
1771 68 my $newstart = $start+1;
1772 68 my $newend = $end + $rhsm + 1;
1773 68 my $rp2 = [];
1774 68 for my $i ( 0 .. $newend ) {
1775 336 push @$rp2, 0;
1776 }
1777 68 for my $i ( $newstart .. $newend ) {
1778 180 my $q = max( 0, $i - 1 - $end );
1779 180 for my $j ( $q .. min( $rhsm, $i - 2 ) ) {
1780 266 my $a = $rp->[$i-$j-1] * nchoose($lhsm + $rhsm - ($i-1),$rhsm-$j) * nchoose($i-2,$j);
1781 266 $rp2->[$i]+=$a;
1782 }
1783 }
1784 68 $rp = $rp2;
1785 68 $start = $newstart;
1786 68 $end = $newend;
1787 68 $lhsm = $lhsm+$rhsm+1;
1788 68 $step += 1;
1789 }
1790 76 my $tot = sum( @{ $rp } );
1791 76 for my $i ( 0..$#{ $rp } ) {
1792 320 $rp->[$i] = $rp->[$i] / $tot;
1793 }
1794 76 return $rp;
1795 }
1796  
1797 =item calc_expected_rank()
1798  
1799 Calculates the expected rank and variance that the invocant node occupies among all
1800 possible labeled histories. Uses Stadler's RANKPROB algorithm as described in:
1801  
1802 B<Gernhard, T.> et al., 2006. Estimating the relative order of speciation
1803 or coalescence events on a given phylogeny. I<Evolutionary Bioinformatics Online>.
1804 B<2>:285. L<http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2674681/>.
1805  
1806 Type : Calculation
1807 Title : calc_expected_rank
1808 Usage : my ( $rank, $variance ) = $root->calc_expected_rank($node);
1809 Function: Calculates expected rank and variance
1810 Returns : Two numbers: rank and variance
1811 Args : NONE
1812  
1813 =cut
1814  
1815 8 ▶sub calc_expected_rank {
Subroutine calc_expected_rank: called CC=2 SCAR=6.9
Pod documented
1816 8 my ( $t, $u ) = @_;
1817 8 my $rp = $t->calc_rankprob( $u );
1818 8 my $mu = 0;
1819 8 my $sigma = 0;
1820 8 for my $i ( 0 .. $#{ $rp } ) {
1821 59 $mu += $i * $rp->[$i];
1822 59 $sigma += $i * $i * $rp->[$i];
1823 }
1824 8 return $mu, $sigma - $mu * $mu;
1825 }
1826  
1827 =item calc_rankprob_compare()
1828  
1829 Calculates the probability that the argument node is below the invocant node over all
1830 possible labeled histories. Uses Stadler's COMPARE algorithm as described in:
1831  
1832 B<Gernhard, T.> et al., 2006. Estimating the relative order of speciation
1833 or coalescence events on a given phylogeny. I<Evolutionary Bioinformatics Online>.
1834 B<2>:285. L<http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2674681/>.
1835  
1836 Type : Calculation
1837 Title : calc_rankprob_compare
1838 Usage : my $prob = $root->calc_rankprob_compare($u,$v);
1839 Function: Compares rankings of nodes
1840 Returns : A number (probability)
1841 Args : Bio::Phylo::Forest::Node
1842  
1843 =cut
1844  
1845 56 ▶sub calc_rankprob_compare {
Subroutine calc_rankprob_compare: called CC=9 SCAR=22.2
Pod documented
1846 56 my ($t,$u,$v) = @_;
1847 56 my ($found_u,$found_v,$root,$root_u,$root_v) = $t->get_subtrees($u,$v);
1848
1849 # both vertices need to occur in the same tree, of course
1850 56 ▶ if ( not ($found_u and $found_v) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found_u and $found_v) 0 56 56
Condition33%1/3
$found_u and $found_v
!ll&&!rl&&r
0056
MC/DC0%0/2
$found_u and $found_v
$found_u $found_v
Truth table33%1/3
A and B
A= $found_uB= $found_v
ABresult
0X0
100
111
1851 0 print "This tree does not have those vertices!";
1852 0 return 0;
1853 }
1854
1855 # If either one is the root node of the
1856 # subtree that connects them then their
1857 # relative rankings are certain.
1858 56 ▶ return 1.0 if $root->is_equal($u);
Branch: 1 branch
BranchTrueFalseTotal
if $root->is_equal($u) 13 43 56
1859 43 ▶ return 0.0 if $root->is_equal($v);
Branch: 1 branch
BranchTrueFalseTotal
if $root->is_equal($v) 13 30 43
1860  
1861 # calculate rank probabilities in
1862 # respective subtrees
1863 30 my $x = $root_u->calc_rankprob($u);
1864 30 my $y = $root_v->calc_rankprob($v);
1865 30 my $usize = $root_u->calc_terminals - 1;
1866 30 my $vsize = $root_v->calc_terminals - 1;
1867
1868 30 for my $i ( scalar(@$x) .. $usize + 1 ) {
1869 51 push @$x, 0;
1870 }
1871 30 my $xcumulative = [0];
1872 30 for my $i ( 1 .. $#{ $x } ) {
1873 122 push @$xcumulative, $xcumulative->[$i-1] + $x->[$i];
1874 }
1875 30 my $rp = [0];
1876 30 for my $i ( 1 .. $#{ $y } ) {
1877 71 push @$rp, 0;
1878 71 for my $j ( 1 .. $usize) {
1879 229 my $a = $y->[$i] * nchoose($i-1+$j,$j) * nchoose($vsize-$i+$usize-$j, $usize-$j) * $xcumulative->[$j];
1880 229 $rp->[$i] += $a;
1881 }
1882 }
1883 30 my $tot = nchoose($usize+$vsize,$vsize);
1884 30 return sum(@$rp)/$tot;
1885 }
1886  
1887 =back
1888  
1889 =head2 VISITOR METHODS
1890  
1891 The methods below are similar in spirit to those by the same name in L<Bio::Phylo::Forest::Tree>,
1892 except those in the tree class operate from the tree root, and those in this node class operate
1893 on an invocant node, and so these process a subtree.
1894  
1895 =over
1896  
1897 =item visit_depth_first()
1898  
1899 Visits nodes depth first
1900  
1901 Type : Visitor method
1902 Title : visit_depth_first
1903 Usage : $tree->visit_depth_first( -pre => sub{ ... }, -post => sub { ... } );
1904 Function: Visits nodes in a depth first traversal, executes subs
1905 Returns : $tree
1906 Args : Optional:
1907 # first event handler, is executed when node is reached in recursion
1908 -pre => sub { print "pre: ", shift->get_name, "\n" },
1909
1910 # is executed if node has a daughter, but before that daughter is processed
1911 -pre_daughter => sub { print "pre_daughter: ", shift->get_name, "\n" },
1912
1913 # is executed if node has a daughter, after daughter has been processed
1914 -post_daughter => sub { print "post_daughter: ", shift->get_name, "\n" },
1915
1916 # is executed if node has no daughter
1917 -no_daughter => sub { print "no_daughter: ", shift->get_name, "\n" },
1918  
1919 # is executed whether or not node has sisters, if it does have sisters
1920 # they're processed first
1921 -in => sub { print "in: ", shift->get_name, "\n" },
1922  
1923 # is executed if node has a sister, before sister is processed
1924 -pre_sister => sub { print "pre_sister: ", shift->get_name, "\n" },
1925
1926 # is executed if node has a sister, after sister is processed
1927 -post_sister => sub { print "post_sister: ", shift->get_name, "\n" },
1928
1929 # is executed if node has no sister
1930 -no_sister => sub { print "no_sister: ", shift->get_name, "\n" },
1931
1932 # is executed last
1933 -post => sub { print "post: ", shift->get_name, "\n" },
1934
1935 # specifies traversal order, default 'ltr' means first_daugher -> next_sister
1936 # traversal, alternate value 'rtl' means last_daughter -> previous_sister traversal
1937 -order => 'ltr', # ltr = left-to-right, 'rtl' = right-to-left
1938
1939 # passes sister node as second argument to pre_sister and post_sister subs,
1940 # and daughter node as second argument to pre_daughter and post_daughter subs
1941 -with_relatives => 1 # or any other true value
1942 Comments:
1943  
1944 =cut
1945  
1946 #$tree->visit_depth_first(
1947 # '-pre' => sub { print "pre: ", shift->get_name, "\n" },
1948 # '-pre_daughter' => sub { print "pre_daughter: ", shift->get_name, "\n" },
1949 # '-post_daughter' => sub { print "post_daughter: ", shift->get_name, "\n" },
1950 # '-in' => sub { print "in: ", shift->get_name, "\n" },
1951 # '-pre_sister' => sub { print "pre_sister: ", shift->get_name, "\n" },
1952 # '-post_sister' => sub { print "post_sister: ", shift->get_name, "\n" },
1953 # '-post' => sub { print "post: ", shift->get_name, "\n" },
1954 # '-order' => 'ltr',
1955 #);
1956 153 ▶ sub visit_depth_first {
Subroutine visit_depth_first: called CC=3 SCAR=12.3
Pod documented
1957 153 my $self = shift;
1958 153 my %args = looks_like_hash @_;
1959  
1960 # my @keys = qw(pre pre_daughter post_daughter in pre_sister post_sister post order with_relatives);
1961 # my %permitted_keys = map { "-${_}" => 1 } @keys;
1962 # for my $key ( keys %args ) {
1963 # if ( not exists $permitted_keys{$key} ) {
1964 # throw 'BadArgs' => "Can't use argument $key";
1965 # }
1966 # if ( $key ne "-with_relatives" or $key ne "-order" ) {
1967 # if ( not looks_like_instance $args{$key}, 'CODE' ) {
1968 # throw 'BadArgs' => "Argument $key must be a code reference";
1969 # }
1970 # }
1971 # }
1972 153 ▶ if ( $args{'-order'} and $args{'-order'} =~ /^rtl$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'-order'} and $args{'-order'} =~ /^rtl$/i) { } 0 153 153
Condition33%1/3
$args{"-order"} and $args{"-order"} =~ /^rtl$/i
!ll&&!rl&&r
15300
MC/DC0%0/2
$args{"-order"} and $args{"-order"} =~ /^rtl$/i
$args{"-order"} $args{"-order"} =~ /^rtl$/i
Truth table33%1/3
A and B
A= $args{"-order"}B= $args{"-order"} =~ /^rtl$/i
ABresult
0X0
100
111
1973 0 $args{'-sister_method'} = 'get_previous_sister';
1974 0 $args{'-daughter_method'} = 'get_last_daughter';
1975 }
1976 else {
1977 153 $args{'-sister_method'} = 'get_next_sister';
1978 153 $args{'-daughter_method'} = 'get_first_daughter';
1979 }
1980 153 $self->_visit_depth_first(%args);
1981 152 return $self;
1982 }
1983  
1984 4597 ▶ sub _visit_depth_first {
Subroutine _visit_depth_first: called CC=14 SCAR=26.9
1985 4597 my ( $node, %args ) = @_;
1986 my ( $daughter_method, $sister_method ) =
1987 4597 @args{qw(-daughter_method -sister_method)};
1988 4597 ▶ $args{'-pre'}->($node) if $args{'-pre'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-pre"} 1215 3382 4597
1989 4597 ▶ if ( my $daughter = $node->$daughter_method ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $daughter = $node->$daughter_method) { } 2168 2429 4597
1990 2168 my @args = ($node);
1991 2168 ▶ push @args, $daughter if $args{'-with_relatives'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-with_relatives"} 0 2168 2168
1992 2168 ▶ $args{'-pre_daughter'}->(@args) if $args{'-pre_daughter'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-pre_daughter"} 0 2168 2168
1993 2168 $daughter->_visit_depth_first(%args);
1994 2163 ▶ $args{'-post_daughter'}->(@args) if $args{'-post_daughter'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-post_daughter"} 7 2156 2163
1995 }
1996 else {
1997 2429 ▶ $args{'-no_daughter'}->($node) if $args{'-no_daughter'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-no_daughter"} 10 2419 2429
1998 }
1999 4592 ▶ $args{'-in'}->($node) if $args{'-in'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-in"} 0 4592 4592
2000 4592 ▶ if ( my $sister = $node->$sister_method ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sister = $node->$sister_method) { } 2276 2316 4592
2001 2276 my @args = ($node);
2002 2276 ▶ push @args, $sister if $args{'-with_relatives'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-with_relatives"} 0 2276 2276
2003 2276 ▶ $args{'-pre_sister'}->(@args) if $args{'-pre_sister'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-pre_sister"} 0 2276 2276
2004 2276 $sister->_visit_depth_first(%args);
2005 2272 ▶ $args{'-post_sister'}->(@args) if $args{'-post_sister'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-post_sister"} 0 2272 2272
2006 }
2007 else {
2008 2316 ▶ $args{'-no_sister'}->($node) if $args{'-no_sister'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-no_sister"} 0 2316 2316
2009 }
2010 4588 ▶ $args{'-post'}->($node) if $args{'-post'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-post"} 3373 1215 4588
2011 }
2012  
2013 =item visit_breadth_first()
2014  
2015 Visits nodes breadth first
2016  
2017 Type : Visitor method
2018 Title : visit_breadth_first
2019 Usage : $tree->visit_breadth_first( -pre => sub{ ... }, -post => sub { ... } );
2020 Function: Visits nodes in a breadth first traversal, executes handlers
2021 Returns : $tree
2022 Args : Optional handlers in the order in which they would be executed on an internal node:
2023
2024 # first event handler, is executed when node is reached in recursion
2025 -pre => sub { print "pre: ", shift->get_name, "\n" },
2026
2027 # is executed if node has a sister, before sister is processed
2028 -pre_sister => sub { print "pre_sister: ", shift->get_name, "\n" },
2029
2030 # is executed if node has a sister, after sister is processed
2031 -post_sister => sub { print "post_sister: ", shift->get_name, "\n" },
2032
2033 # is executed if node has no sister
2034 -no_sister => sub { print "no_sister: ", shift->get_name, "\n" },
2035
2036 # is executed whether or not node has sisters, if it does have sisters
2037 # they're processed first
2038 -in => sub { print "in: ", shift->get_name, "\n" },
2039
2040 # is executed if node has a daughter, but before that daughter is processed
2041 -pre_daughter => sub { print "pre_daughter: ", shift->get_name, "\n" },
2042
2043 # is executed if node has a daughter, after daughter has been processed
2044 -post_daughter => sub { print "post_daughter: ", shift->get_name, "\n" },
2045
2046 # is executed if node has no daughter
2047 -no_daughter => sub { print "no_daughter: ", shift->get_name, "\n" },
2048
2049 # is executed last
2050 -post => sub { print "post: ", shift->get_name, "\n" },
2051
2052 # specifies traversal order, default 'ltr' means first_daugher -> next_sister
2053 # traversal, alternate value 'rtl' means last_daughter -> previous_sister traversal
2054 -order => 'ltr', # ltr = left-to-right, 'rtl' = right-to-left
2055 Comments:
2056  
2057 =cut
2058  
2059 0 ▶ sub visit_breadth_first {
Subroutine visit_breadth_first: not called CC=3 SCAR=24.8
Pod documented
2060 0 my $self = shift;
2061 0 my %args = looks_like_hash @_;
2062 0 ▶ if ( $args{'-order'} and $args{'-order'} =~ /rtl/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'-order'} and $args{'-order'} =~ /rtl/i) { } 0 0 0
Condition0%0/3
$args{"-order"} and $args{"-order"} =~ /rtl/i
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"-order"} and $args{"-order"} =~ /rtl/i
$args{"-order"} $args{"-order"} =~ /rtl/i
Truth table0%0/3
A and B
A= $args{"-order"}B= $args{"-order"} =~ /rtl/i
ABresult
0X0
100
111
2063 0 $args{'-sister_method'} = 'get_previous_sister';
2064 0 $args{'-daughter_method'} = 'get_last_daughter';
2065 }
2066 else {
2067 0 $args{'-sister_method'} = 'get_next_sister';
2068 0 $args{'-daughter_method'} = 'get_first_daughter';
2069 }
2070 0 $self->_visit_breadth_first(%args);
2071 0 return $self;
2072 }
2073  
2074 0 ▶ sub _visit_breadth_first {
Subroutine _visit_breadth_first: not called CC=12 SCAR=50.5
2075 0 my ( $node, %args ) = @_;
2076 my ( $daughter_method, $sister_method ) =
2077 0 @args{qw(-daughter_method -sister_method)};
2078 0 ▶ $args{'-pre'}->($node) if $args{'-pre'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-pre"} 0 0 0
2079 0 ▶ if ( my $sister = $node->$sister_method ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sister = $node->$sister_method) { } 0 0 0
2080 0 ▶ $args{'-pre_sister'}->($node) if $args{'-pre_sister'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-pre_sister"} 0 0 0
2081 0 $sister->_visit_breadth_first(%args);
2082 0 ▶ $args{'-post_sister'}->($node) if $args{'-post_sister'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-post_sister"} 0 0 0
2083 }
2084 else {
2085 0 ▶ $args{'-no_sister'}->($node) if $args{'-no_sister'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-no_sister"} 0 0 0
2086 }
2087 0 ▶ $args{'-in'}->($node) if $args{'-in'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-in"} 0 0 0
2088 0 ▶ if ( my $daughter = $node->$daughter_method ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $daughter = $node->$daughter_method) { } 0 0 0
2089 0 ▶ $args{'-pre_daughter'}->($node) if $args{'-pre_daughter'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-pre_daughter"} 0 0 0
2090 0 $daughter->_visit_breadth_first(%args);
2091 0 ▶ $args{'-post_daughter'}->($node) if $args{'-post_daughter'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-post_daughter"} 0 0 0
2092 }
2093 else {
2094 0 ▶ $args{'-no_daughter'}->($node) if $args{'-no_daughter'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-no_daughter"} 0 0 0
2095 }
2096 0 ▶ $args{'-post'}->($node) if $args{'-post'};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-post"} 0 0 0
2097 }
2098  
2099 =item visit_level_order()
2100  
2101 Visits nodes in a level order traversal.
2102  
2103 Type : Visitor method
2104 Title : visit_level_order
2105 Usage : $tree->visit_level_order( sub{...} );
2106 Function: Visits nodes in a level order traversal, executes sub
2107 Returns : $tree
2108 Args : A subroutine reference that operates on visited nodes.
2109 Comments:
2110  
2111 =cut
2112  
2113 360 ▶ sub visit_level_order {
Subroutine visit_level_order: called CC=4 SCAR=14.1
Pod documented
2114 360 my ( $self, $sub ) = @_;
2115 360 ▶ if ( looks_like_instance $sub, 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_instance($sub, 'CODE')) { } 360 0 360
2116 360 my @queue = ($self);
2117 360 ▶ while (@queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (@queue) 5582 360 5942
2118 5582 my $node = shift @queue;
2119 5582 $sub->($node);
2120 5582 ▶ if ( my $children = $node->get_children ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $children = $node->get_children) 5582 0 5582
2121 5582 push @queue, @{$children};
2122 }
2123 }
2124 }
2125 else {
2126 0 throw 'BadArgs' => "'$sub' not a CODE reference";
2127 }
2128 360 return $self;
2129 }
2130  
2131 =back
2132  
2133 =head2 SERIALIZERS
2134  
2135 =over
2136  
2137 =item to_xml()
2138  
2139 Serializes invocant to xml.
2140  
2141 Type : Serializer
2142 Title : to_xml
2143 Usage : my $xml = $obj->to_xml;
2144 Function: Turns the invocant object (and its descendants )into an XML string.
2145 Returns : SCALAR
2146 Args : NONE
2147  
2148 =cut
2149  
2150 0 ▶ sub to_xml {
Subroutine to_xml: not called CC=7 SCAR=40.3
Pod documented
2151 0 my $self = shift;
2152 0 my @nodes = ( $self, @{ $self->get_descendants } );
2153 0 my $xml = '';
2154  
2155 # first write out the node elements
2156 0 for my $node (@nodes) {
2157 0 ▶ if ( my $taxon = $node->get_taxon ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $taxon = $node->get_taxon) 0 0 0
2158 0 $node->set_attributes( 'otu' => $taxon->get_xml_id );
2159 }
2160 0 ▶ if ( $node->is_root ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_root) 0 0 0
2161 0 $node->set_attributes( 'root' => 'true' );
2162 }
2163 0 $xml .= "\n" . $node->get_xml_tag(1);
2164 }
2165  
2166 # then the rootedge?
2167 0 ▶ if ( my $length = shift(@nodes)->get_branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $length = shift(@nodes)->get_branch_length) 0 0 0
2168 0 my $edge = $fac->create_xmlwritable(
2169 '-tag' => 'rootedge',
2170 '-attributes' => {
2171 'target' => $self->get_xml_id,
2172 'id' => "edge" . $self->get_id,
2173 'length' => $length
2174 }
2175 );
2176 0 $xml .= "\n" . $edge->get_xml_tag(1);
2177 }
2178  
2179 # then the subtended edges
2180 0 for my $node (@nodes) {
2181 0 my $length = $node->get_branch_length;
2182 0 my $edge = $fac->create_xmlwritable(
2183 '-tag' => 'edge',
2184 '-attributes' => {
2185 'source' => $node->get_parent->get_xml_id,
2186 'target' => $node->get_xml_id,
2187 'id' => "edge" . $node->get_id
2188 }
2189 );
2190 0 ▶ $edge->set_attributes( 'length' => $length ) if defined $length;
Branch: 1 branch
BranchTrueFalseTotal
if defined $length 0 0 0
2191 0 $xml .= "\n" . $edge->get_xml_tag(1);
2192 }
2193 0 return $xml;
2194 }
2195  
2196 =item to_newick()
2197  
2198 Serializes subtree subtended by invocant to newick string.
2199  
2200 Type : Serializer
2201 Title : to_newick
2202 Usage : my $newick = $obj->to_newick;
2203 Function: Turns the invocant object into a newick string.
2204 Returns : SCALAR
2205 Args : takes same arguments as Bio::Phylo::Unparsers::Newick
2206 Comments: takes same arguments as Bio::Phylo::Unparsers::Newick
2207  
2208 =cut
2209  
2210 {
2211 34 my ( $root_id, $string );
2212  
2213 #no warnings 'uninitialized';
2214 3400 ▶ sub to_newick {
Subroutine to_newick: called CC=29 SCAR=37.3
Pod documented
2215 3400 my $node = shift;
2216 3400 my %args = @_;
2217 3400 ▶ $root_id = $node->get_id if not $root_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $root_id 29 3371 3400
2218 3400 my $blformat = '%f';
2219  
2220 # first create the name
2221 3400 my $name;
2222 3400 ▶ if ( $node->is_terminal or $args{'-nodelabels'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_terminal or $args{"-nodelabels"}) 3189 211 3400
Condition100%3/3
$node->is_terminal or $args{"-nodelabels"}
l!l&&r!l&&!r
17301459211
MC/DC100%2/2
$node->is_terminal or $args{"-nodelabels"}
$node->is_terminal $args{"-nodelabels"}
Truth table100%3/3
A or B
A= $node->is_terminalB= $args{"-nodelabels"}
ABresult
1X1
011
000
2223 3189 ▶ if ( ref $args{'-nodelabels'} and ref($args{'-nodelabels'}) eq 'CODE' ) {
Branch: 4 branches
BranchTrueFalseTotal
if (ref $args{'-nodelabels'} and ref $args{'-nodelabels'} eq 'CODE') { } 35 3154 3189
elsif (not $args{'-tipnames'}) { } 3154 0 3154
elsif ($args{'-tipnames'} =~ /^internal$/i) { } 0 0 0
elsif ($args{'-tipnames'} =~ /^taxon/i and $node->get_taxon) { } 0 0 0
Condition66%2/3
ref $args{"-nodelabels"} and ref $args{"-nodelabels"} eq "CODE"
!ll&&!rl&&r
3154035
MC/DC50%1/2
ref $args{"-nodelabels"} and ref $args{"-nodelabels"} eq "CODE"
ref $args{"-nodelabels"} ref $args{"-nodelabels"} eq "CODE"
Truth table66%2/3
A and B
A= ref $args{"-nodelabels"}B= ref $args{"-nodelabels"} eq "CODE"
ABresult
0X0
100
111
2224 35 my $id;
2225 35 ▶ if ( $node->is_terminal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_terminal) { } 18 17 35
2226 18 $id = $args{'-translate'}->{$node->get_nexus_name};
2227 }
2228 else {
2229 17 $id = $node->get_name;
2230 }
2231 35 $name = $args{'-nodelabels'}->($node,$id);
2232 }
2233 elsif ( not $args{'-tipnames'} ) {
2234 3154 $name = $node->get_nexus_name(1);
2235 }
2236 elsif ( $args{'-tipnames'} =~ /^internal$/i ) {
2237 0 $name = $node->get_nexus_name(1);
2238 }
2239 ▶ elsif ( $args{'-tipnames'} =~ /^taxon/i and $node->get_taxon ) {
Condition0%0/3
$args{"-tipnames"} =~ /^taxon/i and $node->get_taxon
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"-tipnames"} =~ /^taxon/i and $node->get_taxon
$args{"-tipnames"} =~ /^taxon/i $node->get_taxon
Truth table0%0/3
A and B
A= $args{"-tipnames"} =~ /^taxon/iB= $node->get_taxon
ABresult
0X0
100
111
2240 0 ▶ if ( $args{'-tipnames'} =~ /^taxon_internal$/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'-tipnames'} =~ /^taxon_internal$/i) { } 0 0 0
elsif ($args{'-tipnames'} =~ /^taxon$/i) { } 0 0 0
2241 0 $name = $node->get_taxon->get_nexus_name(1);
2242 }
2243 elsif ( $args{'-tipnames'} =~ /^taxon$/i ) {
2244 0 $name = $node->get_taxon->get_nexus_name(1);
2245 }
2246 }
2247 else {
2248 0 $name = $node->get_generic( $args{'-tipnames'} );
2249 }
2250 3189 ▶ if ( $args{'-translate'}
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"-translate"} and exists $args{"-translate"}{$name}) 0 3189 3189
Condition66%2/3
$args{"-translate"} and exists $args{"-translate"}{$name}
!ll&&!rl&&r
3154350
MC/DC0%0/2
$args{"-translate"} and exists $args{"-translate"}{$name}
$args{"-translate"} exists $args{"-translate"}{$name}
Truth table66%2/3
A and B
A= $args{"-translate"}B= exists $args{"-translate"}{$name}
ABresult
0X0
100
111
2251 and exists $args{'-translate'}->{$name} )
2252 {
2253 0 $name = $args{'-translate'}->{$name};
2254 }
2255 }
2256  
2257 # now format branch length
2258 3400 my $branch_length;
2259 3400 ▶ if ( defined( $branch_length = $node->get_branch_length ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($branch_length = $node->get_branch_length)) 3168 232 3400
2260 3168 ▶ if ( $args{'-blformat'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"-blformat"}) 0 3168 3168
2261 0 $blformat = $args{'-blformat'};
2262 }
2263 3168 $branch_length = sprintf $blformat, $branch_length;
2264 }
2265  
2266 # now format nhx
2267 3400 my $nhx;
2268 3400 ▶ if ( $args{'-nhxkeys'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"-nhxkeys"}) 215 3185 3400
2269 215 my ( $sep, $sp );
2270 215 ▶ if ( $args{'-nhxstyle'} =~ /^mesquite$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'-nhxstyle'} =~ /^mesquite$/i) { } 0 215 215
2271 0 $sep = ',';
2272 0 $nhx = '[%';
2273 0 $sp = ' ';
2274 }
2275 else {
2276 215 $sep = ':';
2277 215 $nhx = '[&&NHX:';
2278 215 $sp = '';
2279 }
2280 215 my @nhx;
2281 215 for my $i ( 0 .. $#{ $args{'-nhxkeys'} } ) {
2282 860 my $key = $args{'-nhxkeys'}->[$i];
2283 860 my $value = $node->get_generic($key);
2284 860 ▶ push @nhx, "$sp$key$sp=$sp$value$sp" if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 625 235 860
2285 }
2286 215 ▶ if (@nhx) {
Branch: 1 branch
BranchTrueFalseTotal
if (@nhx) { } 215 0 215
2287 215 $nhx .= join $sep, @nhx;
2288 215 $nhx .= ']';
2289 }
2290 else {
2291 0 $nhx = '';
2292 }
2293 }
2294  
2295 # recurse further
2296 3400 ▶ if ( my $first_daughter = $node->get_first_daughter ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $first_daughter = $node->get_first_daughter) 1670 1730 3400
2297 1670 $string .= '(';
2298 1670 $first_daughter->to_newick(%args);
2299 }
2300  
2301 # append to growing newick string
2302 3400 ▶ $string .= ')' if $node->get_first_daughter;
Branch: 1 branch
BranchTrueFalseTotal
if $node->get_first_daughter 1670 1730 3400
2303 3400 ▶ $string .= $name if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 3189 211 3400
2304 3400 ▶ $string .= ':' . $branch_length if defined $branch_length;
Branch: 1 branch
BranchTrueFalseTotal
if defined $branch_length 3168 232 3400
2305 3400 ▶ $string .= $nhx if $nhx;
Branch: 1 branch
BranchTrueFalseTotal
if $nhx 215 3185 3400
2306 3400 ▶ if ( $root_id == $node->get_id ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($root_id == $node->get_id) { } 29 3371 3400
elsif (my $next_sister = $node->get_next_sister) { } 1701 1670 3371
2307 29 undef $root_id;
2308 29 my $result = $string . ';';
2309 29 undef $string;
2310 29 return $result;
2311 }
2312  
2313 # recurse further
2314 elsif ( my $next_sister = $node->get_next_sister ) {
2315 1701 $string .= ',';
2316 1701 $next_sister->to_newick(%args);
2317 }
2318 else {
2319 #$string .= ')';
2320 }
2321 }
2322 }
2323  
2324 =item to_dom()
2325  
2326 Type : Serializer
2327 Title : to_dom
2328 Usage : $node->to_dom($dom)
2329 Function: Generates an array of DOM elements from the invocant's
2330 descendants
2331 Returns : an array of Element objects
2332 Args : DOM factory object
2333  
2334 =cut
2335  
2336 34 ▶ sub to_dom {
Subroutine to_dom: not called CC=9 SCAR=44.3
Pod documented
2337 0 my ( $self, $dom ) = shift;
2338 0 ▶ $dom ||= $Bio::Phylo::NeXML::DOM::DOM;
Condition0%0/3
$dom ||= $Bio::Phylo::NeXML::DOM::DOM
l!l&&r!l&&!r
000
MC/DC0%0/2
$dom ||= $Bio::Phylo::NeXML::DOM::DOM
$dom $Bio::Phylo::NeXML::DOM::DOM
Truth table0%0/3
A ||= B
A= $domB= $Bio::Phylo::NeXML::DOM::DOM
ABresult
1X1
011
000
2339 0 ▶ unless ( looks_like_object $dom, _DOMCREATOR_ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&looks_like_object($dom, 18)) 0 0 0
2340 0 throw 'BadArgs' => 'DOM factory object not provided';
2341 }
2342 0 my @nodes = ( $self, @{ $self->get_descendants } );
2343 0 my @elts;
2344  
2345 # first write out the node elements
2346 0 for my $node (@nodes) {
2347 0 ▶ if ( my $taxon = $node->get_taxon ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $taxon = $node->get_taxon) 0 0 0
2348 0 $node->set_attributes( 'otu' => $taxon->get_xml_id );
2349 }
2350 0 ▶ if ( $node->is_root ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_root) 0 0 0
2351 0 $node->set_attributes( 'root' => 'true' );
2352 }
2353 0 push @elts, $node->get_dom_elt($dom);
2354 }
2355  
2356 # then the rootedge?
2357 0 ▶ if ( my $length = shift(@nodes)->get_branch_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $length = shift(@nodes)->get_branch_length) 0 0 0
2358 0 my $target = $self->get_xml_id;
2359 0 my $id = "edge" . $self->get_id;
2360 0 my $elt = $dom->create_element(
2361 '-tag' => 'rootedge',
2362 '-attributes' => {
2363 'target' => $target,
2364 'id' => $id,
2365 'length' => $length,
2366 }
2367 );
2368 0 push @elts, $elt;
2369 }
2370  
2371 # then the subtended edges
2372 0 for my $node (@nodes) {
2373 0 my $source = $node->get_parent->get_xml_id;
2374 0 my $target = $node->get_xml_id;
2375 0 my $id = "edge" . $node->get_id;
2376 0 my $length = $node->get_branch_length;
2377 0 my $elt = $dom->create_element(
2378 '-tag' => 'edge',
2379 '-attributes' => {
2380 'source' => $source,
2381 'target' => $target,
2382 'id' => $id,
2383 }
2384 );
2385 0 ▶ $elt->set_attributes( 'length' => $length ) if ( defined $length );
Branch: 1 branch
BranchTrueFalseTotal
if defined $length 0 0 0
2386 0 push @elts, $elt;
2387 }
2388 0 return @elts;
2389 }
2390  
2391 =begin comment
2392  
2393 Type : Internal method
2394 Title : _type
2395 Usage : $node->_type;
2396 Function:
2397 Returns : CONSTANT
2398 Args :
2399  
2400 =end comment
2401  
2402 =cut
2403  
2404 57759 ▶ sub _type { $TYPE_CONSTANT }
Subroutine _type: called CC=1 SCAR=0.0
2405 2 ▶ sub _tag { 'node' }
Subroutine _tag: called CC=1 SCAR=0.0
2406  
2407 =begin comment
2408  
2409 Type : Internal method
2410 Title : _container
2411 Usage : $node->_container;
2412 Function:
2413 Returns : CONSTANT
2414 Args :
2415  
2416 =end comment
2417  
2418 =cut
2419  
2420 18588 ▶ sub _container { $CONTAINER_CONSTANT }
Subroutine _container: called CC=1 SCAR=0.0
2421  
2422 =back
2423  
2424 =cut
2425  
2426 # podinherit_insert_token
2427  
2428 =head1 SEE ALSO
2429  
2430 There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
2431 for any user or developer questions and discussions.
2432  
2433 =over
2434  
2435 =item L<Bio::Phylo::Taxa::TaxonLinker>
2436  
2437 This object inherits from L<Bio::Phylo::Taxa::TaxonLinker>, so methods
2438 defined there are also applicable here.
2439  
2440 =item L<Bio::Phylo::Listable>
2441  
2442 This object inherits from L<Bio::Phylo::Listable>, so methods
2443 defined there are also applicable here.
2444  
2445 =item L<Bio::Phylo::Manual>
2446  
2447 Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>.
2448  
2449 =back
2450  
2451 =head1 CITATION
2452  
2453 If you use Bio::Phylo in published research, please cite it:
2454  
2455 B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
2456 and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
2457 I<BMC Bioinformatics> B<12>:63.
2458 L<http://dx.doi.org/10.1186/1471-2105-12-63>
2459  
2460 =cut
2461  
2462 34 1;
2463 __DATA__
« Phylo/Matrices/Datum.pm ↑ Summary Phylo/NeXML/Meta/XMLLiteral.pm »