| 1 | package Bio::Phylo::Forest::DrawTreeRole; | ||||||||||||||
| 2 | 31 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 31 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 31 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 31 | ▶ | use Bio::Phylo::Forest::TreeRole; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 31 | ▶ | use base 'Bio::Phylo::Forest::TreeRole'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 31 | ▶ | use Bio::Phylo::Forest::DrawNodeRole; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 31 | ▶ | use Bio::Phylo::Util::CONSTANT 'looks_like_hash'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | { | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 31 | our $AUTOLOAD; | |||||||||||||
| 12 | 31 | my @properties = qw(width height node_radius tip_radius node_color node_shape | |||||||||||||
| 13 | node_image branch_color branch_shape branch_width branch_style collapsed_clade_width | ||||||||||||||
| 14 | font_face font_size font_style margin margin_top margin_bottom margin_left | ||||||||||||||
| 15 | margin_right padding padding_top padding_bottom padding_left padding_right | ||||||||||||||
| 16 | mode shape text_horiz_offset text_vert_offset); | ||||||||||||||
| 17 | |||||||||||||||
| 18 | =head1 NAME | ||||||||||||||
| 19 | |||||||||||||||
| 20 | Bio::Phylo::Forest::DrawTreeRole - Tree with extra methods for tree drawing | ||||||||||||||
| 21 | |||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||
| 23 | |||||||||||||||
| 24 | # see Bio::Phylo::Forest::Tree | ||||||||||||||
| 25 | |||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||
| 27 | |||||||||||||||
| 28 | The object models a phylogenetic tree, a container of Bio::Phylo::For- | ||||||||||||||
| 29 | est::Node objects. The tree object inherits from Bio::Phylo::Listable, | ||||||||||||||
| 30 | so look there for more methods. | ||||||||||||||
| 31 | |||||||||||||||
| 32 | In addition, this subclass of the default tree object L<Bio::Phylo::Forest::Tree> | ||||||||||||||
| 33 | has getters and setters for drawing trees, e.g. font and text attributes, etc. | ||||||||||||||
| 34 | |||||||||||||||
| 35 | =head1 METHODS | ||||||||||||||
| 36 | |||||||||||||||
| 37 | =head2 CONSTRUCTORS | ||||||||||||||
| 38 | |||||||||||||||
| 39 | =over | ||||||||||||||
| 40 | |||||||||||||||
| 41 | =item new() | ||||||||||||||
| 42 | |||||||||||||||
| 43 | Tree constructor. | ||||||||||||||
| 44 | |||||||||||||||
| 45 | Type : Constructor | ||||||||||||||
| 46 | Title : new | ||||||||||||||
| 47 | Usage : my $tree = Bio::Phylo::Forest::DrawTree->new; | ||||||||||||||
| 48 | Function: Instantiates a Bio::Phylo::Forest::DrawTree object. | ||||||||||||||
| 49 | Returns : A Bio::Phylo::Forest::DrawTree object. | ||||||||||||||
| 50 | Args : No required arguments. | ||||||||||||||
| 51 | |||||||||||||||
| 52 | =cut | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 189 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=4 SCAR=23.1
Pod
documented
| |||||||||||||||
| 55 | 189 | my $class = shift; | |||||||||||||
| 56 | 189 | my %args = looks_like_hash @_; | |||||||||||||
| 57 | 189 | ▶ | if ( not $args{'-tree'} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 58 | 189 | return $class->SUPER::new(@_); | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | else { | ||||||||||||||
| 61 | 0 | my $tree = $args{'-tree'}; | |||||||||||||
| 62 | 0 | my $self = $tree->clone; | |||||||||||||
| 63 | 0 | bless $self, $class; | |||||||||||||
| 64 | 0 | for my $node ( @{ $self->get_entities } ) { | |||||||||||||
| 65 | 0 | bless $node, 'Bio::Phylo::Forest::DrawNode'; | |||||||||||||
| 66 | } | ||||||||||||||
| 67 | |||||||||||||||
| 68 | 0 | delete $args{'-tree'}; | |||||||||||||
| 69 | 0 | for my $key ( keys %args ) { | |||||||||||||
| 70 | 0 | my $method = $key; | |||||||||||||
| 71 | 0 | $method =~ s/^-/set_/; | |||||||||||||
| 72 | 0 | $self->$method( $args{$key} ); | |||||||||||||
| 73 | } | ||||||||||||||
| 74 | 0 | return $self; | |||||||||||||
| 75 | } | ||||||||||||||
| 76 | } | ||||||||||||||
| 77 | |||||||||||||||
| 78 | =back | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =head2 MUTATORS | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =over | ||||||||||||||
| 83 | |||||||||||||||
| 84 | =item set_width() | ||||||||||||||
| 85 | |||||||||||||||
| 86 | Type : Mutator | ||||||||||||||
| 87 | Title : set_width | ||||||||||||||
| 88 | Usage : $tree->set_width($width); | ||||||||||||||
| 89 | Function: Sets width | ||||||||||||||
| 90 | Returns : $self | ||||||||||||||
| 91 | Args : width | ||||||||||||||
| 92 | |||||||||||||||
| 93 | =item set_height() | ||||||||||||||
| 94 | |||||||||||||||
| 95 | Type : Mutator | ||||||||||||||
| 96 | Title : set_height | ||||||||||||||
| 97 | Usage : $tree->set_height($height); | ||||||||||||||
| 98 | Function: Sets height | ||||||||||||||
| 99 | Returns : $self | ||||||||||||||
| 100 | Args : height | ||||||||||||||
| 101 | |||||||||||||||
| 102 | =item set_node_radius() | ||||||||||||||
| 103 | |||||||||||||||
| 104 | Type : Mutator | ||||||||||||||
| 105 | Title : set_node_radius | ||||||||||||||
| 106 | Usage : $tree->set_node_radius($node_radius); | ||||||||||||||
| 107 | Function: Sets node_radius | ||||||||||||||
| 108 | Returns : $self | ||||||||||||||
| 109 | Args : node_radius | ||||||||||||||
| 110 | |||||||||||||||
| 111 | =item set_tip_radius() | ||||||||||||||
| 112 | |||||||||||||||
| 113 | Type : Mutator | ||||||||||||||
| 114 | Title : set_tip_node_radius | ||||||||||||||
| 115 | Usage : $tree->set_tip_radius($node_radius); | ||||||||||||||
| 116 | Function: Sets tip radius | ||||||||||||||
| 117 | Returns : $self | ||||||||||||||
| 118 | Args : tip radius | ||||||||||||||
| 119 | |||||||||||||||
| 120 | =item set_node_colour() | ||||||||||||||
| 121 | |||||||||||||||
| 122 | Type : Mutator | ||||||||||||||
| 123 | Title : set_node_colour | ||||||||||||||
| 124 | Usage : $tree->set_node_colour($node_colour); | ||||||||||||||
| 125 | Function: Sets node_colour | ||||||||||||||
| 126 | Returns : $self | ||||||||||||||
| 127 | Args : node_colour | ||||||||||||||
| 128 | |||||||||||||||
| 129 | =item set_node_shape() | ||||||||||||||
| 130 | |||||||||||||||
| 131 | Type : Mutator | ||||||||||||||
| 132 | Title : set_node_shape | ||||||||||||||
| 133 | Usage : $tree->set_node_shape($node_shape); | ||||||||||||||
| 134 | Function: Sets node_shape | ||||||||||||||
| 135 | Returns : $self | ||||||||||||||
| 136 | Args : node_shape | ||||||||||||||
| 137 | |||||||||||||||
| 138 | =item set_node_image() | ||||||||||||||
| 139 | |||||||||||||||
| 140 | Type : Mutator | ||||||||||||||
| 141 | Title : set_node_image | ||||||||||||||
| 142 | Usage : $tree->set_node_image($node_image); | ||||||||||||||
| 143 | Function: Sets node_image | ||||||||||||||
| 144 | Returns : $self | ||||||||||||||
| 145 | Args : node_image | ||||||||||||||
| 146 | |||||||||||||||
| 147 | =item set_collapsed_clade_width() | ||||||||||||||
| 148 | |||||||||||||||
| 149 | Sets collapsed clade width. | ||||||||||||||
| 150 | |||||||||||||||
| 151 | Type : Mutator | ||||||||||||||
| 152 | Title : set_collapsed_clade_width | ||||||||||||||
| 153 | Usage : $tree->set_collapsed_clade_width(6); | ||||||||||||||
| 154 | Function: sets the width of collapsed clade triangles relative to uncollapsed tips | ||||||||||||||
| 155 | Returns : | ||||||||||||||
| 156 | Args : Positive number | ||||||||||||||
| 157 | |||||||||||||||
| 158 | =item set_branch_color() | ||||||||||||||
| 159 | |||||||||||||||
| 160 | Type : Mutator | ||||||||||||||
| 161 | Title : set_branch_color | ||||||||||||||
| 162 | Usage : $tree->set_branch_color($branch_color); | ||||||||||||||
| 163 | Function: Sets branch_color | ||||||||||||||
| 164 | Returns : $self | ||||||||||||||
| 165 | Args : branch_color | ||||||||||||||
| 166 | |||||||||||||||
| 167 | =item set_branch_shape() | ||||||||||||||
| 168 | |||||||||||||||
| 169 | Type : Mutator | ||||||||||||||
| 170 | Title : set_branch_shape | ||||||||||||||
| 171 | Usage : $tree->set_branch_shape($branch_shape); | ||||||||||||||
| 172 | Function: Sets branch_shape | ||||||||||||||
| 173 | Returns : $self | ||||||||||||||
| 174 | Args : branch_shape | ||||||||||||||
| 175 | |||||||||||||||
| 176 | =item set_branch_width() | ||||||||||||||
| 177 | |||||||||||||||
| 178 | Type : Mutator | ||||||||||||||
| 179 | Title : set_branch_width | ||||||||||||||
| 180 | Usage : $tree->set_branch_width($branch_width); | ||||||||||||||
| 181 | Function: Sets branch width | ||||||||||||||
| 182 | Returns : $self | ||||||||||||||
| 183 | Args : branch_width | ||||||||||||||
| 184 | |||||||||||||||
| 185 | =item set_branch_style() | ||||||||||||||
| 186 | |||||||||||||||
| 187 | Type : Mutator | ||||||||||||||
| 188 | Title : set_branch_style | ||||||||||||||
| 189 | Usage : $tree->set_branch_style($branch_style); | ||||||||||||||
| 190 | Function: Sets branch style | ||||||||||||||
| 191 | Returns : $self | ||||||||||||||
| 192 | Args : branch_style | ||||||||||||||
| 193 | |||||||||||||||
| 194 | =item set_font_face() | ||||||||||||||
| 195 | |||||||||||||||
| 196 | Type : Mutator | ||||||||||||||
| 197 | Title : set_font_face | ||||||||||||||
| 198 | Usage : $tree->set_font_face($font_face); | ||||||||||||||
| 199 | Function: Sets font_face | ||||||||||||||
| 200 | Returns : $self | ||||||||||||||
| 201 | Args : font face, Verdana, Arial, Serif | ||||||||||||||
| 202 | |||||||||||||||
| 203 | =item set_font_size() | ||||||||||||||
| 204 | |||||||||||||||
| 205 | Type : Mutator | ||||||||||||||
| 206 | Title : set_font_size | ||||||||||||||
| 207 | Usage : $tree->set_font_size($font_size); | ||||||||||||||
| 208 | Function: Sets font_size | ||||||||||||||
| 209 | Returns : $self | ||||||||||||||
| 210 | Args : Font size in pixels | ||||||||||||||
| 211 | |||||||||||||||
| 212 | =item set_font_style() | ||||||||||||||
| 213 | |||||||||||||||
| 214 | Type : Mutator | ||||||||||||||
| 215 | Title : set_font_style | ||||||||||||||
| 216 | Usage : $tree->set_font_style($font_style); | ||||||||||||||
| 217 | Function: Sets font_style | ||||||||||||||
| 218 | Returns : $self | ||||||||||||||
| 219 | Args : Font style, e.g. Italic | ||||||||||||||
| 220 | |||||||||||||||
| 221 | =item set_margin() | ||||||||||||||
| 222 | |||||||||||||||
| 223 | Type : Mutator | ||||||||||||||
| 224 | Title : set_margin | ||||||||||||||
| 225 | Usage : $tree->set_margin($margin); | ||||||||||||||
| 226 | Function: Sets margin | ||||||||||||||
| 227 | Returns : $self | ||||||||||||||
| 228 | Args : margin | ||||||||||||||
| 229 | |||||||||||||||
| 230 | =item set_margin_top() | ||||||||||||||
| 231 | |||||||||||||||
| 232 | Type : Mutator | ||||||||||||||
| 233 | Title : set_margin_top | ||||||||||||||
| 234 | Usage : $tree->set_margin_top($margin_top); | ||||||||||||||
| 235 | Function: Sets margin_top | ||||||||||||||
| 236 | Returns : $self | ||||||||||||||
| 237 | Args : margin_top | ||||||||||||||
| 238 | |||||||||||||||
| 239 | =item set_margin_bottom() | ||||||||||||||
| 240 | |||||||||||||||
| 241 | Type : Mutator | ||||||||||||||
| 242 | Title : set_margin_bottom | ||||||||||||||
| 243 | Usage : $tree->set_margin_bottom($margin_bottom); | ||||||||||||||
| 244 | Function: Sets margin_bottom | ||||||||||||||
| 245 | Returns : $self | ||||||||||||||
| 246 | Args : margin_bottom | ||||||||||||||
| 247 | |||||||||||||||
| 248 | =item set_margin_left() | ||||||||||||||
| 249 | |||||||||||||||
| 250 | Type : Mutator | ||||||||||||||
| 251 | Title : set_margin_left | ||||||||||||||
| 252 | Usage : $tree->set_margin_left($margin_left); | ||||||||||||||
| 253 | Function: Sets margin_left | ||||||||||||||
| 254 | Returns : $self | ||||||||||||||
| 255 | Args : margin_left | ||||||||||||||
| 256 | |||||||||||||||
| 257 | =item set_margin_right() | ||||||||||||||
| 258 | |||||||||||||||
| 259 | Type : Mutator | ||||||||||||||
| 260 | Title : set_margin_right | ||||||||||||||
| 261 | Usage : $tree->set_margin_right($margin_right); | ||||||||||||||
| 262 | Function: Sets margin_right | ||||||||||||||
| 263 | Returns : $self | ||||||||||||||
| 264 | Args : margin_right | ||||||||||||||
| 265 | |||||||||||||||
| 266 | =item set_padding() | ||||||||||||||
| 267 | |||||||||||||||
| 268 | Type : Mutator | ||||||||||||||
| 269 | Title : set_padding | ||||||||||||||
| 270 | Usage : $tree->set_padding($padding); | ||||||||||||||
| 271 | Function: Sets padding | ||||||||||||||
| 272 | Returns : $self | ||||||||||||||
| 273 | Args : padding | ||||||||||||||
| 274 | |||||||||||||||
| 275 | =item set_padding_top() | ||||||||||||||
| 276 | |||||||||||||||
| 277 | Type : Mutator | ||||||||||||||
| 278 | Title : set_padding_top | ||||||||||||||
| 279 | Usage : $tree->set_padding_top($padding_top); | ||||||||||||||
| 280 | Function: Sets padding_top | ||||||||||||||
| 281 | Returns : $self | ||||||||||||||
| 282 | Args : padding_top | ||||||||||||||
| 283 | |||||||||||||||
| 284 | =item set_padding_bottom() | ||||||||||||||
| 285 | |||||||||||||||
| 286 | Type : Mutator | ||||||||||||||
| 287 | Title : set_padding_bottom | ||||||||||||||
| 288 | Usage : $tree->set_padding_bottom($padding_bottom); | ||||||||||||||
| 289 | Function: Sets padding_bottom | ||||||||||||||
| 290 | Returns : $self | ||||||||||||||
| 291 | Args : padding_bottom | ||||||||||||||
| 292 | |||||||||||||||
| 293 | =item set_padding_left() | ||||||||||||||
| 294 | |||||||||||||||
| 295 | Type : Mutator | ||||||||||||||
| 296 | Title : set_padding_left | ||||||||||||||
| 297 | Usage : $tree->set_padding_left($padding_left); | ||||||||||||||
| 298 | Function: Sets padding_left | ||||||||||||||
| 299 | Returns : $self | ||||||||||||||
| 300 | Args : padding_left | ||||||||||||||
| 301 | |||||||||||||||
| 302 | =item set_padding_right() | ||||||||||||||
| 303 | |||||||||||||||
| 304 | Type : Mutator | ||||||||||||||
| 305 | Title : set_padding_right | ||||||||||||||
| 306 | Usage : $tree->set_padding_right($padding_right); | ||||||||||||||
| 307 | Function: Sets padding_right | ||||||||||||||
| 308 | Returns : $self | ||||||||||||||
| 309 | Args : padding_right | ||||||||||||||
| 310 | |||||||||||||||
| 311 | =item set_mode() | ||||||||||||||
| 312 | |||||||||||||||
| 313 | Type : Mutator | ||||||||||||||
| 314 | Title : set_mode | ||||||||||||||
| 315 | Usage : $tree->set_mode($mode); | ||||||||||||||
| 316 | Function: Sets mode | ||||||||||||||
| 317 | Returns : $self | ||||||||||||||
| 318 | Args : mode, e.g. 'CLADO' or 'PHYLO' | ||||||||||||||
| 319 | |||||||||||||||
| 320 | =item set_shape() | ||||||||||||||
| 321 | |||||||||||||||
| 322 | Type : Mutator | ||||||||||||||
| 323 | Title : set_shape | ||||||||||||||
| 324 | Usage : $tree->set_shape($shape); | ||||||||||||||
| 325 | Function: Sets shape | ||||||||||||||
| 326 | Returns : $self | ||||||||||||||
| 327 | Args : shape, e.g. 'RECT', 'CURVY', 'DIAG' | ||||||||||||||
| 328 | |||||||||||||||
| 329 | =item set_text_horiz_offset() | ||||||||||||||
| 330 | |||||||||||||||
| 331 | Type : Mutator | ||||||||||||||
| 332 | Title : set_text_horiz_offset | ||||||||||||||
| 333 | Usage : $tree->set_text_horiz_offset($text_horiz_offset); | ||||||||||||||
| 334 | Function: Sets text_horiz_offset | ||||||||||||||
| 335 | Returns : $self | ||||||||||||||
| 336 | Args : text_horiz_offset | ||||||||||||||
| 337 | |||||||||||||||
| 338 | =item set_text_vert_offset() | ||||||||||||||
| 339 | |||||||||||||||
| 340 | Type : Mutator | ||||||||||||||
| 341 | Title : set_text_vert_offset | ||||||||||||||
| 342 | Usage : $tree->set_text_vert_offset($text_vert_offset); | ||||||||||||||
| 343 | Function: Sets text_vert_offset | ||||||||||||||
| 344 | Returns : $self | ||||||||||||||
| 345 | Args : text_vert_offset | ||||||||||||||
| 346 | |||||||||||||||
| 347 | =back | ||||||||||||||
| 348 | |||||||||||||||
| 349 | =head2 ACCESSORS | ||||||||||||||
| 350 | |||||||||||||||
| 351 | =over | ||||||||||||||
| 352 | |||||||||||||||
| 353 | =item get_width() | ||||||||||||||
| 354 | |||||||||||||||
| 355 | Type : Accessor | ||||||||||||||
| 356 | Title : get_width | ||||||||||||||
| 357 | Usage : my $width = $tree->get_width(); | ||||||||||||||
| 358 | Function: Gets width | ||||||||||||||
| 359 | Returns : width | ||||||||||||||
| 360 | Args : NONE | ||||||||||||||
| 361 | |||||||||||||||
| 362 | =item get_height() | ||||||||||||||
| 363 | |||||||||||||||
| 364 | Type : Accessor | ||||||||||||||
| 365 | Title : get_height | ||||||||||||||
| 366 | Usage : my $height = $tree->get_height(); | ||||||||||||||
| 367 | Function: Gets height | ||||||||||||||
| 368 | Returns : height | ||||||||||||||
| 369 | Args : NONE | ||||||||||||||
| 370 | |||||||||||||||
| 371 | =item get_node_radius() | ||||||||||||||
| 372 | |||||||||||||||
| 373 | Type : Accessor | ||||||||||||||
| 374 | Title : get_node_radius | ||||||||||||||
| 375 | Usage : my $node_radius = $tree->get_node_radius(); | ||||||||||||||
| 376 | Function: Gets node_radius | ||||||||||||||
| 377 | Returns : node_radius | ||||||||||||||
| 378 | Args : NONE | ||||||||||||||
| 379 | |||||||||||||||
| 380 | =item get_node_colour() | ||||||||||||||
| 381 | |||||||||||||||
| 382 | Type : Accessor | ||||||||||||||
| 383 | Title : get_node_colour | ||||||||||||||
| 384 | Usage : my $node_colour = $tree->get_node_colour(); | ||||||||||||||
| 385 | Function: Gets node_colour | ||||||||||||||
| 386 | Returns : node_colour | ||||||||||||||
| 387 | Args : NONE | ||||||||||||||
| 388 | |||||||||||||||
| 389 | =item get_node_shape() | ||||||||||||||
| 390 | |||||||||||||||
| 391 | Type : Accessor | ||||||||||||||
| 392 | Title : get_node_shape | ||||||||||||||
| 393 | Usage : my $node_shape = $tree->get_node_shape(); | ||||||||||||||
| 394 | Function: Gets node_shape | ||||||||||||||
| 395 | Returns : node_shape | ||||||||||||||
| 396 | Args : NONE | ||||||||||||||
| 397 | |||||||||||||||
| 398 | =item get_node_image() | ||||||||||||||
| 399 | |||||||||||||||
| 400 | Type : Accessor | ||||||||||||||
| 401 | Title : get_node_image | ||||||||||||||
| 402 | Usage : my $node_image = $tree->get_node_image(); | ||||||||||||||
| 403 | Function: Gets node_image | ||||||||||||||
| 404 | Returns : node_image | ||||||||||||||
| 405 | Args : NONE | ||||||||||||||
| 406 | |||||||||||||||
| 407 | =item get_collapsed_clade_width() | ||||||||||||||
| 408 | |||||||||||||||
| 409 | Gets collapsed clade width. | ||||||||||||||
| 410 | |||||||||||||||
| 411 | Type : Mutator | ||||||||||||||
| 412 | Title : get_collapsed_clade_width | ||||||||||||||
| 413 | Usage : $w = $tree->get_collapsed_clade_width(); | ||||||||||||||
| 414 | Function: gets the width of collapsed clade triangles relative to uncollapsed tips | ||||||||||||||
| 415 | Returns : Positive number | ||||||||||||||
| 416 | Args : None | ||||||||||||||
| 417 | |||||||||||||||
| 418 | =item get_branch_color() | ||||||||||||||
| 419 | |||||||||||||||
| 420 | Type : Accessor | ||||||||||||||
| 421 | Title : get_branch_color | ||||||||||||||
| 422 | Usage : my $branch_color = $tree->get_branch_color(); | ||||||||||||||
| 423 | Function: Gets branch_color | ||||||||||||||
| 424 | Returns : branch_color | ||||||||||||||
| 425 | Args : NONE | ||||||||||||||
| 426 | |||||||||||||||
| 427 | =item get_branch_shape() | ||||||||||||||
| 428 | |||||||||||||||
| 429 | Type : Accessor | ||||||||||||||
| 430 | Title : get_branch_shape | ||||||||||||||
| 431 | Usage : my $branch_shape = $tree->get_branch_shape(); | ||||||||||||||
| 432 | Function: Gets branch_shape | ||||||||||||||
| 433 | Returns : branch_shape | ||||||||||||||
| 434 | Args : NONE | ||||||||||||||
| 435 | |||||||||||||||
| 436 | =item get_branch_width() | ||||||||||||||
| 437 | |||||||||||||||
| 438 | Type : Accessor | ||||||||||||||
| 439 | Title : get_branch_width | ||||||||||||||
| 440 | Usage : my $branch_width = $tree->get_branch_width(); | ||||||||||||||
| 441 | Function: Gets branch_width | ||||||||||||||
| 442 | Returns : branch_width | ||||||||||||||
| 443 | Args : NONE | ||||||||||||||
| 444 | |||||||||||||||
| 445 | =item get_branch_style() | ||||||||||||||
| 446 | |||||||||||||||
| 447 | Type : Accessor | ||||||||||||||
| 448 | Title : get_branch_style | ||||||||||||||
| 449 | Usage : my $branch_style = $tree->get_branch_style(); | ||||||||||||||
| 450 | Function: Gets branch_style | ||||||||||||||
| 451 | Returns : branch_style | ||||||||||||||
| 452 | Args : NONE | ||||||||||||||
| 453 | |||||||||||||||
| 454 | =item get_font_face() | ||||||||||||||
| 455 | |||||||||||||||
| 456 | Type : Accessor | ||||||||||||||
| 457 | Title : get_font_face | ||||||||||||||
| 458 | Usage : my $font_face = $tree->get_font_face(); | ||||||||||||||
| 459 | Function: Gets font_face | ||||||||||||||
| 460 | Returns : font_face | ||||||||||||||
| 461 | Args : NONE | ||||||||||||||
| 462 | |||||||||||||||
| 463 | =item get_font_size() | ||||||||||||||
| 464 | |||||||||||||||
| 465 | Type : Accessor | ||||||||||||||
| 466 | Title : get_font_size | ||||||||||||||
| 467 | Usage : my $font_size = $tree->get_font_size(); | ||||||||||||||
| 468 | Function: Gets font_size | ||||||||||||||
| 469 | Returns : font_size | ||||||||||||||
| 470 | Args : NONE | ||||||||||||||
| 471 | |||||||||||||||
| 472 | =item get_font_style() | ||||||||||||||
| 473 | |||||||||||||||
| 474 | Type : Accessor | ||||||||||||||
| 475 | Title : get_font_style | ||||||||||||||
| 476 | Usage : my $font_style = $tree->get_font_style(); | ||||||||||||||
| 477 | Function: Gets font_style | ||||||||||||||
| 478 | Returns : font_style | ||||||||||||||
| 479 | Args : NONE | ||||||||||||||
| 480 | |||||||||||||||
| 481 | =item get_margin() | ||||||||||||||
| 482 | |||||||||||||||
| 483 | Type : Accessor | ||||||||||||||
| 484 | Title : get_margin | ||||||||||||||
| 485 | Usage : my $margin = $tree->get_margin(); | ||||||||||||||
| 486 | Function: Gets margin | ||||||||||||||
| 487 | Returns : margin | ||||||||||||||
| 488 | Args : NONE | ||||||||||||||
| 489 | |||||||||||||||
| 490 | =item get_margin_top() | ||||||||||||||
| 491 | |||||||||||||||
| 492 | Type : Accessor | ||||||||||||||
| 493 | Title : get_margin_top | ||||||||||||||
| 494 | Usage : my $margin_top = $tree->get_margin_top(); | ||||||||||||||
| 495 | Function: Gets margin_top | ||||||||||||||
| 496 | Returns : margin_top | ||||||||||||||
| 497 | Args : NONE | ||||||||||||||
| 498 | |||||||||||||||
| 499 | =item get_margin_bottom() | ||||||||||||||
| 500 | |||||||||||||||
| 501 | Type : Accessor | ||||||||||||||
| 502 | Title : get_margin_bottom | ||||||||||||||
| 503 | Usage : my $margin_bottom = $tree->get_margin_bottom(); | ||||||||||||||
| 504 | Function: Gets margin_bottom | ||||||||||||||
| 505 | Returns : margin_bottom | ||||||||||||||
| 506 | Args : NONE | ||||||||||||||
| 507 | |||||||||||||||
| 508 | =item get_margin_left() | ||||||||||||||
| 509 | |||||||||||||||
| 510 | Type : Accessor | ||||||||||||||
| 511 | Title : get_margin_left | ||||||||||||||
| 512 | Usage : my $margin_left = $tree->get_margin_left(); | ||||||||||||||
| 513 | Function: Gets margin_left | ||||||||||||||
| 514 | Returns : margin_left | ||||||||||||||
| 515 | Args : NONE | ||||||||||||||
| 516 | |||||||||||||||
| 517 | =item get_margin_right() | ||||||||||||||
| 518 | |||||||||||||||
| 519 | Type : Accessor | ||||||||||||||
| 520 | Title : get_margin_right | ||||||||||||||
| 521 | Usage : my $margin_right = $tree->get_margin_right(); | ||||||||||||||
| 522 | Function: Gets margin_right | ||||||||||||||
| 523 | Returns : margin_right | ||||||||||||||
| 524 | Args : NONE | ||||||||||||||
| 525 | |||||||||||||||
| 526 | =item get_padding() | ||||||||||||||
| 527 | |||||||||||||||
| 528 | Type : Accessor | ||||||||||||||
| 529 | Title : get_padding | ||||||||||||||
| 530 | Usage : my $padding = $tree->get_padding(); | ||||||||||||||
| 531 | Function: Gets padding | ||||||||||||||
| 532 | Returns : padding | ||||||||||||||
| 533 | Args : NONE | ||||||||||||||
| 534 | |||||||||||||||
| 535 | =item get_padding_top() | ||||||||||||||
| 536 | |||||||||||||||
| 537 | Type : Accessor | ||||||||||||||
| 538 | Title : get_padding_top | ||||||||||||||
| 539 | Usage : my $padding_top = $tree->get_padding_top(); | ||||||||||||||
| 540 | Function: Gets padding_top | ||||||||||||||
| 541 | Returns : padding_top | ||||||||||||||
| 542 | Args : NONE | ||||||||||||||
| 543 | |||||||||||||||
| 544 | =item get_padding_bottom() | ||||||||||||||
| 545 | |||||||||||||||
| 546 | Type : Accessor | ||||||||||||||
| 547 | Title : get_padding_bottom | ||||||||||||||
| 548 | Usage : my $padding_bottom = $tree->get_padding_bottom(); | ||||||||||||||
| 549 | Function: Gets padding_bottom | ||||||||||||||
| 550 | Returns : padding_bottom | ||||||||||||||
| 551 | Args : NONE | ||||||||||||||
| 552 | |||||||||||||||
| 553 | =item get_padding_left() | ||||||||||||||
| 554 | |||||||||||||||
| 555 | Type : Accessor | ||||||||||||||
| 556 | Title : get_padding_left | ||||||||||||||
| 557 | Usage : my $padding_left = $tree->get_padding_left(); | ||||||||||||||
| 558 | Function: Gets padding_left | ||||||||||||||
| 559 | Returns : padding_left | ||||||||||||||
| 560 | Args : NONE | ||||||||||||||
| 561 | |||||||||||||||
| 562 | =item get_padding_right() | ||||||||||||||
| 563 | |||||||||||||||
| 564 | Type : Accessor | ||||||||||||||
| 565 | Title : get_padding_right | ||||||||||||||
| 566 | Usage : my $padding_right = $tree->get_padding_right(); | ||||||||||||||
| 567 | Function: Gets padding_right | ||||||||||||||
| 568 | Returns : padding_right | ||||||||||||||
| 569 | Args : NONE | ||||||||||||||
| 570 | |||||||||||||||
| 571 | =item get_mode() | ||||||||||||||
| 572 | |||||||||||||||
| 573 | Type : Accessor | ||||||||||||||
| 574 | Title : get_mode | ||||||||||||||
| 575 | Usage : my $mode = $tree->get_mode(); | ||||||||||||||
| 576 | Function: Gets mode | ||||||||||||||
| 577 | Returns : mode | ||||||||||||||
| 578 | Args : NONE | ||||||||||||||
| 579 | |||||||||||||||
| 580 | =cut | ||||||||||||||
| 581 | |||||||||||||||
| 582 | 1 | ▶ | sub get_mode { | ||||||||||||
|
Subroutine
get_mode: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||
| 583 | 1 | my $self = shift; | |||||||||||||
| 584 | 1 | ▶ | if ( $self->is_cladogram ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 585 | 1 | return 'CLADO'; | |||||||||||||
| 586 | } | ||||||||||||||
| 587 | 0 | return $self->get_meta_object( 'map:mode' ); | |||||||||||||
| 588 | } | ||||||||||||||
| 589 | |||||||||||||||
| 590 | =item get_shape() | ||||||||||||||
| 591 | |||||||||||||||
| 592 | Type : Accessor | ||||||||||||||
| 593 | Title : get_shape | ||||||||||||||
| 594 | Usage : my $shape = $tree->get_shape(); | ||||||||||||||
| 595 | Function: Gets shape | ||||||||||||||
| 596 | Returns : shape | ||||||||||||||
| 597 | Args : NONE | ||||||||||||||
| 598 | |||||||||||||||
| 599 | =item get_text_horiz_offset() | ||||||||||||||
| 600 | |||||||||||||||
| 601 | Type : Accessor | ||||||||||||||
| 602 | Title : get_text_horiz_offset | ||||||||||||||
| 603 | Usage : my $text_horiz_offset = $tree->get_text_horiz_offset(); | ||||||||||||||
| 604 | Function: Gets text_horiz_offset | ||||||||||||||
| 605 | Returns : text_horiz_offset | ||||||||||||||
| 606 | Args : NONE | ||||||||||||||
| 607 | |||||||||||||||
| 608 | =item get_text_vert_offset() | ||||||||||||||
| 609 | |||||||||||||||
| 610 | Type : Accessor | ||||||||||||||
| 611 | Title : get_text_vert_offset | ||||||||||||||
| 612 | Usage : my $text_vert_offset = $tree->get_text_vert_offset(); | ||||||||||||||
| 613 | Function: Gets text_vert_offset | ||||||||||||||
| 614 | Returns : text_vert_offset | ||||||||||||||
| 615 | Args : NONE | ||||||||||||||
| 616 | |||||||||||||||
| 617 | =begin comment | ||||||||||||||
| 618 | |||||||||||||||
| 619 | This method re-computes the node coordinates | ||||||||||||||
| 620 | |||||||||||||||
| 621 | =end comment | ||||||||||||||
| 622 | |||||||||||||||
| 623 | =cut | ||||||||||||||
| 624 | |||||||||||||||
| 625 | 29 | ▶ | sub _redraw { | ||||||||||||
|
Subroutine
_redraw: called CC=2 SCAR=14.0
| |||||||||||||||
| 626 | 29 | my $self = shift; | |||||||||||||
| 627 | 29 | my ( $width, $height ) = ( $self->get_width, $self->get_height ); | |||||||||||||
| 628 | 29 | my $tips_seen = 0; | |||||||||||||
| 629 | 29 | my $total_tips = $self->calc_number_of_terminals(); | |||||||||||||
| 630 | 29 | ▶ | if ( my $root = $self->get_root ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 631 | 0 | my $tallest = $root->calc_max_path_to_tips; | |||||||||||||
| 632 | 0 | my $maxnodes = $root->calc_max_nodes_to_tips; | |||||||||||||
| 633 | 0 | my $is_clado = $self->get_mode =~ m/^c/i; | |||||||||||||
| 634 | $self->visit_depth_first( | ||||||||||||||
| 635 | 0 | ▶ | '-post' => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||
| 636 | 0 | my $node = shift; | |||||||||||||
| 637 | 0 | my ( $x, $y ); | |||||||||||||
| 638 | 0 | ▶ | if ( $node->is_terminal ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 639 | 0 | $tips_seen++; | |||||||||||||
| 640 | 0 | $y = ( $height / $total_tips ) * $tips_seen; | |||||||||||||
| 641 | 0 | ▶ | $x = | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 642 | $is_clado | ||||||||||||||
| 643 | ? $width | ||||||||||||||
| 644 | : ( $width / $tallest ) * $node->calc_path_to_root; | ||||||||||||||
| 645 | } | ||||||||||||||
| 646 | else { | ||||||||||||||
| 647 | 0 | my @children = @{ $node->get_children }; | |||||||||||||
| 648 | 0 | $y += $_->get_y for @children; | |||||||||||||
| 649 | 0 | $y /= scalar @children; | |||||||||||||
| 650 | 0 | ▶ | $x = | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 651 | $is_clado | ||||||||||||||
| 652 | ? $width - | ||||||||||||||
| 653 | ( ( $width / $maxnodes ) * $node->calc_max_nodes_to_tips ) | ||||||||||||||
| 654 | : ( $width / $tallest ) * $node->calc_path_to_root; | ||||||||||||||
| 655 | } | ||||||||||||||
| 656 | 0 | $node->set_y($y); | |||||||||||||
| 657 | 0 | $node->set_x($x); | |||||||||||||
| 658 | } | ||||||||||||||
| 659 | 0 | ); | |||||||||||||
| 660 | } | ||||||||||||||
| 661 | } | ||||||||||||||
| 662 | |||||||||||||||
| 663 | |||||||||||||||
| 664 | =back | ||||||||||||||
| 665 | |||||||||||||||
| 666 | =cut | ||||||||||||||
| 667 | |||||||||||||||
| 668 | 116 | ▶ | sub AUTOLOAD { | ||||||||||||
|
Subroutine
AUTOLOAD: called CC=8 SCAR=22.0
| |||||||||||||||
| 669 | 116 | my $self = shift; | |||||||||||||
| 670 | 116 | my $method = $AUTOLOAD; | |||||||||||||
| 671 | 116 | $method =~ s/.+://; # strip package names | |||||||||||||
| 672 | 116 | $method =~ s/colour/color/; # map Canadian/British to American :) | |||||||||||||
| 673 | |||||||||||||||
| 674 | # if the user calls some non-existant method, try to do the | ||||||||||||||
| 675 | # usual way, with this message, from perspective of caller | ||||||||||||||
| 676 | 116 | my $template = 'Can\'t locate object method "%s" via package "%s"'; | |||||||||||||
| 677 | |||||||||||||||
| 678 | # handler set_* method calls | ||||||||||||||
| 679 | 116 | ▶ | if ( $method =~ /^set_(.+)$/ ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 680 | 29 | my $prop = $1; | |||||||||||||
| 681 | |||||||||||||||
| 682 | # test if this is actually settable | ||||||||||||||
| 683 | 29 | ▶ | if ( grep { /^\Q$prop\E$/ } @properties ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 684 | 29 | my $value = shift; | |||||||||||||
| 685 | |||||||||||||||
| 686 | # these are properties that must be applied to all nodes | ||||||||||||||
| 687 | 29 | ▶ | if ( $prop =~ /_(?:node|tip|branch|clade|font|text)_/ ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 688 | 0 | ▶ | $self->visit(sub{ | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 689 | 0 | my $node = shift; | |||||||||||||
| 690 | 0 | $node->$method($value); | |||||||||||||
| 691 | 1 | }); | |||||||||||||
| 692 | } | ||||||||||||||
| 693 | |||||||||||||||
| 694 | # these are properties that must be expanded to left/right/top/bottom | ||||||||||||||
| 695 | 29 | ▶ | if ( $prop =~ /_(?:margin|padding)$/ ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 696 | 0 | for my $pos ( qw(left right top bottom) ) { | |||||||||||||
| 697 | 0 | my $expanded = $method . '_' . $pos; | |||||||||||||
| 698 | 0 | $self->$expanded($value); | |||||||||||||
| 699 | } | ||||||||||||||
| 700 | } | ||||||||||||||
| 701 | |||||||||||||||
| 702 | # also apply the property to the tree itself | ||||||||||||||
| 703 | 29 | $self->set_meta_object( "map:$prop" => $value ); | |||||||||||||
| 704 | 29 | $self->_redraw; | |||||||||||||
| 705 | 29 | return $self; | |||||||||||||
| 706 | } | ||||||||||||||
| 707 | else { | ||||||||||||||
| 708 | 0 | croak sprintf $template, $method, __PACKAGE__; | |||||||||||||
| 709 | } | ||||||||||||||
| 710 | } | ||||||||||||||
| 711 | elsif ( $method =~ /^get_(.+)$/ ) { | ||||||||||||||
| 712 | 86 | my $prop = $1; | |||||||||||||
| 713 | |||||||||||||||
| 714 | # test if this is actually gettable | ||||||||||||||
| 715 | 86 | ▶ | if ( grep { /^\Q$prop\E$/ } @properties ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 716 | |||||||||||||||
| 717 | # return the annotation | ||||||||||||||
| 718 | 86 | return $self->get_meta_object( "map:$prop" ); | |||||||||||||
| 719 | } | ||||||||||||||
| 720 | else { | ||||||||||||||
| 721 | 0 | croak sprintf $template, $method, __PACKAGE__; | |||||||||||||
| 722 | } | ||||||||||||||
| 723 | } | ||||||||||||||
| 724 | else { | ||||||||||||||
| 725 | 1 | croak sprintf $template, $method, __PACKAGE__; | |||||||||||||
| 726 | } | ||||||||||||||
| 727 | } | ||||||||||||||
| 728 | |||||||||||||||
| 729 | # podinherit_insert_token | ||||||||||||||
| 730 | |||||||||||||||
| 731 | =head1 SEE ALSO | ||||||||||||||
| 732 | |||||||||||||||
| 733 | There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> | ||||||||||||||
| 734 | for any user or developer questions and discussions. | ||||||||||||||
| 735 | |||||||||||||||
| 736 | =over | ||||||||||||||
| 737 | |||||||||||||||
| 738 | =item L<Bio::Phylo::Forest::Tree> | ||||||||||||||
| 739 | |||||||||||||||
| 740 | This object inherits from L<Bio::Phylo::Forest::Tree>, so methods | ||||||||||||||
| 741 | defined there are also applicable here. | ||||||||||||||
| 742 | |||||||||||||||
| 743 | =item L<Bio::Phylo::Manual> | ||||||||||||||
| 744 | |||||||||||||||
| 745 | Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. | ||||||||||||||
| 746 | |||||||||||||||
| 747 | =back | ||||||||||||||
| 748 | |||||||||||||||
| 749 | =head1 CITATION | ||||||||||||||
| 750 | |||||||||||||||
| 751 | If you use Bio::Phylo in published research, please cite it: | ||||||||||||||
| 752 | |||||||||||||||
| 753 | B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> | ||||||||||||||
| 754 | and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. | ||||||||||||||
| 755 | I<BMC Bioinformatics> B<12>:63. | ||||||||||||||
| 756 | L<http://dx.doi.org/10.1186/1471-2105-12-63> | ||||||||||||||
| 757 | |||||||||||||||
| 758 | =cut | ||||||||||||||
| 759 | |||||||||||||||
| 760 | } | ||||||||||||||
| 761 | 31 | 1; | |||||||||||||