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