line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Phylo::Util::CONSTANT; |
2
|
57
|
|
|
57
|
|
76652
|
use strict; |
|
57
|
|
|
|
|
173
|
|
|
57
|
|
|
|
|
1685
|
|
3
|
57
|
|
|
57
|
|
290
|
use base 'Exporter'; |
|
57
|
|
|
|
|
106
|
|
|
57
|
|
|
|
|
5865
|
|
4
|
57
|
|
|
57
|
|
352
|
use Scalar::Util 'blessed'; |
|
57
|
|
|
|
|
115
|
|
|
57
|
|
|
|
|
2949
|
|
5
|
57
|
|
|
57
|
|
3719
|
use Bio::Phylo::Util::Exceptions 'throw'; |
|
57
|
|
|
|
|
114
|
|
|
57
|
|
|
|
|
2240
|
|
6
|
57
|
|
|
57
|
|
15129
|
use Bio::Phylo::Util::CONSTANT::Int; |
|
57
|
|
|
|
|
155
|
|
|
57
|
|
|
|
|
8488
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
57
|
|
|
57
|
|
165
|
our ( @EXPORT_OK, %EXPORT_TAGS ); |
10
|
57
|
|
|
|
|
571
|
@EXPORT_OK = qw( |
11
|
|
|
|
|
|
|
_NONE_ |
12
|
|
|
|
|
|
|
_NODE_ |
13
|
|
|
|
|
|
|
_TREE_ |
14
|
|
|
|
|
|
|
_FOREST_ |
15
|
|
|
|
|
|
|
_TAXON_ |
16
|
|
|
|
|
|
|
_TAXA_ |
17
|
|
|
|
|
|
|
_CHAR_ |
18
|
|
|
|
|
|
|
_DATUM_ |
19
|
|
|
|
|
|
|
_MATRIX_ |
20
|
|
|
|
|
|
|
_MATRICES_ |
21
|
|
|
|
|
|
|
_SEQUENCE_ |
22
|
|
|
|
|
|
|
_ALIGNMENT_ |
23
|
|
|
|
|
|
|
_CHARSTATE_ |
24
|
|
|
|
|
|
|
_CHARSTATESEQ_ |
25
|
|
|
|
|
|
|
_MATRIXROW_ |
26
|
|
|
|
|
|
|
_PROJECT_ |
27
|
|
|
|
|
|
|
_ANNOTATION_ |
28
|
|
|
|
|
|
|
_DICTIONARY_ |
29
|
|
|
|
|
|
|
_DOMCREATOR_ |
30
|
|
|
|
|
|
|
_META_ |
31
|
|
|
|
|
|
|
_DESCRIPTION_ |
32
|
|
|
|
|
|
|
_RESOURCE_ |
33
|
|
|
|
|
|
|
_HTTP_SC_SEE_ALSO_ |
34
|
|
|
|
|
|
|
_DOCUMENT_ |
35
|
|
|
|
|
|
|
_ELEMENT_ |
36
|
|
|
|
|
|
|
_CHARACTERS_ |
37
|
|
|
|
|
|
|
_CHARACTER_ |
38
|
|
|
|
|
|
|
_SET_ |
39
|
|
|
|
|
|
|
_MODEL_ |
40
|
|
|
|
|
|
|
_OPERATION_ |
41
|
|
|
|
|
|
|
_DATATYPE_ |
42
|
|
|
|
|
|
|
looks_like_number |
43
|
|
|
|
|
|
|
looks_like_object |
44
|
|
|
|
|
|
|
looks_like_hash |
45
|
|
|
|
|
|
|
looks_like_class |
46
|
|
|
|
|
|
|
looks_like_instance |
47
|
|
|
|
|
|
|
looks_like_implementor |
48
|
|
|
|
|
|
|
_NS_OWL_ |
49
|
|
|
|
|
|
|
_NS_DC_ |
50
|
|
|
|
|
|
|
_NS_DCTERMS_ |
51
|
|
|
|
|
|
|
_NS_NEXML_ |
52
|
|
|
|
|
|
|
_NS_RDF_ |
53
|
|
|
|
|
|
|
_NS_RDFS_ |
54
|
|
|
|
|
|
|
_NS_XSI_ |
55
|
|
|
|
|
|
|
_NS_XSD_ |
56
|
|
|
|
|
|
|
_NS_XML_ |
57
|
|
|
|
|
|
|
_NS_TOL_ |
58
|
|
|
|
|
|
|
_NS_CDAO_ |
59
|
|
|
|
|
|
|
_NS_BIOPHYLO_ |
60
|
|
|
|
|
|
|
_NS_SKOS_ |
61
|
|
|
|
|
|
|
_NEXML_VERSION_ |
62
|
|
|
|
|
|
|
_PI_ |
63
|
|
|
|
|
|
|
_NS_PHYLOXML_ |
64
|
|
|
|
|
|
|
_NS_TB2PURL_ |
65
|
|
|
|
|
|
|
_NS_TNRS_ |
66
|
|
|
|
|
|
|
_NS_FIGTREE_ |
67
|
|
|
|
|
|
|
_NS_PHYLOMAP_ |
68
|
|
|
|
|
|
|
_NS_BIOVEL_ |
69
|
|
|
|
|
|
|
_NS_NHX_ |
70
|
|
|
|
|
|
|
_NS_DWC_ |
71
|
|
|
|
|
|
|
_NS_GBIF_ |
72
|
|
|
|
|
|
|
); |
73
|
57
|
|
|
|
|
63299
|
%EXPORT_TAGS = ( |
74
|
|
|
|
|
|
|
'all' => [@EXPORT_OK], |
75
|
|
|
|
|
|
|
'objecttypes' => [ |
76
|
|
|
|
|
|
|
qw( |
77
|
|
|
|
|
|
|
_NONE_ |
78
|
|
|
|
|
|
|
_NODE_ |
79
|
|
|
|
|
|
|
_TREE_ |
80
|
|
|
|
|
|
|
_FOREST_ |
81
|
|
|
|
|
|
|
_TAXON_ |
82
|
|
|
|
|
|
|
_TAXA_ |
83
|
|
|
|
|
|
|
_CHAR_ |
84
|
|
|
|
|
|
|
_DATUM_ |
85
|
|
|
|
|
|
|
_MATRIX_ |
86
|
|
|
|
|
|
|
_MATRICES_ |
87
|
|
|
|
|
|
|
_SEQUENCE_ |
88
|
|
|
|
|
|
|
_ALIGNMENT_ |
89
|
|
|
|
|
|
|
_CHARSTATE_ |
90
|
|
|
|
|
|
|
_CHARSTATESEQ_ |
91
|
|
|
|
|
|
|
_MATRIXROW_ |
92
|
|
|
|
|
|
|
_PROJECT_ |
93
|
|
|
|
|
|
|
_ANNOTATION_ |
94
|
|
|
|
|
|
|
_DICTIONARY_ |
95
|
|
|
|
|
|
|
_DOMCREATOR_ |
96
|
|
|
|
|
|
|
_META_ |
97
|
|
|
|
|
|
|
_DESCRIPTION_ |
98
|
|
|
|
|
|
|
_RESOURCE_ |
99
|
|
|
|
|
|
|
_HTTP_SC_SEE_ALSO_ |
100
|
|
|
|
|
|
|
_DOCUMENT_ |
101
|
|
|
|
|
|
|
_ELEMENT_ |
102
|
|
|
|
|
|
|
_CHARACTERS_ |
103
|
|
|
|
|
|
|
_CHARACTER_ |
104
|
|
|
|
|
|
|
_SET_ |
105
|
|
|
|
|
|
|
_MODEL_ |
106
|
|
|
|
|
|
|
_OPERATION_ |
107
|
|
|
|
|
|
|
_DATATYPE_ |
108
|
|
|
|
|
|
|
) |
109
|
|
|
|
|
|
|
], |
110
|
|
|
|
|
|
|
'functions' => [ |
111
|
|
|
|
|
|
|
qw( |
112
|
|
|
|
|
|
|
looks_like_number |
113
|
|
|
|
|
|
|
looks_like_object |
114
|
|
|
|
|
|
|
looks_like_hash |
115
|
|
|
|
|
|
|
looks_like_class |
116
|
|
|
|
|
|
|
looks_like_instance |
117
|
|
|
|
|
|
|
looks_like_implementor |
118
|
|
|
|
|
|
|
) |
119
|
|
|
|
|
|
|
], |
120
|
|
|
|
|
|
|
'namespaces' => [ |
121
|
|
|
|
|
|
|
qw( |
122
|
|
|
|
|
|
|
_NS_OWL_ |
123
|
|
|
|
|
|
|
_NS_DC_ |
124
|
|
|
|
|
|
|
_NS_DCTERMS_ |
125
|
|
|
|
|
|
|
_NS_NEXML_ |
126
|
|
|
|
|
|
|
_NS_RDF_ |
127
|
|
|
|
|
|
|
_NS_RDFS_ |
128
|
|
|
|
|
|
|
_NS_XSI_ |
129
|
|
|
|
|
|
|
_NS_XSD_ |
130
|
|
|
|
|
|
|
_NS_XML_ |
131
|
|
|
|
|
|
|
_NS_TOL_ |
132
|
|
|
|
|
|
|
_NS_CDAO_ |
133
|
|
|
|
|
|
|
_NS_BIOPHYLO_ |
134
|
|
|
|
|
|
|
_NS_SKOS_ |
135
|
|
|
|
|
|
|
_NS_PHYLOXML_ |
136
|
|
|
|
|
|
|
_NS_TB2PURL_ |
137
|
|
|
|
|
|
|
_NS_TNRS_ |
138
|
|
|
|
|
|
|
_NS_FIGTREE_ |
139
|
|
|
|
|
|
|
_NS_PHYLOMAP_ |
140
|
|
|
|
|
|
|
_NS_BIOVEL_ |
141
|
|
|
|
|
|
|
_NS_NHX_ |
142
|
|
|
|
|
|
|
_NS_DWC_ |
143
|
|
|
|
|
|
|
_NS_GBIF_ |
144
|
|
|
|
|
|
|
) |
145
|
|
|
|
|
|
|
] |
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# according to perlsub: |
150
|
|
|
|
|
|
|
# "Functions with a prototype of () are potential candidates for inlining. |
151
|
|
|
|
|
|
|
# If the result after optimization and constant folding is either a constant |
152
|
|
|
|
|
|
|
# or a lexically-scoped scalar which has no other references, then it will |
153
|
|
|
|
|
|
|
# be used in place of function calls made without & or do." |
154
|
|
|
|
|
|
|
sub _NS_OWL_ () { 'http://www.w3.org/2002/07/owl#' } |
155
|
|
|
|
|
|
|
sub _NS_DC_ () { 'http://purl.org/dc/elements/1.1/' } |
156
|
|
|
|
|
|
|
sub _NS_DCTERMS_ () { 'http://purl.org/dc/terms/' } |
157
|
|
|
|
|
|
|
sub _NS_NEXML_ () { 'http://www.nexml.org/2009' } |
158
|
|
|
|
|
|
|
sub _NS_RDF_ () { 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' } |
159
|
|
|
|
|
|
|
sub _NS_RDFS_ () { 'http://www.w3.org/2000/01/rdf-schema#' } |
160
|
|
|
|
|
|
|
sub _NS_XSI_ () { 'http://www.w3.org/2001/XMLSchema-instance' } |
161
|
|
|
|
|
|
|
sub _NS_XSD_ () { 'http://www.w3.org/2001/XMLSchema#' } |
162
|
|
|
|
|
|
|
sub _NS_XML_ () { 'http://www.w3.org/XML/1998/namespace' } |
163
|
|
|
|
|
|
|
sub _NS_TOL_ () { 'http://tolweb.org/tree/home.pages/downloadtree.html#' } |
164
|
|
|
|
|
|
|
sub _NS_CDAO_ () { 'http://www.evolutionaryontology.org/cdao/1.0/cdao.owl#' } |
165
|
|
|
|
|
|
|
sub _NS_BIOPHYLO_ () { 'http://search.cpan.org/dist/Bio-Phylo/terms#' } |
166
|
|
|
|
|
|
|
sub _NS_SKOS_ () { 'http://www.w3.org/2004/02/skos/core#' } |
167
|
|
|
|
|
|
|
sub _NS_PHYLOXML_ () { 'http://www.phyloxml.org/1.10/terms#' } |
168
|
|
|
|
|
|
|
sub _NS_TB2PURL_ () { 'http://purl.org/phylo/treebase/phylows/' } |
169
|
|
|
|
|
|
|
sub _NS_TNRS_ () { 'http://phylotastic.org/tnrs/terms#' } |
170
|
|
|
|
|
|
|
sub _NS_FIGTREE_ () { 'http://tree.bio.ed.ac.uk/software/figtree/terms#' } |
171
|
|
|
|
|
|
|
sub _NS_PHYLOMAP_ () { 'http://phylomap.org/terms.owl#' } |
172
|
|
|
|
|
|
|
sub _NS_BIOVEL_ () { 'http://biovel.eu/terms#' } |
173
|
|
|
|
|
|
|
sub _NS_NHX_ () { 'http://sites.google.com/site/cmzmasek/home/software/forester/nhx' } |
174
|
|
|
|
|
|
|
sub _NS_DWC_ () { 'http://rs.tdwg.org/dwc/terms/' } |
175
|
|
|
|
|
|
|
sub _NS_GBIF_ () { 'http://rs.gbif.org/terms/1.0/' } |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
our $NS = { |
178
|
|
|
|
|
|
|
'tnrs' => _NS_TNRS_(), |
179
|
|
|
|
|
|
|
'pxml' => _NS_PHYLOXML_(), |
180
|
|
|
|
|
|
|
'skos' => _NS_SKOS_(), |
181
|
|
|
|
|
|
|
'bp' => _NS_BIOPHYLO_(), |
182
|
|
|
|
|
|
|
'cdao' => _NS_CDAO_(), |
183
|
|
|
|
|
|
|
'tol' => _NS_TOL_(), |
184
|
|
|
|
|
|
|
'xml' => _NS_XML_(), |
185
|
|
|
|
|
|
|
'xsd' => _NS_XSD_(), |
186
|
|
|
|
|
|
|
'xsi' => _NS_XSI_(), |
187
|
|
|
|
|
|
|
'rdf' => _NS_RDF_(), |
188
|
|
|
|
|
|
|
'rdfs' => _NS_RDFS_(), |
189
|
|
|
|
|
|
|
'nex' => _NS_NEXML_(), |
190
|
|
|
|
|
|
|
'dc' => _NS_DC_(), |
191
|
|
|
|
|
|
|
'owl' => _NS_OWL_(), |
192
|
|
|
|
|
|
|
'bv' => _NS_BIOVEL_(), |
193
|
|
|
|
|
|
|
'dcterms' => _NS_DCTERMS_(), |
194
|
|
|
|
|
|
|
'fig' => _NS_FIGTREE_(), |
195
|
|
|
|
|
|
|
'nhx' => _NS_NHX_(), |
196
|
|
|
|
|
|
|
'dwc' => _NS_DWC_(), |
197
|
|
|
|
|
|
|
'gbif' => _NS_GBIF_(), |
198
|
|
|
|
|
|
|
}; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub _NEXML_VERSION_ () { '0.9' } |
201
|
|
|
|
|
|
|
sub _NONE_ () { Bio::Phylo::Util::CONSTANT::Int::_NONE_ } |
202
|
|
|
|
|
|
|
sub _NODE_ () { Bio::Phylo::Util::CONSTANT::Int::_NODE_ } |
203
|
|
|
|
|
|
|
sub _TREE_ () { Bio::Phylo::Util::CONSTANT::Int::_TREE_ } |
204
|
|
|
|
|
|
|
sub _FOREST_ () { Bio::Phylo::Util::CONSTANT::Int::_FOREST_ } |
205
|
|
|
|
|
|
|
sub _TAXON_ () { Bio::Phylo::Util::CONSTANT::Int::_TAXON_ } |
206
|
|
|
|
|
|
|
sub _TAXA_ () { Bio::Phylo::Util::CONSTANT::Int::_TAXA_ } |
207
|
|
|
|
|
|
|
sub _DATUM_ () { Bio::Phylo::Util::CONSTANT::Int::_DATUM_ } |
208
|
|
|
|
|
|
|
sub _MATRIX_ () { Bio::Phylo::Util::CONSTANT::Int::_MATRIX_ } |
209
|
|
|
|
|
|
|
sub _MATRICES_ () { Bio::Phylo::Util::CONSTANT::Int::_MATRICES_ } |
210
|
|
|
|
|
|
|
sub _SEQUENCE_ () { Bio::Phylo::Util::CONSTANT::Int::_SEQUENCE_ } |
211
|
|
|
|
|
|
|
sub _ALIGNMENT_ () { Bio::Phylo::Util::CONSTANT::Int::_ALIGNMENT_ } |
212
|
|
|
|
|
|
|
sub _CHAR_ () { Bio::Phylo::Util::CONSTANT::Int::_CHAR_ } |
213
|
|
|
|
|
|
|
sub _PROJECT_ () { Bio::Phylo::Util::CONSTANT::Int::_PROJECT_ } |
214
|
|
|
|
|
|
|
sub _CHARSTATE_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARSTATE_ } |
215
|
|
|
|
|
|
|
sub _CHARSTATESEQ_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARSTATESEQ_ } |
216
|
|
|
|
|
|
|
sub _MATRIXROW_ () { Bio::Phylo::Util::CONSTANT::Int::_MATRIXROW_ } |
217
|
|
|
|
|
|
|
sub _ANNOTATION_ () { Bio::Phylo::Util::CONSTANT::Int::_ANNOTATION_ } |
218
|
|
|
|
|
|
|
sub _DICTIONARY_ () { Bio::Phylo::Util::CONSTANT::Int::_DICTIONARY_ } |
219
|
|
|
|
|
|
|
sub _DOMCREATOR_ () { Bio::Phylo::Util::CONSTANT::Int::_DOMCREATOR_ } |
220
|
|
|
|
|
|
|
sub _META_ () { Bio::Phylo::Util::CONSTANT::Int::_META_ } |
221
|
|
|
|
|
|
|
sub _DESCRIPTION_ () { Bio::Phylo::Util::CONSTANT::Int::_DESCRIPTION_ } |
222
|
|
|
|
|
|
|
sub _RESOURCE_ () { Bio::Phylo::Util::CONSTANT::Int::_RESOURCE_ } |
223
|
|
|
|
|
|
|
sub _DOCUMENT_ () { Bio::Phylo::Util::CONSTANT::Int::_DOCUMENT_ } |
224
|
|
|
|
|
|
|
sub _ELEMENT_ () { Bio::Phylo::Util::CONSTANT::Int::_ELEMENT_ } |
225
|
|
|
|
|
|
|
sub _CHARACTERS_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARACTERS_ } |
226
|
|
|
|
|
|
|
sub _CHARACTER_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARACTER_ } |
227
|
|
|
|
|
|
|
sub _SET_ () { Bio::Phylo::Util::CONSTANT::Int::_SET_ } |
228
|
|
|
|
|
|
|
sub _MODEL_ () { Bio::Phylo::Util::CONSTANT::Int::_MODEL_ } |
229
|
|
|
|
|
|
|
sub _OPERATION_ () { Bio::Phylo::Util::CONSTANT::Int::_OPERATION_ } |
230
|
|
|
|
|
|
|
sub _DATATYPE_ () { Bio::Phylo::Util::CONSTANT::Int::_DATATYPE_ } |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# for PhyloWS |
233
|
|
|
|
|
|
|
sub _HTTP_SC_SEE_ALSO_ () { '303 See Other' } |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# for tree drawing |
236
|
|
|
|
|
|
|
sub _PI_ () { 4 * atan2(1,1) } |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
# this is a drop in replacement for Scalar::Util's function |
239
|
|
|
|
|
|
|
my $looks_like_number; |
240
|
|
|
|
|
|
|
{ |
241
|
|
|
|
|
|
|
eval { Scalar::Util::looks_like_number(0) }; |
242
|
|
|
|
|
|
|
if ($@) { |
243
|
|
|
|
|
|
|
my $LOOKS_LIKE_NUMBER_RE = |
244
|
|
|
|
|
|
|
qr/^([-+]?\d+(\.\d+)?([eE][-+]\d+)?|Inf|NaN)$/; |
245
|
|
|
|
|
|
|
$looks_like_number = sub { |
246
|
|
|
|
|
|
|
my $num = shift; |
247
|
|
|
|
|
|
|
if ( defined $num and $num =~ $LOOKS_LIKE_NUMBER_RE ) { |
248
|
|
|
|
|
|
|
return 1; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
else { |
251
|
|
|
|
|
|
|
return; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
else { |
256
|
|
|
|
|
|
|
$looks_like_number = \&Scalar::Util::looks_like_number; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
undef($@); |
259
|
|
|
|
|
|
|
} |
260
|
82275
|
|
|
82275
|
1
|
313653
|
sub looks_like_number($) { return $looks_like_number->(shift) } |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub looks_like_object($$) { |
263
|
24434
|
|
|
24434
|
1
|
35518
|
my ( $object, $constant ) = @_; |
264
|
24434
|
|
|
|
|
29938
|
my $type; |
265
|
24434
|
|
|
|
|
31298
|
eval { $type = $object->_type }; |
|
24434
|
|
|
|
|
46152
|
|
266
|
24434
|
100
|
100
|
|
|
65664
|
if ( $@ or $type != $constant ) { |
267
|
20
|
|
|
|
|
59
|
throw 'ObjectMismatch' => 'Invalid object!'; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
else { |
270
|
24414
|
|
|
|
|
59804
|
return 1; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub looks_like_implementor($$) { |
275
|
12603
|
|
|
12603
|
1
|
40540
|
return UNIVERSAL::can( $_[0], $_[1] ); |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub looks_like_instance($$) { |
279
|
90671
|
|
|
90671
|
1
|
173960
|
my ( $object, $class ) = @_; |
280
|
90671
|
100
|
|
|
|
165190
|
if ( ref $object ) { |
281
|
88255
|
100
|
|
|
|
177647
|
if ( blessed $object ) { |
282
|
218
|
|
|
|
|
906
|
return $object->isa($class); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
else { |
285
|
88037
|
|
|
|
|
245995
|
return ref $object eq $class; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
else { |
289
|
2416
|
|
|
|
|
6265
|
return; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub looks_like_hash(@) { |
294
|
17878
|
100
|
|
17878
|
1
|
40735
|
if ( scalar(@_) % 2 ) { |
295
|
1
|
|
|
|
|
3
|
throw 'OddHash' => 'Odd number of elements in hash assignment'; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
else { |
298
|
17877
|
|
|
|
|
49915
|
return @_; |
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub looks_like_class($) { |
303
|
1699
|
|
|
1699
|
1
|
3601
|
my $class = shift; |
304
|
1699
|
|
|
|
|
3835
|
my $path = $class; |
305
|
1699
|
|
|
|
|
8682
|
$path =~ s|::|/|g; |
306
|
1699
|
|
|
|
|
3962
|
$path .= '.pm'; |
307
|
1699
|
100
|
|
|
|
5416
|
if ( not exists $INC{$path} ) { |
308
|
178
|
|
|
|
|
304
|
eval { require $path }; |
|
178
|
|
|
|
|
31836
|
|
309
|
178
|
100
|
|
|
|
776
|
if ($@) { |
310
|
96
|
|
|
|
|
401
|
throw 'ExtensionError' => $@; |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
} |
313
|
1603
|
|
|
|
|
7622
|
return $class; |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
1; |
316
|
|
|
|
|
|
|
__END__ |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 NAME |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Bio::Phylo::Util::CONSTANT - Global constants and utility functions |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head1 DESCRIPTION |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
This package defines globals used in the Bio::Phylo libraries. The constants |
325
|
|
|
|
|
|
|
are called internally by the other packages, they have no direct usage. In |
326
|
|
|
|
|
|
|
addition, several useful subroutines are optionally exported, which are |
327
|
|
|
|
|
|
|
described below. |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=head1 SUBROUTINES |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
The following subroutines are utility functions that can be imported using: |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
use Bio::Phylo::Util::CONSTANT ':functions'; |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
The subroutines use prototypes for more concise syntax, e.g.: |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
looks_like_number $num; |
338
|
|
|
|
|
|
|
looks_like_object $obj, $const; |
339
|
|
|
|
|
|
|
looks_like_hash @_; |
340
|
|
|
|
|
|
|
looks_like_class $class; |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
These subroutines are used for argument processing inside method calls. |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=over |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=item looks_like_instance() |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
Tests if argument 1 looks like an instance of argument 2 |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Type : Utility function |
351
|
|
|
|
|
|
|
Title : looks_like_instance |
352
|
|
|
|
|
|
|
Usage : do 'something' if looks_like_instance $var, $class; |
353
|
|
|
|
|
|
|
Function: Tests whether $var looks like an instance of $class. |
354
|
|
|
|
|
|
|
Returns : TRUE or undef |
355
|
|
|
|
|
|
|
Args : $var = a variable to test, a $class to test against. |
356
|
|
|
|
|
|
|
$class can also be anything returned by ref($var), e.g. |
357
|
|
|
|
|
|
|
'HASH', 'CODE', etc. |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=item looks_like_implementor() |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
Tests if argument 1 implements argument 2 |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
Type : Utility function |
364
|
|
|
|
|
|
|
Title : looks_like_implementor |
365
|
|
|
|
|
|
|
Usage : do 'something' if looks_like_implementor $var, $method; |
366
|
|
|
|
|
|
|
Function: Tests whether $var implements $method |
367
|
|
|
|
|
|
|
Returns : return value of UNIVERSAL::can or undef |
368
|
|
|
|
|
|
|
Args : $var = a variable to test, a $method to test against. |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
=item looks_like_number() |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
Tests if argument looks like a number. |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
Type : Utility function |
375
|
|
|
|
|
|
|
Title : looks_like_number |
376
|
|
|
|
|
|
|
Usage : do 'something' if looks_like_number $var; |
377
|
|
|
|
|
|
|
Function: Tests whether $var looks like a number. |
378
|
|
|
|
|
|
|
Returns : TRUE or undef |
379
|
|
|
|
|
|
|
Args : $var = a variable to test |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=item looks_like_object() |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
Tests if argument looks like an object of specified type constant. |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
Type : Utility function |
386
|
|
|
|
|
|
|
Title : looks_like_object |
387
|
|
|
|
|
|
|
Usage : do 'something' if looks_like_object $obj, $const; |
388
|
|
|
|
|
|
|
Function: Tests whether $obj looks like an object. |
389
|
|
|
|
|
|
|
Returns : TRUE or throws ObjectMismatch |
390
|
|
|
|
|
|
|
Args : $obj = an object to test |
391
|
|
|
|
|
|
|
$const = a constant as defined in this package |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
=item looks_like_hash() |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
Tests if argument looks like a hash. |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Type : Utility function |
398
|
|
|
|
|
|
|
Title : looks_like_hash |
399
|
|
|
|
|
|
|
Usage : do 'something' if looks_like_hash @_; |
400
|
|
|
|
|
|
|
Function: Tests whether argument looks like a hash. |
401
|
|
|
|
|
|
|
Returns : hash (same order as arg) or throws OddHash |
402
|
|
|
|
|
|
|
Args : An array of hopefully even key/value pairs |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=item looks_like_class() |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
Tests if argument looks like a loadable class name. |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
Type : Utility function |
409
|
|
|
|
|
|
|
Title : looks_like_class |
410
|
|
|
|
|
|
|
Usage : do 'something' if looks_like_class $class; |
411
|
|
|
|
|
|
|
Function: Tests whether argument looks like a class. |
412
|
|
|
|
|
|
|
Returns : $class or throws ExtensionError |
413
|
|
|
|
|
|
|
Args : A hopefully loadable class name |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=back |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=head1 SEE ALSO |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> |
420
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=over |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=item L<Bio::Phylo::Manual> |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=back |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=head1 CITATION |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
435
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
436
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
437
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=cut |
442
|
|
|
|
|
|
|
|