| 1 | # BioPerl module for Bio::Tree::AnnotatableNode | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Cared for by Mira Han <mirhan@indiana.edu> | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # Copyright Mira Han | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Bio::Tree::AnnotatableNode - A Tree Node with support for annotation | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | use Bio::Tree::AnnotatableNode; | ||||||||||||||||||||||||||||
| 20 | my $nodeA = Bio::Tree::AnnotatableNode->new(); | ||||||||||||||||||||||||||||
| 21 | my $nodeL = Bio::Tree::AnnotatableNode->new(); | ||||||||||||||||||||||||||||
| 22 | my $nodeR = Bio::Tree::AnnotatableNode->new(); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | my $node = Bio::Tree::AnnotatableNode->new(); | ||||||||||||||||||||||||||||
| 25 | $node->add_Descendents($nodeL); | ||||||||||||||||||||||||||||
| 26 | $node->add_Descendents($nodeR); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | print "node is not a leaf \n" if( $node->is_leaf); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # $node is-a Bio::AnnotatableI, hence: | ||||||||||||||||||||||||||||
| 31 | my $ann_coll = $node->annotation(); | ||||||||||||||||||||||||||||
| 32 | # $ann_coll is-a Bio::AnnotationCollectionI, hence: | ||||||||||||||||||||||||||||
| 33 | my @all_anns = $ann_coll->get_Annotations(); | ||||||||||||||||||||||||||||
| 34 | # do something with the annotation objects | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | Makes a Tree Node with Annotations, suitable for building a Tree. See | ||||||||||||||||||||||||||||
| 39 | L<Bio::Tree::Node> for a full list of functionality. | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 46 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 47 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 50 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head2 Support | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 59 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 60 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 61 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 66 | of the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||
| 67 | the web: | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 AUTHOR - Mira Han | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Email mirhan@indiana.edu | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 78 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # Let the code begin... | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | package Bio::Tree::AnnotatableNode; | ||||||||||||||||||||||||||||
| 86 | 3 | $Bio::Tree::AnnotatableNode::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 87 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 3 | ▶ | use Bio::Annotation::Collection; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 90 | 3 | ▶ | use Bio::Seq; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 91 | 3 | ▶ | use base qw(Bio::Tree::Node Bio::AnnotatableI); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =head2 new | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Title : new | ||||||||||||||||||||||||||||
| 96 | Usage : my $obj = Bio::Tree::AnnotatableNode->new(); | ||||||||||||||||||||||||||||
| 97 | Function: Builds a new Bio::Tree::AnnotatableNode object | ||||||||||||||||||||||||||||
| 98 | Returns : Bio::Tree::AnnotatableNode | ||||||||||||||||||||||||||||
| 99 | Args : -tostring => code reference to the tostring callback function (optional) | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 96 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 96 | my ($class,@args) = @_; | |||||||||||||||||||||||||||
| 105 | 96 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 106 | 96 | my $to_string_cb = $self->_rearrange([qw(TOSTRING)], @args); | |||||||||||||||||||||||||||
| 107 | 96 | ▶ | if ($to_string_cb) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 66 | $self->to_string_callback($to_string_cb); | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 96 | return $self; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 92 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 114 | 92 | my ($self) = @_; | |||||||||||||||||||||||||||
| 115 | # try to insure that everything is cleaned up | ||||||||||||||||||||||||||||
| 116 | 92 | $self->SUPER::DESTROY(); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head1 Methods for implementing Bio::AnnotatableI | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head2 annotation | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | Title : annotation | ||||||||||||||||||||||||||||
| 126 | Usage : $ann = $node->annotation or | ||||||||||||||||||||||||||||
| 127 | $node->annotation($ann) | ||||||||||||||||||||||||||||
| 128 | Function: Gets or sets the annotation | ||||||||||||||||||||||||||||
| 129 | Returns : Bio::AnnotationCollectionI object | ||||||||||||||||||||||||||||
| 130 | Args : None or Bio::AnnotationCollectionI object | ||||||||||||||||||||||||||||
| 131 | See L<Bio::AnnotationCollectionI> and L<Bio::Annotation::Collection> | ||||||||||||||||||||||||||||
| 132 | for more information | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =cut | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | sub annotation | ||||||||||||||||||||||||||||
| 137 | 260 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
annotation: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||
| 138 | 260 | my ($self,$value) = @_; | |||||||||||||||||||||||||||
| 139 | 260 | ▶ | if( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $self->throw("object of class ".ref($value)." does not implement ". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | "Bio::AnnotationCollectionI. Too bad.") unless $value->isa("Bio::AnnotationCollectionI"); | ||||||||||||||||||||||||||||
| 142 | 0 | $self->{'_annotation'} = $value; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | elsif( ! defined $self->{'_annotation'}) | ||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||
| 146 | 66 | $self->{'_annotation'} = Bio::Annotation::Collection->new(); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 260 | return $self->{'_annotation'}; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =head1 Methods for implementing tag access through Annotation::SimpleValue | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =cut | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head2 add_tag_value | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | Title : add_tag_value | ||||||||||||||||||||||||||||
| 159 | Usage : $node->add_tag_value($tag,$value) | ||||||||||||||||||||||||||||
| 160 | Function: Adds a tag value to a node | ||||||||||||||||||||||||||||
| 161 | Returns : number of values stored for this tag | ||||||||||||||||||||||||||||
| 162 | Args : $tag - tag name | ||||||||||||||||||||||||||||
| 163 | $value - value to store for the tag | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =cut | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | sub add_tag_value | ||||||||||||||||||||||||||||
| 168 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
add_tag_value: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | 1 | my ($self,$tag,$value) = @_; | |||||||||||||||||||||||||||
| 170 | 1 | ▶ | if( ! defined $tag || ! defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $tag and defined $value
MC/DC0%0/2
defined $tag and defined $value
defined $tag
defined $value
Truth table33%1/3
A and B
A= defined $tagB= defined $value
| |||||||||||||||||||||||||||||
| 171 | 0 | $self->warn("cannot call add_tag_value with an undefined value"); | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | 1 | my $ac = $self->annotation(); | |||||||||||||||||||||||||||
| 174 | 1 | my $sv = Bio::Annotation::SimpleValue->new(-value => $value); | |||||||||||||||||||||||||||
| 175 | 1 | $ac->add_Annotation($tag, $sv); | |||||||||||||||||||||||||||
| 176 | 1 | return scalar $ac->get_Annotations($tag); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =head2 remove_tag | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | Title : remove_tag | ||||||||||||||||||||||||||||
| 182 | Usage : $node->remove_tag($tag) | ||||||||||||||||||||||||||||
| 183 | Function: Remove the tag and all values for this tag | ||||||||||||||||||||||||||||
| 184 | Returns : boolean representing success (0 if tag does not exist) | ||||||||||||||||||||||||||||
| 185 | Args : $tag - tagname to remove | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | =cut | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | sub remove_tag | ||||||||||||||||||||||||||||
| 191 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
remove_tag: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 192 | 0 | my ($self,$tag) = @_; | |||||||||||||||||||||||||||
| 193 | 0 | my $ac = $self->annotation(); | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | if( @{$ac->get_Annotations($tag)} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $ac->remove_Annotations($tag); | |||||||||||||||||||||||||||
| 196 | 0 | return 1; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | 0 | return 0; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =head2 remove_all_tags | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | Title : remove_all_tags | ||||||||||||||||||||||||||||
| 204 | Usage : $node->remove_all_tags() | ||||||||||||||||||||||||||||
| 205 | Function: Removes all tags | ||||||||||||||||||||||||||||
| 206 | Returns : None | ||||||||||||||||||||||||||||
| 207 | Args : None | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =cut | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | sub remove_all_tags | ||||||||||||||||||||||||||||
| 212 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
remove_all_tags: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 213 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 214 | 0 | my $ac = $self->annotation(); | |||||||||||||||||||||||||||
| 215 | 0 | $ac->remove_Annotations(); | |||||||||||||||||||||||||||
| 216 | 0 | return; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | =head2 get_all_tags | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | Title : get_all_tags | ||||||||||||||||||||||||||||
| 222 | Usage : my @tags = $node->get_all_tags() | ||||||||||||||||||||||||||||
| 223 | Function: Gets all the tag names for this Node | ||||||||||||||||||||||||||||
| 224 | Returns : Array of tagnames | ||||||||||||||||||||||||||||
| 225 | Args : None | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =cut | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub get_all_tags{ | ||||||||||||||||||||||||||
|
Subroutine
get_all_tags: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 230 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 231 | 0 | my $ac = $self->annotation(); | |||||||||||||||||||||||||||
| 232 | 0 | my @tags = sort $ac->get_all_annotation_keys(); | |||||||||||||||||||||||||||
| 233 | # how to restrict it to SimpleValues? | ||||||||||||||||||||||||||||
| 234 | 0 | return @tags; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head2 get_tag_values | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | Title : get_tag_values | ||||||||||||||||||||||||||||
| 240 | Usage : my @values = $node->get_tag_value($tag) | ||||||||||||||||||||||||||||
| 241 | Function: Gets the values for given tag ($tag) | ||||||||||||||||||||||||||||
| 242 | Returns : Array of values or empty list if tag does not exist | ||||||||||||||||||||||||||||
| 243 | Args : $tag - tag name | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | =cut | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 2 | ▶ | sub get_tag_values{ | ||||||||||||||||||||||||||
|
Subroutine
get_tag_values: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 248 | 2 | my ($self,$tag) = @_; | |||||||||||||||||||||||||||
| 249 | 2 | my $ac = $self->annotation(); | |||||||||||||||||||||||||||
| 250 | 2 | my @values = map {$_->value()} $ac->get_Annotations($tag); | |||||||||||||||||||||||||||
| 251 | 2 | return @values; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | =head2 has_tag | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | Title : has_tag | ||||||||||||||||||||||||||||
| 257 | Usage : $node->has_tag($tag) | ||||||||||||||||||||||||||||
| 258 | Function: Boolean test if tag exists in the Node | ||||||||||||||||||||||||||||
| 259 | Returns : Boolean | ||||||||||||||||||||||||||||
| 260 | Args : $tag - tagname | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =cut | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 1 | ▶ | sub has_tag { | ||||||||||||||||||||||||||
|
Subroutine
has_tag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 265 | 1 | my ($self,$tag) = @_; | |||||||||||||||||||||||||||
| 266 | 1 | my $ac = $self->annotation(); | |||||||||||||||||||||||||||
| 267 | 1 | return ( scalar $ac->get_Annotations($tag) > 0); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =head1 Methods for implementing to_string | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =cut | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =head2 to_string_callback | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | Title : to_string_callback | ||||||||||||||||||||||||||||
| 278 | Usage : $node->to_string_callback(\&func) | ||||||||||||||||||||||||||||
| 279 | Function: get/set callback for to_string | ||||||||||||||||||||||||||||
| 280 | Returns : code reference for the to_string callback function | ||||||||||||||||||||||||||||
| 281 | Args : \&func - code reference to be set as the callback function | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | =cut | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 66 | ▶ | sub to_string_callback { | ||||||||||||||||||||||||||
|
Subroutine
to_string_callback: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 286 | # get/set callback, using $DEFAULT_CB if nothing is set | ||||||||||||||||||||||||||||
| 287 | 66 | my ($self, $foo) = @_; | |||||||||||||||||||||||||||
| 288 | 66 | ▶ | if ($foo) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | # $foo is callback code ref, self as first arg (so you have access to object data) | ||||||||||||||||||||||||||||
| 290 | 66 | $self->{'_to_string_cb'} = $foo; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if (! defined $self->{'_to_string_cb'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 0 | $self->{'_to_string_cb'} = \&Bio::Tree::NodeI::to_string; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | 66 | return $self->{'_to_string_cb'}; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | ▶ | sub to_string { | ||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 301 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 302 | 0 | my $cb = $self->to_string_callback(); | |||||||||||||||||||||||||||
| 303 | 0 | return $cb->($self); | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | =head1 Methods for accessing Bio::Seq | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =cut | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | =head2 sequence | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | Title : sequence | ||||||||||||||||||||||||||||
| 313 | Usage : $ann = $node->sequence or | ||||||||||||||||||||||||||||
| 314 | $node->sequence($seq) | ||||||||||||||||||||||||||||
| 315 | Function: Gets or sets the sequence | ||||||||||||||||||||||||||||
| 316 | Returns : array reference of Bio::SeqI objects | ||||||||||||||||||||||||||||
| 317 | Args : None or Bio::SeqI object | ||||||||||||||||||||||||||||
| 318 | See L<Bio::SeqI> and L<Bio::Seq> | ||||||||||||||||||||||||||||
| 319 | for more information | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =cut | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | sub sequence | ||||||||||||||||||||||||||||
| 324 | 22 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
sequence: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 325 | 22 | my ($self,$value) = @_; | |||||||||||||||||||||||||||
| 326 | 22 | ▶ | if( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | 9 | ▶ | $self->throw("object of class ".ref($value)." does not implement ". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | "Bio::SeqI. Too bad.") unless $value->isa("Bio::SeqI"); | ||||||||||||||||||||||||||||
| 329 | 9 | push (@{$self->{'_sequence'}}, $value); | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | #elsif( ! defined $self->{'_sequence'}) | ||||||||||||||||||||||||||||
| 332 | #{ | ||||||||||||||||||||||||||||
| 333 | # $self->{'_sequence'} = Bio::Seq->new(); | ||||||||||||||||||||||||||||
| 334 | #} | ||||||||||||||||||||||||||||
| 335 | 22 | return $self->{'_sequence'}; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | =head2 has_sequence | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | Title : has_sequence | ||||||||||||||||||||||||||||
| 341 | Usage : if( $node->has_sequence) { # do something } | ||||||||||||||||||||||||||||
| 342 | Function: tells if node has sequence attached | ||||||||||||||||||||||||||||
| 343 | Returns : Boolean for whether or not node has Bio::SeqI attached. | ||||||||||||||||||||||||||||
| 344 | Args : None | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =cut | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | sub has_sequence | ||||||||||||||||||||||||||||
| 349 | 66 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
has_sequence: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 350 | 66 | my ($self) = @_; | |||||||||||||||||||||||||||
| 351 | 66 | ▶ | return $self->{'_sequence'} && @{$self->{'_sequence'}}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'_sequence'} && @{$self->{'_sequence'};}
MC/DC50%1/2
$self->{'_sequence'} && @{$self->{'_sequence'};}
$self->{'_sequence'}
@{$self->{'_sequence'};}
Truth table66%2/3
A && B
A= $self->{'_sequence'}B= @{$self->{'_sequence'};}
| |||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 3 | 1; | |||||||||||||||||||||||||||