| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# BioPerl module for Bio::Tree::NodeNHX |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Please direct questions and support issues to |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Cared for by Aaron Mackey |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Copyright Aaron Mackey |
|
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::Tree::NodeNHX - A Simple Tree Node with support for NHX tags |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Bio::Tree::NodeNHX; |
|
21
|
|
|
|
|
|
|
my $nodeA = Bio::Tree::NodeNHX->new(); |
|
22
|
|
|
|
|
|
|
my $nodeL = Bio::Tree::NodeNHX->new(); |
|
23
|
|
|
|
|
|
|
my $nodeR = Bio::Tree::NodeNHX->new(); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $node = Bio::Tree::NodeNHX->new(); |
|
26
|
|
|
|
|
|
|
$node->add_Descendents($nodeL); |
|
27
|
|
|
|
|
|
|
$node->add_Descendents($nodeR); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
print "node is not a leaf \n" if( $node->is_leaf); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Makes a Tree Node with NHX tags, suitable for building a Tree. See |
|
34
|
|
|
|
|
|
|
L for a full list of functionality. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 FEEDBACK |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Mailing Lists |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this and other |
|
41
|
|
|
|
|
|
|
Bioperl modules. Send your comments and suggestions preferably to |
|
42
|
|
|
|
|
|
|
the Bioperl mailing list. Your participation is much appreciated. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
bioperl-l@bioperl.org - General discussion |
|
45
|
|
|
|
|
|
|
http://bioperl.org/wiki/Mailing_lists - About the mailing lists |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Support |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
I |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
|
54
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
|
55
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
|
56
|
|
|
|
|
|
|
with code and data examples if at all possible. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 Reporting Bugs |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
|
61
|
|
|
|
|
|
|
of the bugs and their resolution. Bug reports can be submitted via |
|
62
|
|
|
|
|
|
|
the web: |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
https://github.com/bioperl/bioperl-live/issues |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR - Aaron Mackey |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Email amackey@virginia.edu |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The NHX (New Hampshire eXtended) format was created by Chris Zmasek, |
|
73
|
|
|
|
|
|
|
and is described at: |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
http://sourceforge.net/projects/forester-atv/ |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 APPENDIX |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The rest of the documentation details each of the object methods. |
|
80
|
|
|
|
|
|
|
Internal methods are usually preceded with a _ |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Let the code begin... |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
package Bio::Tree::NodeNHX; |
|
88
|
5
|
|
|
5
|
|
16
|
use strict; |
|
|
5
|
|
|
|
|
4
|
|
|
|
5
|
|
|
|
|
132
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
5
|
|
|
5
|
|
15
|
use base qw(Bio::Tree::Node); |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
1957
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 new |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Title : new |
|
96
|
|
|
|
|
|
|
Usage : my $obj = Bio::Tree::NodeNHX->new(); |
|
97
|
|
|
|
|
|
|
Function: Builds a new Bio::Tree::NodeNHX object |
|
98
|
|
|
|
|
|
|
Returns : Bio::Tree::NodeNHX |
|
99
|
|
|
|
|
|
|
Args : -left => pointer to Left descendent (optional) |
|
100
|
|
|
|
|
|
|
-right => pointer to Right descenent (optional) |
|
101
|
|
|
|
|
|
|
-branch_length => branch length [integer] (optional) |
|
102
|
|
|
|
|
|
|
-bootstrap => bootstrap value (string) |
|
103
|
|
|
|
|
|
|
-description => description of node |
|
104
|
|
|
|
|
|
|
-id => unique id for node |
|
105
|
|
|
|
|
|
|
-nhx => hashref of NHX tags and values |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub new { |
|
110
|
550
|
|
|
550
|
1
|
969
|
my($class,@args) = @_; |
|
111
|
|
|
|
|
|
|
|
|
112
|
550
|
|
|
|
|
1167
|
my $self = $class->SUPER::new(@args); |
|
113
|
550
|
|
|
|
|
1212
|
my ($nhx) = $self->_rearrange([qw(NHX)], @args); |
|
114
|
550
|
|
|
|
|
957
|
$self->nhx_tag($nhx); |
|
115
|
550
|
|
|
|
|
1021
|
return $self; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub DESTROY { |
|
119
|
549
|
|
|
549
|
|
381
|
my ($self) = @_; |
|
120
|
|
|
|
|
|
|
# try to insure that everything is cleaned up |
|
121
|
549
|
|
|
|
|
677
|
$self->SUPER::DESTROY(); |
|
122
|
549
|
50
|
33
|
|
|
3118
|
if( defined $self->{'_desc'} && |
|
123
|
|
|
|
|
|
|
ref($self->{'_desc'}) =~ /ARRAY/i ) { |
|
124
|
0
|
|
|
|
|
0
|
while( my ($nodeid,$node) = each %{ $self->{'_desc'} } ) { |
|
|
0
|
|
|
|
|
0
|
|
|
125
|
0
|
|
|
|
|
0
|
$node->{'_ancestor'} = undef; # insure no circular references |
|
126
|
0
|
|
|
|
|
0
|
$node->DESTROY(); |
|
127
|
0
|
|
|
|
|
0
|
$node = undef; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
0
|
|
|
|
|
0
|
$self->{'_desc'} = {}; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub to_string{ |
|
134
|
2492
|
|
|
2492
|
1
|
1798
|
my ($self) = @_; |
|
135
|
2492
|
|
|
|
|
2927
|
my @tags = $self->get_all_tags; |
|
136
|
2492
|
|
|
|
|
2061
|
my $tagstr = ''; |
|
137
|
2492
|
100
|
|
|
|
3438
|
if( scalar(@tags) > 0 ) { |
|
138
|
|
|
|
|
|
|
$tagstr = '[' . join(":", "&&NHX", |
|
139
|
2269
|
|
|
|
|
1852
|
map { "$_=" .join(',', |
|
|
3473
|
|
|
|
|
5073
|
|
|
140
|
|
|
|
|
|
|
$self->get_tag_values($_))} |
|
141
|
|
|
|
|
|
|
@tags ) . ']'; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
2492
|
100
|
|
|
|
3446
|
return sprintf("%s%s%s", |
|
|
|
100
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
defined $self->id ? $self->id : '', |
|
145
|
|
|
|
|
|
|
defined $self->branch_length ? ':' . |
|
146
|
|
|
|
|
|
|
$self->branch_length : ' ', |
|
147
|
|
|
|
|
|
|
$tagstr); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 nhx_tag |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Title : nhx_tag |
|
153
|
|
|
|
|
|
|
Usage : my $tag = $nodenhx->nhx_tag(%tags); |
|
154
|
|
|
|
|
|
|
Function: Set tag-value pairs for NHX nodes |
|
155
|
|
|
|
|
|
|
Returns : none |
|
156
|
|
|
|
|
|
|
Args : hashref to update the tags/value pairs |
|
157
|
|
|
|
|
|
|
OR |
|
158
|
|
|
|
|
|
|
with a scalar value update the bootstrap value by default |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub nhx_tag { |
|
164
|
550
|
|
|
550
|
1
|
452
|
my ($self, $tags) = @_; |
|
165
|
550
|
100
|
66
|
|
|
2473
|
if (defined $tags && (ref($tags) =~ /HASH/i)) { |
|
|
|
50
|
33
|
|
|
|
|
|
166
|
478
|
|
|
|
|
1349
|
while( my ($tag,$val) = each %$tags ) { |
|
167
|
778
|
50
|
|
|
|
934
|
if( ref($val) =~ /ARRAY/i ) { |
|
168
|
0
|
|
|
|
|
0
|
for my $v ( @$val ) { |
|
169
|
0
|
|
|
|
|
0
|
$self->add_tag_value($tag,$v); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} else { |
|
172
|
778
|
|
|
|
|
1152
|
$self->add_tag_value($tag,$val); |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
} |
|
175
|
478
|
100
|
|
|
|
788
|
if (exists $tags->{'B'}) { |
|
176
|
135
|
|
|
|
|
229
|
$self->bootstrap($tags->{'B'}); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
} elsif (defined $tags and ! ref ($tags)) { |
|
179
|
0
|
|
|
|
|
|
$self->debug( "here with $tags\n"); |
|
180
|
|
|
|
|
|
|
# bootstrap by default |
|
181
|
0
|
|
|
|
|
|
$self->bootstrap($tags); |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |