| 1 | # | ||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::TreeIO::TreeEventBuilder | ||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||
| 6 | # Cared for by Jason Stajich <jason@bioperl.org> | ||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||
| 8 | # Copyright Jason Stajich | ||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | Bio::TreeIO::TreeEventBuilder - Build Bio::Tree::Tree's and | ||||||||||||||||||||||||||||||||||
| 17 | Bio::Tree::Node's from Events | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | # internal use only | ||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | This object will take events and build a Bio::Tree::TreeI compliant | ||||||||||||||||||||||||||||||||||
| 26 | object makde up of Bio::Tree::NodeI objects. | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||
| 33 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||||
| 34 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||
| 37 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | =head2 Support | ||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||
| 41 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||
| 46 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||
| 47 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||
| 48 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||
| 53 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||||
| 54 | web: | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | =head1 AUTHOR - Jason Stajich | ||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | Email jason-at-bioperl.org | ||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||
| 65 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | # Let the code begin... | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | package Bio::TreeIO::TreeEventBuilder; | ||||||||||||||||||||||||||||||||||
| 74 | 28 | $Bio::TreeIO::TreeEventBuilder::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||
| 75 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | 28 | ▶ | use Bio::Tree::Tree; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 78 | 28 | ▶ | use Bio::Tree::Node; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 28 | ▶ | use base qw(Bio::Root::Root Bio::Event::EventHandlerI); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||
| 82 | =head2 new | ||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | Title : new | ||||||||||||||||||||||||||||||||||
| 85 | Usage : my $obj = Bio::TreeIO::TreeEventBuilder->new(); | ||||||||||||||||||||||||||||||||||
| 86 | Function: Builds a new Bio::TreeIO::TreeEventBuilder object | ||||||||||||||||||||||||||||||||||
| 87 | Returns : Bio::TreeIO::TreeEventBuilder | ||||||||||||||||||||||||||||||||||
| 88 | Args : | ||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | 185 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 94 | 185 | my($class,@args) = @_; | |||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | 185 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||
| 97 | 185 | my ($treetype, $nodetype) = $self->_rearrange([qw(TREETYPE | |||||||||||||||||||||||||||||||||
| 98 | NODETYPE)], @args); | ||||||||||||||||||||||||||||||||||
| 99 | 185 | ▶ | $treetype ||= 'Bio::Tree::Tree'; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$treetype ||= "Bio::Tree::Tree"
MC/DC100%1/1
$treetype ||= "Bio::Tree::Tree"
$treetype
Truth table100%2/2
A
A= $treetype
| |||||||||||||||||||||||||||||||||||
| 100 | 185 | ▶ | $nodetype ||= 'Bio::Tree::Node'; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$nodetype ||= "Bio::Tree::Node"
MC/DC100%1/1
$nodetype ||= "Bio::Tree::Node"
$nodetype
Truth table100%2/2
A
A= $nodetype
| |||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | 185 | eval { | |||||||||||||||||||||||||||||||||
| 103 | 185 | $self->_load_module($treetype); | |||||||||||||||||||||||||||||||||
| 104 | 185 | $self->_load_module($nodetype); | |||||||||||||||||||||||||||||||||
| 105 | }; | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | 185 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->throw("Could not load module $treetype or $nodetype. \n$@\n") | |||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||
| 110 | 185 | $self->treetype($treetype); | |||||||||||||||||||||||||||||||||
| 111 | 185 | $self->nodetype($nodetype); | |||||||||||||||||||||||||||||||||
| 112 | 185 | $self->{'_treelevel'} = 0; | |||||||||||||||||||||||||||||||||
| 113 | 185 | return $self; | |||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||
| 116 | =head2 treetype | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | Title : treetype | ||||||||||||||||||||||||||||||||||
| 119 | Usage : $obj->treetype($newval) | ||||||||||||||||||||||||||||||||||
| 120 | Function: | ||||||||||||||||||||||||||||||||||
| 121 | Returns : value of treetype | ||||||||||||||||||||||||||||||||||
| 122 | Args : newvalue (optional) | ||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | =cut | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | 303 | ▶ | sub treetype{ | ||||||||||||||||||||||||||||||||
|
Subroutine
treetype: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 128 | 303 | my ($self,$value) = @_; | |||||||||||||||||||||||||||||||||
| 129 | 303 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 130 | 185 | $self->{'treetype'} = $value; | |||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||
| 132 | 303 | return $self->{'treetype'}; | |||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | =head2 nodetype | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | Title : nodetype | ||||||||||||||||||||||||||||||||||
| 138 | Usage : $obj->nodetype($newval) | ||||||||||||||||||||||||||||||||||
| 139 | Function: | ||||||||||||||||||||||||||||||||||
| 140 | Returns : value of nodetype | ||||||||||||||||||||||||||||||||||
| 141 | Args : newvalue (optional) | ||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||
| 144 | =cut | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | 4708 | ▶ | sub nodetype{ | ||||||||||||||||||||||||||||||||
|
Subroutine
nodetype: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 147 | 4708 | my ($self,$value) = @_; | |||||||||||||||||||||||||||||||||
| 148 | 4708 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 149 | 185 | $self->{'nodetype'} = $value; | |||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | 4708 | return $self->{'nodetype'}; | |||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | =head2 SAX methods | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | =head2 start_document | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | Title : start_document | ||||||||||||||||||||||||||||||||||
| 162 | Usage : $handler->start_document | ||||||||||||||||||||||||||||||||||
| 163 | Function: Begins a Tree event cycle | ||||||||||||||||||||||||||||||||||
| 164 | Returns : none | ||||||||||||||||||||||||||||||||||
| 165 | Args : none | ||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | =cut | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | 118 | ▶ | sub start_document { | ||||||||||||||||||||||||||||||||
|
Subroutine
start_document: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 170 | 118 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 171 | 118 | $self->{'_lastitem'} = {}; | |||||||||||||||||||||||||||||||||
| 172 | 118 | $self->{'_currentitems'} = []; | |||||||||||||||||||||||||||||||||
| 173 | 118 | $self->{'_currentnodes'} = []; | |||||||||||||||||||||||||||||||||
| 174 | 118 | return; | |||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | =head2 end_document | ||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | Title : end_document | ||||||||||||||||||||||||||||||||||
| 180 | Usage : my @trees = $parser->end_document | ||||||||||||||||||||||||||||||||||
| 181 | Function: Finishes a Phylogeny cycle | ||||||||||||||||||||||||||||||||||
| 182 | Returns : An array Bio::Tree::TreeI | ||||||||||||||||||||||||||||||||||
| 183 | Args : none | ||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||
| 187 | 118 | ▶ | sub end_document { | ||||||||||||||||||||||||||||||||
|
Subroutine
end_document: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 188 | 118 | my ($self,$label) = @_; | |||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | 118 | my ($root) = @{$self->{'_currentnodes'}}; | |||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | 118 | $self->debug("Root node is " . $root->to_string()."\n"); | |||||||||||||||||||||||||||||||||
| 193 | 118 | ▶ | if( $self->verbose > 0 ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 194 | 0 | foreach my $node ( $root->get_Descendents ) { | |||||||||||||||||||||||||||||||||
| 195 | 0 | $self->debug("node is ". $node->to_string(). "\n"); | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||
| 198 | 118 | my $tree = $self->treetype->new(-verbose => $self->verbose, | |||||||||||||||||||||||||||||||||
| 199 | -root => $root); | ||||||||||||||||||||||||||||||||||
| 200 | 118 | return $tree; | |||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | =head2 start_element | ||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||
| 205 | Title : start_element | ||||||||||||||||||||||||||||||||||
| 206 | Usage : | ||||||||||||||||||||||||||||||||||
| 207 | Function: | ||||||||||||||||||||||||||||||||||
| 208 | Example : | ||||||||||||||||||||||||||||||||||
| 209 | Returns : | ||||||||||||||||||||||||||||||||||
| 210 | Args : $data => hashref with key 'Name' | ||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | =cut | ||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||
| 214 | 13254 | ▶ | sub start_element{ | ||||||||||||||||||||||||||||||||
|
Subroutine
start_element: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 215 | 13254 | my ($self,$data) =@_; | |||||||||||||||||||||||||||||||||
| 216 | 13254 | $self->{'_lastitem'}->{$data->{'Name'}}++; | |||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | 13254 | $self->debug("starting element: $data->{Name}\n"); | |||||||||||||||||||||||||||||||||
| 219 | 13254 | push @{$self->{'_lastitem'}->{'current'}},$data->{'Name'}; | |||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | 13254 | my %data; | |||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||
| 223 | 13254 | ▶ | if( $data->{'Name'} eq 'node' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 224 | 4523 | push @{$self->{'_currentitems'}}, \%data; | |||||||||||||||||||||||||||||||||
| 225 | 4523 | $self->{'_treelevel'}++; | |||||||||||||||||||||||||||||||||
| 226 | } elsif ( $data->{Name} eq 'tree' ) { | ||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | =head2 end_element | ||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | Title : end_element | ||||||||||||||||||||||||||||||||||
| 233 | Usage : | ||||||||||||||||||||||||||||||||||
| 234 | Function: | ||||||||||||||||||||||||||||||||||
| 235 | Returns : none | ||||||||||||||||||||||||||||||||||
| 236 | Args : $data => hashref with key 'Name' | ||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | =cut | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | 13254 | ▶ | sub end_element{ | ||||||||||||||||||||||||||||||||
|
Subroutine
end_element: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 241 | 13254 | my ($self,$data) = @_; | |||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | 13254 | $self->debug("end of element: $data->{Name}\n"); | |||||||||||||||||||||||||||||||||
| 244 | # this is the stack where we push/pop items from it | ||||||||||||||||||||||||||||||||||
| 245 | 13254 | my $curcount = scalar @{$self->{'_currentnodes'}}; | |||||||||||||||||||||||||||||||||
| 246 | 13254 | my $level = $self->{'_treelevel'}; | |||||||||||||||||||||||||||||||||
| 247 | 13254 | ▶ | my $levelct = $self->{'_nodect'}->[$self->{'_treelevel'}+1] || 0; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'_nodect'}[$self->{'_treelevel'} + 1] || 0
MC/DC100%1/1
$self->{'_nodect'}[$self->{'_treelevel'} + 1] || 0
$self->{'_nodect'}[$self->{'_treelevel'} + 1]
Truth table100%2/2
A
A= $self->{'_nodect'}[$self->{'_treelevel'} + 1]
| |||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | 13254 | ▶ | if( $data->{'Name'} eq 'node' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 250 | 4523 | my $tnode; | |||||||||||||||||||||||||||||||||
| 251 | 4523 | my $node = pop @{$self->{'_currentitems'}}; | |||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | $tnode = $self->nodetype->new( -verbose => $self->verbose, | ||||||||||||||||||||||||||||||||||
| 254 | 4523 | %{$node}); | |||||||||||||||||||||||||||||||||
| 255 | 4523 | $self->debug( "new node will be ".$tnode->to_string."\n"); | |||||||||||||||||||||||||||||||||
| 256 | 4523 | ▶ | if ( !$node->{'-leaf'} && $levelct > 0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $node->{"-leaf"} and $levelct > 0
MC/DC50%1/2
not $node->{"-leaf"} and $levelct > 0
not $node->{"-leaf"}
$levelct > 0
Truth table66%2/3
not(A) and B
A= not $node->{"-leaf"}B= $levelct > 0
| |||||||||||||||||||||||||||||||||||
| 257 | 12675 | $self->debug(join(',', map { $_->to_string } | |||||||||||||||||||||||||||||||||
| 258 | 2151 | @{$self->{'_currentnodes'}}). "\n"); | |||||||||||||||||||||||||||||||||
| 259 | 2151 | ▶ | $self->throw("something wrong with event construction treelevel ". | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 260 | "$level is recorded as having $levelct nodes ". | ||||||||||||||||||||||||||||||||||
| 261 | "but current nodes at this level is $curcount\n") | ||||||||||||||||||||||||||||||||||
| 262 | if( $levelct > $curcount); | ||||||||||||||||||||||||||||||||||
| 263 | 2151 | for ( splice( @{$self->{'_currentnodes'}}, - $levelct)) { | |||||||||||||||||||||||||||||||||
| 264 | 4405 | $self->debug("adding desc: " . $_->to_string . "\n"); | |||||||||||||||||||||||||||||||||
| 265 | 4405 | $tnode->add_Descendent($_); | |||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||
| 267 | 2151 | $self->{'_nodect'}->[$self->{'_treelevel'}+1] = 0; | |||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||
| 269 | 4523 | push @{$self->{'_currentnodes'}}, $tnode; | |||||||||||||||||||||||||||||||||
| 270 | 4523 | $self->{'_nodect'}->[$self->{'_treelevel'}]++; | |||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||
| 272 | 4523 | $curcount = scalar @{$self->{'_currentnodes'}}; | |||||||||||||||||||||||||||||||||
| 273 | 4523 | $self->debug ("added node: count is now $curcount, treelevel: $level, nodect: $levelct\n"); | |||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | 4523 | $self->{'_treelevel'}--; | |||||||||||||||||||||||||||||||||
| 276 | } elsif( $data->{'Name'} eq 'tree' ) { | ||||||||||||||||||||||||||||||||||
| 277 | 118 | $self->debug("end of tree: nodes in stack is $curcount\n"); | |||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||
| 280 | 13254 | $self->{'_lastitem'}->{ $data->{'Name'} }--; | |||||||||||||||||||||||||||||||||
| 281 | 13254 | pop @{$self->{'_lastitem'}->{'current'}}; | |||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||
| 285 | =head2 in_element | ||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||
| 287 | Title : in_element | ||||||||||||||||||||||||||||||||||
| 288 | Usage : | ||||||||||||||||||||||||||||||||||
| 289 | Function: | ||||||||||||||||||||||||||||||||||
| 290 | Example : | ||||||||||||||||||||||||||||||||||
| 291 | Returns : | ||||||||||||||||||||||||||||||||||
| 292 | Args : | ||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||
| 297 | 24148 | ▶ | sub in_element{ | ||||||||||||||||||||||||||||||||
|
Subroutine
in_element: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 298 | 24148 | my ($self,$e) = @_; | |||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||
| 300 | return 0 if ! defined $self->{'_lastitem'} || | ||||||||||||||||||||||||||||||||||
| 301 | 24148 | ▶ | ! defined $self->{'_lastitem'}->{'current'}->[-1]; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"_lastitem"} and defined $self->{"_lastitem"}{"current"}[-1]
MC/DC0%0/2
defined $self->{"_lastitem"} and defined $self->{"_lastitem"}{"current"}[-1]
defined $self->{"_lastitem"}
defined $self->{"_lastitem"}{"current"}[-1]
Truth table33%1/3
A and B
A= defined $self->{"_lastitem"}B= defined $self->{"_lastitem"}{"current"}[-1]
| |||||||||||||||||||||||||||||||||||
| 302 | 24148 | return ($e eq $self->{'_lastitem'}->{'current'}->[-1]); | |||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||
| 306 | =head2 within_element | ||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||
| 308 | Title : within_element | ||||||||||||||||||||||||||||||||||
| 309 | Usage : | ||||||||||||||||||||||||||||||||||
| 310 | Function: | ||||||||||||||||||||||||||||||||||
| 311 | Example : | ||||||||||||||||||||||||||||||||||
| 312 | Returns : | ||||||||||||||||||||||||||||||||||
| 313 | Args : | ||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | =cut | ||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | 8253 | ▶ | sub within_element{ | ||||||||||||||||||||||||||||||||
|
Subroutine
within_element: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 319 | 8253 | my ($self,$e) = @_; | |||||||||||||||||||||||||||||||||
| 320 | 8253 | return $self->{'_lastitem'}->{$e}; | |||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||
| 323 | =head2 characters | ||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||
| 325 | Title : characters | ||||||||||||||||||||||||||||||||||
| 326 | Usage : $handler->characters($text); | ||||||||||||||||||||||||||||||||||
| 327 | Function: Processes characters | ||||||||||||||||||||||||||||||||||
| 328 | Returns : none | ||||||||||||||||||||||||||||||||||
| 329 | Args : text string | ||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | 8135 | ▶ | sub characters{ | ||||||||||||||||||||||||||||||||
|
Subroutine
characters: called CC=9 SCAR=22.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 335 | 8135 | my ($self,$ch) = @_; | |||||||||||||||||||||||||||||||||
| 336 | 8135 | ▶ | if( $self->within_element('node') ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 337 | 8135 | my $hash = pop @{$self->{'_currentitems'}}; | |||||||||||||||||||||||||||||||||
| 338 | 8135 | ▶ | if( $self->in_element('bootstrap') ) { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 339 | # leading/trailing Whitespace-B-Gone | ||||||||||||||||||||||||||||||||||
| 340 | 8 | $ch =~ s/^\s+//; $ch =~ s/\s+$//; | |||||||||||||||||||||||||||||||||
| 341 | 8 | $hash->{'-bootstrap'} = $ch; | |||||||||||||||||||||||||||||||||
| 342 | } elsif( $self->in_element('branch_length') ) { | ||||||||||||||||||||||||||||||||||
| 343 | # leading/trailing Whitespace-B-Gone | ||||||||||||||||||||||||||||||||||
| 344 | 4131 | $ch =~ s/^\s+//; $ch =~ s/\s+$//; | |||||||||||||||||||||||||||||||||
| 345 | 4131 | $hash->{'-branch_length'} = $ch; | |||||||||||||||||||||||||||||||||
| 346 | } elsif( $self->in_element('id') ) { | ||||||||||||||||||||||||||||||||||
| 347 | 2440 | $hash->{'-id'} = $ch; | |||||||||||||||||||||||||||||||||
| 348 | } elsif( $self->in_element('description') ) { | ||||||||||||||||||||||||||||||||||
| 349 | 0 | $hash->{'-desc'} = $ch; | |||||||||||||||||||||||||||||||||
| 350 | } elsif ( $self->in_element('tag_name') ) { | ||||||||||||||||||||||||||||||||||
| 351 | 778 | $hash->{'-NHXtagname'} = $ch; | |||||||||||||||||||||||||||||||||
| 352 | } elsif ( $self->in_element('tag_value') ) { | ||||||||||||||||||||||||||||||||||
| 353 | 778 | $hash->{'-nhx'}->{$hash->{'-NHXtagname'}} = $ch; | |||||||||||||||||||||||||||||||||
| 354 | 778 | delete $hash->{'-NHXtagname'}; | |||||||||||||||||||||||||||||||||
| 355 | } elsif( $self->in_element('leaf') ) { | ||||||||||||||||||||||||||||||||||
| 356 | 0 | $hash->{'-leaf'} = $ch; | |||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||
| 358 | 8135 | push @{$self->{'_currentitems'}}, $hash; | |||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||
| 360 | 8135 | $self->debug("chars: $ch\n"); | |||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||
| 364 | 28 | 1; | |||||||||||||||||||||||||||||||||