line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::PhyloRole; |
2
|
57
|
|
|
57
|
|
306
|
use strict; |
|
57
|
|
|
|
|
104
|
|
|
57
|
|
|
|
|
1577
|
|
3
|
57
|
|
|
57
|
|
264
|
use base 'Bio::Phylo::Identifiable'; |
|
57
|
|
|
|
|
99
|
|
|
57
|
|
|
|
|
14448
|
|
4
|
57
|
|
|
57
|
|
17599
|
use Data::Dumper; |
|
57
|
|
|
|
|
228257
|
|
|
57
|
|
|
|
|
3204
|
|
5
|
57
|
|
|
57
|
|
10347
|
use Bio::Phylo::Util::CONSTANT '/looks_like/'; |
|
57
|
|
|
|
|
908
|
|
|
57
|
|
|
|
|
10636
|
|
6
|
57
|
|
|
57
|
|
378
|
use Bio::Phylo::Identifiable; # for storing unique IDs inside an instance |
|
57
|
|
|
|
|
110
|
|
|
57
|
|
|
|
|
1460
|
|
7
|
57
|
|
|
57
|
|
267
|
use Bio::Phylo::Util::Exceptions 'throw'; # defines exception classes and throws |
|
57
|
|
|
|
|
105
|
|
|
57
|
|
|
|
|
2058
|
|
8
|
57
|
|
|
57
|
|
14045
|
use Bio::Phylo::Util::Logger; # for logging, like log4perl/log4j |
|
57
|
|
|
|
|
200
|
|
|
57
|
|
|
|
|
29030
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Bio::PhyloRole - Extra behaviours for the base class |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Actually, you would almost never use this module directly. This is |
17
|
|
|
|
|
|
|
# the base class for other modules. |
18
|
|
|
|
|
|
|
use Bio::Phylo; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# sets global verbosity to 'error' |
21
|
|
|
|
|
|
|
Bio::Phylo->VERBOSE( -level => Bio::Phylo::Util::Logger::ERROR ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# sets verbosity for forest ojects to 'debug' |
24
|
|
|
|
|
|
|
Bio::Phylo->VERBOSE( |
25
|
|
|
|
|
|
|
-level => Bio::Phylo::Util::Logger::DEBUG, |
26
|
|
|
|
|
|
|
-class => 'Bio::Phylo::Forest' |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# prints version, including SVN revision number |
30
|
|
|
|
|
|
|
print Bio::Phylo->VERSION; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# prints suggested citation |
33
|
|
|
|
|
|
|
print Bio::Phylo->CITATION; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This is the base class for the Bio::Phylo package for phylogenetic analysis using |
38
|
|
|
|
|
|
|
object-oriented perl5. In this file, methods are defined that are performed by other |
39
|
|
|
|
|
|
|
objects in the Bio::Phylo release that inherit from this base class (which you normally |
40
|
|
|
|
|
|
|
wouldn't use directly). |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
For general information on how to use Bio::Phylo, consult the manual |
43
|
|
|
|
|
|
|
(L<Bio::Phylo::Manual>). |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
If you come here because you are trying to debug a problem you run into in |
46
|
|
|
|
|
|
|
using Bio::Phylo, you may be interested in the "exceptions" system as discussed |
47
|
|
|
|
|
|
|
in L<Bio::Phylo::Util::Exceptions>. In addition, you may find the logging system |
48
|
|
|
|
|
|
|
in L<Bio::Phylo::Util::Logger> of use to localize problems. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 ACCESSORS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item get_nexus_name() |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Gets invocant's name, modified to be safely used in nexus files. This means that: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item names with spaces in them that aren't 'single quoted' have their spaces replaced |
61
|
|
|
|
|
|
|
with underscores |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item names with any of the following characters in them are single quoted: |
64
|
|
|
|
|
|
|
-^*(){}[]+=;:"\<>/, |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item names with single quotes inside them (i.e. not around them) are "double quoted" |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Type : Accessor |
69
|
|
|
|
|
|
|
Title : get_nexus_name |
70
|
|
|
|
|
|
|
Usage : my $name = $obj->get_nexus_name; |
71
|
|
|
|
|
|
|
Function: Returns the object's name. |
72
|
|
|
|
|
|
|
Returns : A string |
73
|
|
|
|
|
|
|
Args : (Optional) if provided a true value, the returned name may be the null |
74
|
|
|
|
|
|
|
string, in cases where no name for the object has been set. The default |
75
|
|
|
|
|
|
|
value (i.e. if no argument was provided) is to return an autogenerated |
76
|
|
|
|
|
|
|
name for any anonymous object. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub get_nexus_name { |
81
|
2641
|
|
|
2641
|
1
|
3925
|
my ($self,$no_internal) = @_; |
82
|
2641
|
100
|
|
|
|
5315
|
my $name = $no_internal ? $self->get_name : $self->get_internal_name; |
83
|
2641
|
50
|
|
|
|
4468
|
if ( $name ) { |
84
|
2641
|
50
|
33
|
|
|
6390
|
if ( $name =~ /\s/ && $name !~ /^'.+'$/ ) { |
85
|
0
|
|
|
|
|
0
|
$name =~ s/\s/_/g; |
86
|
|
|
|
|
|
|
} |
87
|
2641
|
100
|
66
|
|
|
6326
|
if ( $name =~ /(?:\-|\^|\*|\(|\)|{|}|\[|\]|\+|=|;|:|"|\\|<|>|\/|,)/ |
88
|
|
|
|
|
|
|
&& $name !~ /^'.+'$/ ) |
89
|
|
|
|
|
|
|
{ |
90
|
49
|
|
|
|
|
108
|
$name = "'${name}'"; |
91
|
|
|
|
|
|
|
} |
92
|
2641
|
50
|
66
|
|
|
5582
|
if ( $name =~ /'/ && $name !~ /^".+"$/ && $name !~ /^'.+'$/ ) { |
|
|
|
66
|
|
|
|
|
93
|
0
|
|
|
|
|
0
|
$name = "\"${name}\""; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
2641
|
|
|
|
|
5559
|
return $name; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item get_internal_name() |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Gets invocant's 'fallback' name (possibly autogenerated). |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Type : Accessor |
104
|
|
|
|
|
|
|
Title : get_internal_name |
105
|
|
|
|
|
|
|
Usage : my $name = $obj->get_internal_name; |
106
|
|
|
|
|
|
|
Function: Returns the object's name (if none was set, the name |
107
|
|
|
|
|
|
|
is a combination of the $obj's class and its UID). |
108
|
|
|
|
|
|
|
Returns : A string |
109
|
|
|
|
|
|
|
Args : None |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get_internal_name { |
114
|
1480
|
|
|
1480
|
1
|
2189
|
my $self = shift; |
115
|
1480
|
100
|
|
|
|
3839
|
if ( my $name = $self->get_name ) { |
116
|
1341
|
|
|
|
|
3476
|
return $name; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else { |
119
|
139
|
|
|
|
|
231
|
my $internal_name = ref $self; |
120
|
139
|
|
|
|
|
586
|
$internal_name =~ s/.*:://; |
121
|
139
|
|
|
|
|
320
|
$internal_name .= $self->get_id; |
122
|
139
|
|
|
|
|
435
|
return $internal_name; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 PACKAGE METHODS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item get() |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Attempts to execute argument string as method on invocant. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Type : Accessor |
137
|
|
|
|
|
|
|
Title : get |
138
|
|
|
|
|
|
|
Usage : my $treename = $tree->get('get_name'); |
139
|
|
|
|
|
|
|
Function: Alternative syntax for safely accessing |
140
|
|
|
|
|
|
|
any of the object data; useful for |
141
|
|
|
|
|
|
|
interpolating runtime $vars. |
142
|
|
|
|
|
|
|
Returns : (context dependent) |
143
|
|
|
|
|
|
|
Args : a SCALAR variable, e.g. $var = 'get_name'; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub get { |
148
|
544
|
|
|
544
|
1
|
1033
|
my ( $self, $var ) = @_; |
149
|
544
|
100
|
|
|
|
1191
|
if ( $self->can($var) ) { |
150
|
534
|
|
|
|
|
1010
|
return $self->$var; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
else { |
153
|
10
|
|
|
|
|
23
|
my $ref = ref $self; |
154
|
10
|
|
|
|
|
47
|
throw 'UnknownMethod' => "sorry, a '$ref' can't '$var'"; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item to_string() |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Serializes object to general purpose string |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Type : Serializer |
163
|
|
|
|
|
|
|
Title : to_string() |
164
|
|
|
|
|
|
|
Usage : print $obj->to_string(); |
165
|
|
|
|
|
|
|
Function: Serializes object to general purpose string |
166
|
|
|
|
|
|
|
Returns : String |
167
|
|
|
|
|
|
|
Args : None |
168
|
|
|
|
|
|
|
Comments: This is YAML |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub to_string { |
173
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
174
|
0
|
|
|
|
|
0
|
my $class = ref $self; |
175
|
0
|
|
|
|
|
0
|
my $id = $self->get_id; |
176
|
0
|
|
|
|
|
0
|
my $internal_name = $self->get_internal_name; |
177
|
0
|
|
0
|
|
|
0
|
my $name = $self->get_name || ''; |
178
|
0
|
|
0
|
|
|
0
|
my $score = $self->get_score || ''; |
179
|
0
|
|
0
|
|
|
0
|
my $desc = $self->get_desc || ''; |
180
|
0
|
|
0
|
|
|
0
|
my $gen = Dumper($self->get_generic) || ''; |
181
|
0
|
|
|
|
|
0
|
return <<"SERIALIZED_OBJECT"; |
182
|
|
|
|
|
|
|
class: $class |
183
|
|
|
|
|
|
|
id: $id |
184
|
|
|
|
|
|
|
internal_name: $internal_name |
185
|
|
|
|
|
|
|
name: $name |
186
|
|
|
|
|
|
|
score: $score |
187
|
|
|
|
|
|
|
desc: $desc |
188
|
|
|
|
|
|
|
generic: $gen |
189
|
|
|
|
|
|
|
SERIALIZED_OBJECT |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item VERBOSE() |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Getter and setter for the verbosity level. Refer to L<Bio::Phylo::Util::Logger> for more |
195
|
|
|
|
|
|
|
info on available verbosity levels. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Type : Accessor |
198
|
|
|
|
|
|
|
Title : VERBOSE() |
199
|
|
|
|
|
|
|
Usage : Bio::Phylo->VERBOSE( -level => $level ) |
200
|
|
|
|
|
|
|
Function: Sets/gets verbose level |
201
|
|
|
|
|
|
|
Returns : Verbose level |
202
|
|
|
|
|
|
|
Args : -level => $level |
203
|
|
|
|
|
|
|
Comments: |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# Verbosity is mostly handled by the logger, actually. This method |
208
|
|
|
|
|
|
|
# is just here for backward compatibility (and ease of use). |
209
|
|
|
|
|
|
|
# TODO have a facility to turn log levels (warn/error/fatal) into |
210
|
|
|
|
|
|
|
# throws |
211
|
|
|
|
|
|
|
sub VERBOSE { |
212
|
12
|
|
|
12
|
1
|
993
|
my $class = shift; |
213
|
12
|
50
|
|
|
|
47
|
if (@_) { |
214
|
12
|
|
|
|
|
60
|
my %opt = looks_like_hash @_; |
215
|
12
|
|
|
|
|
70
|
Bio::Phylo::Util::Logger::VERBOSE(%opt); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
} |
218
|
12
|
|
|
|
|
36
|
return $Bio::Phylo::Util::Logger::VERBOSE; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item CITATION() |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Returns suggested citation. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Type : Accessor |
226
|
|
|
|
|
|
|
Title : CITATION |
227
|
|
|
|
|
|
|
Usage : $phylo->CITATION; |
228
|
|
|
|
|
|
|
Function: Returns suggested citation. |
229
|
|
|
|
|
|
|
Returns : Returns suggested citation. |
230
|
|
|
|
|
|
|
Args : None |
231
|
|
|
|
|
|
|
Comments: |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=cut |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub CITATION { |
236
|
1
|
|
|
1
|
1
|
4
|
return <<'CITATION'; |
237
|
|
|
|
|
|
|
Rutger A Vos, Jason Caravas, Klaas Hartmann, Mark A Jensen and Chase Miller, 2011. |
238
|
|
|
|
|
|
|
Bio::Phylo - phyloinformatic analysis using Perl. BMC Bioinformatics 12:63. |
239
|
|
|
|
|
|
|
doi:10.1186/1471-2105-12-63 |
240
|
|
|
|
|
|
|
CITATION |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=back |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 SEE ALSO |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> |
248
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 CITATION |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
257
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
258
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
259
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=cut |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
1; |