line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Phylo::Matrices::Datatype::Continuous; |
2
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
99
|
|
3
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
109
|
|
4
|
3
|
|
|
3
|
|
18
|
use base 'Bio::Phylo::Matrices::Datatype'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
425
|
|
5
|
|
|
|
|
|
|
use Bio::Phylo::Util::CONSTANT |
6
|
3
|
|
|
3
|
|
24
|
qw(looks_like_number looks_like_implementor looks_like_instance); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1522
|
|
7
|
|
|
|
|
|
|
our ( $LOOKUP, $MISSING, $GAP ); |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
my $logger = __PACKAGE__->get_logger; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Bio::Phylo::Matrices::Datatype::Continuous - Validator subclass, |
14
|
|
|
|
|
|
|
no serviceable parts inside |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
The Bio::Phylo::Matrices::Datatype::* classes are used to validated data |
19
|
|
|
|
|
|
|
contained by L<Bio::Phylo::Matrices::Matrix> and L<Bio::Phylo::Matrices::Datum> |
20
|
|
|
|
|
|
|
objects. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 MUTATORS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item set_lookup() |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Sets the lookup table (no-op for continuous data!). |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Type : Mutator |
33
|
|
|
|
|
|
|
Title : set_lookup |
34
|
|
|
|
|
|
|
Usage : $obj->set_gap($hashref); |
35
|
|
|
|
|
|
|
Function: Sets the symbol for gaps |
36
|
|
|
|
|
|
|
Returns : Modified object. |
37
|
|
|
|
|
|
|
Args : Argument must be a hash |
38
|
|
|
|
|
|
|
reference that maps allowed |
39
|
|
|
|
|
|
|
single character symbols |
40
|
|
|
|
|
|
|
(including ambiguity symbols) |
41
|
|
|
|
|
|
|
onto the equivalent set of |
42
|
|
|
|
|
|
|
non-ambiguous symbols |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub set_lookup { |
47
|
0
|
|
|
0
|
1
|
0
|
$logger->info("Can't set lookup table for continuous characters"); |
48
|
0
|
|
|
|
|
0
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 ACCESSORS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item get_lookup() |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Gets the lookup table (no-op for continuous data!). |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Type : Accessor |
62
|
|
|
|
|
|
|
Title : get_lookup |
63
|
|
|
|
|
|
|
Usage : my $lookup = $obj->get_lookup; |
64
|
|
|
|
|
|
|
Function: Returns the object's lookup hash |
65
|
|
|
|
|
|
|
Returns : A hash reference |
66
|
|
|
|
|
|
|
Args : None |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_lookup { |
71
|
15
|
|
|
15
|
1
|
61
|
$logger->info("Can't get lookup table for continuous characters"); |
72
|
15
|
|
|
|
|
51
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 TESTS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item is_valid() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Validates arguments for data validity. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Type : Test |
86
|
|
|
|
|
|
|
Title : is_valid |
87
|
|
|
|
|
|
|
Usage : if ( $obj->is_valid($datum) ) { |
88
|
|
|
|
|
|
|
# do something |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
Function: Returns true if $datum only contains valid characters |
91
|
|
|
|
|
|
|
Returns : BOOLEAN |
92
|
|
|
|
|
|
|
Args : A list of Bio::Phylo::Matrices::Datum object, and/or |
93
|
|
|
|
|
|
|
character array references, and/or character strings, |
94
|
|
|
|
|
|
|
and/or single characters |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub is_valid { |
99
|
20
|
|
|
20
|
1
|
46
|
my $self = shift; |
100
|
20
|
|
|
|
|
37
|
my @data; |
101
|
20
|
|
|
|
|
49
|
for my $arg (@_) { |
102
|
33
|
100
|
|
|
|
99
|
if ( looks_like_implementor $arg, 'get_char' ) { |
|
|
50
|
|
|
|
|
|
103
|
9
|
|
|
|
|
37
|
push @data, $arg->get_char; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
elsif ( looks_like_instance $arg, 'ARRAY' ) { |
106
|
0
|
|
|
|
|
0
|
push @data, @{$arg}; |
|
0
|
|
|
|
|
0
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else { |
109
|
24
|
|
|
|
|
48
|
push @data, @{ $self->split($arg) }; |
|
24
|
|
|
|
|
64
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
20
|
|
|
|
|
75
|
my $missing = $self->get_missing; |
113
|
20
|
|
|
|
|
48
|
CHAR_CHECK: for my $char (@data) { |
114
|
25
|
100
|
66
|
|
|
67
|
if ( looks_like_number $char || $char eq $missing ) { |
115
|
23
|
|
|
|
|
64
|
next CHAR_CHECK; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
2
|
|
|
|
|
8
|
return 0; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
18
|
|
|
|
|
97
|
return 1; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 UTILITY METHODS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item split() |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Splits string of characters on whitespaces. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Type : Utility method |
135
|
|
|
|
|
|
|
Title : split |
136
|
|
|
|
|
|
|
Usage : $obj->split($string) |
137
|
|
|
|
|
|
|
Function: Splits $string into characters |
138
|
|
|
|
|
|
|
Returns : An array reference of characters |
139
|
|
|
|
|
|
|
Args : A string |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub split { |
144
|
31
|
|
|
31
|
1
|
73
|
my ( $self, $string ) = @_; |
145
|
31
|
|
|
|
|
159
|
my @array = CORE::split( /\s+/, $string ); |
146
|
31
|
|
|
|
|
142
|
return \@array; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item join() |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Joins array ref of characters to a space-separated string. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Type : Utility method |
154
|
|
|
|
|
|
|
Title : join |
155
|
|
|
|
|
|
|
Usage : $obj->join($arrayref) |
156
|
|
|
|
|
|
|
Function: Joins $arrayref into a string |
157
|
|
|
|
|
|
|
Returns : A string |
158
|
|
|
|
|
|
|
Args : An array reference |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub join { |
163
|
6
|
|
|
6
|
1
|
20
|
my ( $self, $array ) = @_; |
164
|
6
|
|
|
|
|
14
|
return CORE::join ' ', @{$array}; |
|
6
|
|
|
|
|
41
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
$MISSING = '?'; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# podinherit_insert_token |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 SEE ALSO |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> |
177
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item L<Bio::Phylo::Matrices::Datatype> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This object inherits from L<Bio::Phylo::Matrices::Datatype>, so the methods defined |
184
|
|
|
|
|
|
|
therein are also applicable to L<Bio::Phylo::Matrices::Datatype::Continuous> |
185
|
|
|
|
|
|
|
objects. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item L<Bio::Phylo::Manual> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 CITATION |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
198
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
199
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
200
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
1; |