| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# BioPerl module for Bio::Seq::Quality |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Please direct questions and support issues to |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Cared for by Heikki Lehvaslaiho |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Copyright Heikki Lehvaslaiho |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Bio::Seq::Quality - Implementation of sequence with residue quality |
|
18
|
|
|
|
|
|
|
and trace values |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Bio::Seq::Quality; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# input can be space delimited string or array ref |
|
25
|
|
|
|
|
|
|
my $qual = '0 1 2 3 4 5 6 7 8 9 11 12'; |
|
26
|
|
|
|
|
|
|
my $trace = '0 5 10 15 20 25 30 35 40 45 50 55'; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $seq = Bio::Seq::Quality->new |
|
29
|
|
|
|
|
|
|
( -qual => $qual, |
|
30
|
|
|
|
|
|
|
-trace_indices => $trace, |
|
31
|
|
|
|
|
|
|
-seq => 'atcgatcgatcg', |
|
32
|
|
|
|
|
|
|
-id => 'human_id', |
|
33
|
|
|
|
|
|
|
-accession_number => 'S000012', |
|
34
|
|
|
|
|
|
|
-verbose => -1 # to silence deprecated methods |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $quals = $seq->qual; # array ref |
|
38
|
|
|
|
|
|
|
my $traces = $seq->trace; # array ref |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $quals = $seq->qual_text; # string |
|
41
|
|
|
|
|
|
|
my $traces = $seq->trace_text; # string |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# get sub values |
|
45
|
|
|
|
|
|
|
$quals = $seq->subqual(2, 3); # array ref |
|
46
|
|
|
|
|
|
|
$traces = $seq->subtrace(2, 3); # array ref |
|
47
|
|
|
|
|
|
|
$quals = $seq->subqual_text(2, 3); # string |
|
48
|
|
|
|
|
|
|
$quals = $seq->subtrace_text(2, 3); # string |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# set sub values |
|
51
|
|
|
|
|
|
|
$seq->subqual(2, 3, "9 9"); |
|
52
|
|
|
|
|
|
|
$seq->subtrace(2, 3, "9 9"); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This object stores base quality values together with the sequence |
|
59
|
|
|
|
|
|
|
string. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
It is a reimplementation of Chad Matsalla's Bio::Seq::SeqWithQuality |
|
62
|
|
|
|
|
|
|
module using Bio::Seq::MetaI. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
The implementation is based on Bio::Seq::Meta::Array. qual() and |
|
65
|
|
|
|
|
|
|
trace() are base methods to store and retrieve information that have |
|
66
|
|
|
|
|
|
|
extensions to retrieve values as a scalar (e.g. qual_text() ), or get |
|
67
|
|
|
|
|
|
|
or set subvalues (e.g. subqual() ). See L for more |
|
68
|
|
|
|
|
|
|
details. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
All the functional code is in Bio::Seq::Meta::Array. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
There deprecated methods that are included for compatibility with |
|
73
|
|
|
|
|
|
|
Bio::Seq::SeqWithQuality. These will print a warning unless verbosity |
|
74
|
|
|
|
|
|
|
of the object is set to be less than zero. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 Differences from Bio::Seq::SeqWithQuality |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
It is not possible to fully follow the interface of |
|
79
|
|
|
|
|
|
|
Bio::Seq::SeqWithQuality since internally a Bio::Seq::SeqWithQuality |
|
80
|
|
|
|
|
|
|
object is a composite of two independent objects: a Bio::PrimarySeq |
|
81
|
|
|
|
|
|
|
object and Bio::Seq::PrimaryQual object. Both of these objects can be |
|
82
|
|
|
|
|
|
|
created separately and merged into Bio::Seq::SeqWithQuality. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This implementation is based on Bio::Seq::Meta::Array that is a |
|
85
|
|
|
|
|
|
|
subclass of Bio::PrimarySeq that stores any number of meta information |
|
86
|
|
|
|
|
|
|
in unnamed arrays. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Here we assume that two meta sets, called 'qual' and 'trace_indices' |
|
89
|
|
|
|
|
|
|
are attached to a sequence. (But there is nothing that prevents you to |
|
90
|
|
|
|
|
|
|
add as many named meta sets as you need using normal meta() methods). |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
qual() is an alias to meta(), qualat($loc) is an alias to |
|
93
|
|
|
|
|
|
|
submeta($loc,$loc). |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
trace_indices() in Bio::Seq::SeqWithQuality has been abbreviated to |
|
96
|
|
|
|
|
|
|
trace() and is an alias to named_meta('trace'). |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
You can create an object without passing any arguments to the |
|
99
|
|
|
|
|
|
|
constructor (Bio::Seq::SeqWithQuality fails without alphabet). It will |
|
100
|
|
|
|
|
|
|
warn about not being able to set alphabet unless you set verbosity of |
|
101
|
|
|
|
|
|
|
the object to a negative value. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
After the latest rewrite, the meta information sets (quality and |
|
104
|
|
|
|
|
|
|
trace) no longer cover all the residues automatically. Methods to |
|
105
|
|
|
|
|
|
|
check the length of meta information (L, |
|
106
|
|
|
|
|
|
|
L)and to see if the ends are flushed to the sequence |
|
107
|
|
|
|
|
|
|
have been added (L, L). To force the |
|
108
|
|
|
|
|
|
|
old functinality, set L to true. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
qual_obj() and seq_obj() methods do not exist! |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Finally, there is only one set of descriptors (primary_id, display_id, |
|
113
|
|
|
|
|
|
|
accession_number) for the object. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L, |
|
119
|
|
|
|
|
|
|
L |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 FEEDBACK |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 Mailing Lists |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this and other |
|
126
|
|
|
|
|
|
|
Bioperl modules. Send your comments and suggestions preferably to one |
|
127
|
|
|
|
|
|
|
of the Bioperl mailing lists. Your participation is much appreciated. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
bioperl-l@bioperl.org - General discussion |
|
130
|
|
|
|
|
|
|
http://bioperl.org/wiki/Mailing_lists - About the mailing lists |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 Support |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
I |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
|
139
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
|
140
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
|
141
|
|
|
|
|
|
|
with code and data examples if at all possible. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 Reporting Bugs |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
|
146
|
|
|
|
|
|
|
the bugs and their resolution. Bug reports can be submitted via the |
|
147
|
|
|
|
|
|
|
web: |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
https://github.com/bioperl/bioperl-live/issues |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR - Heikki Lehvaslaiho |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Email heikki-at-bioperl-dot-org |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Chad Matsalla, bioinformatics at dieselwurks dot com |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Dan Bolser, dan dot bolser at gmail dot com |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 APPENDIX |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The rest of the documentation details each of the object methods. |
|
164
|
|
|
|
|
|
|
Internal methods are usually preceded with a _ |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# Let the code begin... |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
package Bio::Seq::Quality; |
|
173
|
9
|
|
|
9
|
|
5364
|
use strict; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
259
|
|
|
174
|
|
|
|
|
|
|
|
|
175
|
9
|
|
|
9
|
|
39
|
use base qw(Bio::Seq::Meta::Array); |
|
|
9
|
|
|
|
|
15
|
|
|
|
9
|
|
|
|
|
3845
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
## Is this the right place (and way) to define this? |
|
178
|
|
|
|
|
|
|
our $MASK_CHAR = 'X'; |
|
179
|
|
|
|
|
|
|
our $DEFAULT_NAME = 'DEFAULT'; |
|
180
|
|
|
|
|
|
|
our $GAP = '-'; |
|
181
|
|
|
|
|
|
|
our $META_GAP = ' '; |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 new |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Title : new |
|
186
|
|
|
|
|
|
|
Usage : $metaseq = Bio::Seq::Quality->new |
|
187
|
|
|
|
|
|
|
( -qual => '0 1 2 3 4 5 6 7 8 9 11 12', |
|
188
|
|
|
|
|
|
|
-trace => '0 5 10 15 20 25 30 35 40 45 50 55', |
|
189
|
|
|
|
|
|
|
-seq => 'atcgatcgatcg', |
|
190
|
|
|
|
|
|
|
-id => 'human_id', |
|
191
|
|
|
|
|
|
|
-accession_number => 'S000012', |
|
192
|
|
|
|
|
|
|
); |
|
193
|
|
|
|
|
|
|
Function: Constructor for Bio::Seq::Quality class. Note that you can |
|
194
|
|
|
|
|
|
|
provide an empty quality and trace strings. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Returns : a new Bio::Seq::Quality object |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub new { |
|
202
|
862
|
|
|
862
|
1
|
116489
|
my ($class, @args) = @_; |
|
203
|
|
|
|
|
|
|
|
|
204
|
862
|
|
|
|
|
2173
|
my $self = $class->SUPER::new(@args); |
|
205
|
|
|
|
|
|
|
|
|
206
|
862
|
|
|
|
|
2358
|
my($meta, $qual, $trace, $trace_indices, $trace_data) = |
|
207
|
|
|
|
|
|
|
$self->_rearrange([qw(META |
|
208
|
|
|
|
|
|
|
QUAL |
|
209
|
|
|
|
|
|
|
TRACE |
|
210
|
|
|
|
|
|
|
TRACE_INDICES |
|
211
|
|
|
|
|
|
|
TRACE_DATA)], |
|
212
|
|
|
|
|
|
|
@args); |
|
213
|
|
|
|
|
|
|
|
|
214
|
862
|
|
|
|
|
2077
|
$self->{'_meta'}->{$DEFAULT_NAME} = []; |
|
215
|
862
|
|
|
|
|
1301
|
$self->{'_meta'}->{'trace'} = []; |
|
216
|
862
|
|
|
|
|
1605
|
$self->{trace_data} = $trace_data; |
|
217
|
|
|
|
|
|
|
|
|
218
|
862
|
100
|
|
|
|
1501
|
$meta && $self->meta($meta); |
|
219
|
862
|
100
|
|
|
|
2190
|
$qual && $self->qual($qual); |
|
220
|
862
|
100
|
|
|
|
1312
|
$trace && $self->named_meta('trace', $trace); |
|
221
|
862
|
100
|
|
|
|
1179
|
$trace_indices && $self->named_meta('trace', $trace_indices); |
|
222
|
|
|
|
|
|
|
|
|
223
|
862
|
|
|
|
|
2450
|
return $self; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
## QUAL |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head2 qual |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
Title : qual |
|
233
|
|
|
|
|
|
|
Usage : $qual_values = $obj->qual($values_string); |
|
234
|
|
|
|
|
|
|
Function: |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Get and set method for the meta data starting from residue |
|
237
|
|
|
|
|
|
|
position one. Since it is dependent on the length of the |
|
238
|
|
|
|
|
|
|
sequence, it needs to be manipulated after the sequence. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
The length of the returned value always matches the length |
|
241
|
|
|
|
|
|
|
of the sequence. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Returns : reference to an array of meta data |
|
244
|
|
|
|
|
|
|
Args : new value, string or array ref or Bio::Seq::PrimaryQual, optional |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Setting quality values resets the clear range. |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=cut |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub qual { |
|
251
|
1506
|
|
|
1506
|
1
|
8730
|
my $self = shift; |
|
252
|
1506
|
|
|
|
|
1677
|
my $value = shift; |
|
253
|
1506
|
100
|
100
|
|
|
4258
|
$value = $value->qual |
|
|
|
|
66
|
|
|
|
|
|
254
|
|
|
|
|
|
|
if ref($value) and ref($value) ne 'ARRAY' and |
|
255
|
|
|
|
|
|
|
$value->isa('Bio::Seq::PrimaryQual'); |
|
256
|
1506
|
100
|
|
|
|
3174
|
$self->_empty_cache if $value; |
|
257
|
1506
|
|
|
|
|
2834
|
return $self->named_meta($DEFAULT_NAME, $value); |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head2 qual_text |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Title : qual_text |
|
263
|
|
|
|
|
|
|
Usage : $qual_values = $obj->qual_text($values_arrayref); |
|
264
|
|
|
|
|
|
|
Function: Variant of meta() and qual() guarantied to return a string |
|
265
|
|
|
|
|
|
|
representation of meta data. For details, see L. |
|
266
|
|
|
|
|
|
|
Returns : a string |
|
267
|
|
|
|
|
|
|
Args : new value, optional |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub qual_text { |
|
272
|
2
|
|
|
2
|
1
|
4
|
return join ' ', @{shift->named_submeta($DEFAULT_NAME, @_)}; |
|
|
2
|
|
|
|
|
6
|
|
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head2 subqual |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Title : subqual |
|
278
|
|
|
|
|
|
|
Usage : $subset_of_qual_values = $obj->subqual(10, 20, $value_string); |
|
279
|
|
|
|
|
|
|
$subset_of_qual_values = $obj->subqual(10, undef, $value_string); |
|
280
|
|
|
|
|
|
|
Function: |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Get and set method for meta data for subsequences. |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Numbering starts from 1 and the number is inclusive, ie 1-2 |
|
285
|
|
|
|
|
|
|
are the first two residue of the sequence. Start cannot be |
|
286
|
|
|
|
|
|
|
larger than end but can be equal. |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
If the second argument is missing the returned values |
|
289
|
|
|
|
|
|
|
should extend to the end of the sequence. |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
Returns : A reference to an array |
|
292
|
|
|
|
|
|
|
Args : integer, start position |
|
293
|
|
|
|
|
|
|
integer, end position, optional when a third argument present |
|
294
|
|
|
|
|
|
|
new value, optional |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=cut |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub subqual { |
|
299
|
317
|
|
|
317
|
1
|
859
|
shift->named_submeta($DEFAULT_NAME, @_); |
|
300
|
|
|
|
|
|
|
} |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head2 subqual_text |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Title : subqual_text |
|
305
|
|
|
|
|
|
|
Usage : $meta_values = $obj->subqual_text(20, $value_string); |
|
306
|
|
|
|
|
|
|
Function: Variant of subqual() returning a stringified |
|
307
|
|
|
|
|
|
|
representation of meta data. For details, see L. |
|
308
|
|
|
|
|
|
|
Returns : a string |
|
309
|
|
|
|
|
|
|
Args : new value, optional |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=cut |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub subqual_text { |
|
314
|
5
|
|
|
5
|
1
|
71
|
return join ' ', @{shift->named_submeta($DEFAULT_NAME, @_)}; |
|
|
5
|
|
|
|
|
22
|
|
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head2 quality_length |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
Title : quality_length() |
|
320
|
|
|
|
|
|
|
Usage : $qual_len = $obj->quality_length(); |
|
321
|
|
|
|
|
|
|
Function: return the number of elements in the quality array |
|
322
|
|
|
|
|
|
|
Returns : integer |
|
323
|
|
|
|
|
|
|
Args : - |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=cut |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub quality_length { |
|
328
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
|
329
|
0
|
|
|
|
|
0
|
return $self->named_meta_length($DEFAULT_NAME); |
|
330
|
|
|
|
|
|
|
} |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head2 quality_is_flush |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
Title : quality_is_flush |
|
335
|
|
|
|
|
|
|
Usage : $quality_is_flush = $obj->quality_is_flush() |
|
336
|
|
|
|
|
|
|
Function: Boolean to tell if the trace length equals the sequence length. |
|
337
|
|
|
|
|
|
|
Returns true if force_flush() is set. |
|
338
|
|
|
|
|
|
|
Returns : boolean 1 or 0 |
|
339
|
|
|
|
|
|
|
Args : none |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=cut |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub quality_is_flush { |
|
344
|
1
|
|
|
1
|
1
|
4
|
return shift->is_flush('quality'); |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
## TRACE |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=head2 trace |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
Title : trace |
|
354
|
|
|
|
|
|
|
Usage : $trace_values = $obj->trace($values_string); |
|
355
|
|
|
|
|
|
|
Function: |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
Get and set method for the meta data starting from residue |
|
358
|
|
|
|
|
|
|
position one. Since it is dependent on the length of the |
|
359
|
|
|
|
|
|
|
sequence, it needs to be manipulated after the sequence. |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
The length of the returned value always matches the length |
|
362
|
|
|
|
|
|
|
of the sequence. |
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
Returns : reference to an array of meta data |
|
365
|
|
|
|
|
|
|
Args : new value, string or array ref, optional |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=cut |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub trace { |
|
370
|
11
|
|
|
11
|
1
|
903
|
my $self = shift; |
|
371
|
11
|
|
|
|
|
15
|
my $value = shift; |
|
372
|
11
|
|
|
|
|
29
|
return $self->named_meta('trace', $value); |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=head2 trace_text |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
Title : trace_text |
|
378
|
|
|
|
|
|
|
Usage : $trace_values = $obj->trace_text($values_arrayref); |
|
379
|
|
|
|
|
|
|
Function: Variant of meta() and trace() guarantied to return a string |
|
380
|
|
|
|
|
|
|
representation of meta data. For details, see L. |
|
381
|
|
|
|
|
|
|
Returns : a string |
|
382
|
|
|
|
|
|
|
Args : new value, optional |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=cut |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub trace_text { |
|
387
|
1
|
|
|
1
|
1
|
3
|
return join ' ', @{shift->named_submeta('trace', @_)}; |
|
|
1
|
|
|
|
|
3
|
|
|
388
|
|
|
|
|
|
|
} |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=head2 subtrace |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
Title : subtrace |
|
393
|
|
|
|
|
|
|
Usage : $subset_of_trace_values = $obj->subtrace(10, 20, $value_string); |
|
394
|
|
|
|
|
|
|
$subset_of_trace_values = $obj->subtrace(10, undef, $value_string); |
|
395
|
|
|
|
|
|
|
Function: |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Get and set method for meta data for subsequences. |
|
398
|
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
Numbering starts from 1 and the number is inclusive, ie 1-2 |
|
400
|
|
|
|
|
|
|
are the first two residue of the sequence. Start cannot be |
|
401
|
|
|
|
|
|
|
larger than end but can be equal. |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
If the second argument is missing the returned values |
|
404
|
|
|
|
|
|
|
should extend to the end of the sequence. |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
Returns : A reference to an array |
|
407
|
|
|
|
|
|
|
Args : integer, start position |
|
408
|
|
|
|
|
|
|
integer, end position, optional when a third argument present |
|
409
|
|
|
|
|
|
|
new value, optional |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=cut |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
sub subtrace { |
|
415
|
2
|
|
|
2
|
1
|
6
|
return shift->named_submeta('trace', @_); |
|
416
|
|
|
|
|
|
|
} |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=head2 subtrace_text |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
Title : subtrace_text |
|
421
|
|
|
|
|
|
|
Usage : $meta_values = $obj->subtrace_text(20, $value_string); |
|
422
|
|
|
|
|
|
|
Function: Variant of subtrace() returning a stringified |
|
423
|
|
|
|
|
|
|
representation of meta data. For details, see L. |
|
424
|
|
|
|
|
|
|
Returns : a string |
|
425
|
|
|
|
|
|
|
Args : new value, optional |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=cut |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
sub subtrace_text { |
|
430
|
5
|
|
|
5
|
1
|
1596
|
return join ' ', @{shift->named_submeta('trace', @_)}; |
|
|
5
|
|
|
|
|
18
|
|
|
431
|
|
|
|
|
|
|
} |
|
432
|
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=head2 trace_length |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
Title : trace_length() |
|
436
|
|
|
|
|
|
|
Usage : $trace_len = $obj->trace_length(); |
|
437
|
|
|
|
|
|
|
Function: return the number of elements in the trace set |
|
438
|
|
|
|
|
|
|
Returns : integer |
|
439
|
|
|
|
|
|
|
Args : - |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=cut |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
sub trace_length { |
|
444
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
|
445
|
1
|
|
|
|
|
4
|
return $self->named_meta_length('trace'); |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
=head2 trace_is_flush |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
Title : trace_is_flush |
|
451
|
|
|
|
|
|
|
Usage : $trace_is_flush = $obj->trace_is_flush() |
|
452
|
|
|
|
|
|
|
Function: Boolean to tell if the trace length equals the sequence length. |
|
453
|
|
|
|
|
|
|
Returns true if force_flush() is set. |
|
454
|
|
|
|
|
|
|
Returns : boolean 1 or 0 |
|
455
|
|
|
|
|
|
|
Args : none |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=cut |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
sub trace_is_flush { |
|
460
|
1
|
|
|
1
|
1
|
4
|
return shift->is_flush('trace'); |
|
461
|
|
|
|
|
|
|
} |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=head2 get_trace_graph |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
Title : get_trace_graph |
|
468
|
|
|
|
|
|
|
Usage : @trace_values = $obj->get_trace_graph( -trace => 'a', |
|
469
|
|
|
|
|
|
|
-scale => 100) |
|
470
|
|
|
|
|
|
|
Function : Returns array of raw trace values for a trace file, or |
|
471
|
|
|
|
|
|
|
false if no trace data exists. Requires a value for trace |
|
472
|
|
|
|
|
|
|
to get either the a, g, c or t trace information, and an |
|
473
|
|
|
|
|
|
|
optional value for scale, which rescales the data between |
|
474
|
|
|
|
|
|
|
0 and the provided value, a scale value of '0' performs no |
|
475
|
|
|
|
|
|
|
scaling |
|
476
|
|
|
|
|
|
|
Returns : Array or 0 |
|
477
|
|
|
|
|
|
|
Args : string, trace to retrieve, one of a, g, c or t integer, |
|
478
|
|
|
|
|
|
|
scale, for scaling of trace between 0 and scale, or 0 for |
|
479
|
|
|
|
|
|
|
no scaling, optional |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=cut |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
sub get_trace_graph |
|
484
|
|
|
|
|
|
|
{ |
|
485
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
486
|
0
|
|
|
|
|
0
|
my($trace, $scale) = |
|
487
|
|
|
|
|
|
|
$self->_rearrange([qw(TRACE |
|
488
|
|
|
|
|
|
|
SCALE |
|
489
|
|
|
|
|
|
|
)], |
|
490
|
|
|
|
|
|
|
@_); |
|
491
|
0
|
0
|
|
|
|
0
|
unless (defined($self->{trace_data})) { return 0 } |
|
|
0
|
|
|
|
|
0
|
|
|
492
|
0
|
0
|
|
|
|
0
|
unless (grep { lc($trace) eq $_ } ('a', 'g', 'c', 't')) { return 0 } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
493
|
0
|
|
|
|
|
0
|
$trace = lc($trace) . "_trace"; |
|
494
|
|
|
|
|
|
|
my @trace_data = exists $self->{trace_data}->{$trace} && |
|
495
|
|
|
|
|
|
|
ref $self->{trace_data}->{$trace} eq 'ARRAY' ? |
|
496
|
0
|
0
|
0
|
|
|
0
|
@{$self->{trace_data}->{$trace}} : (); |
|
|
0
|
|
|
|
|
0
|
|
|
497
|
0
|
|
|
|
|
0
|
my $max = $self->{trace_data}->{max_height}; |
|
498
|
0
|
0
|
0
|
|
|
0
|
if (defined($scale) and $scale != 0) |
|
499
|
|
|
|
|
|
|
{ |
|
500
|
0
|
|
|
|
|
0
|
@trace_data = map { $_ / $max * $scale } @trace_data; |
|
|
0
|
|
|
|
|
0
|
|
|
501
|
|
|
|
|
|
|
} |
|
502
|
0
|
|
|
|
|
0
|
return @trace_data; |
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
=head2 threshold |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
Title : threshold |
|
509
|
|
|
|
|
|
|
Usage : $qual->threshold($value); |
|
510
|
|
|
|
|
|
|
Function: Sets the quality threshold. |
|
511
|
|
|
|
|
|
|
Returns : an integer |
|
512
|
|
|
|
|
|
|
Args : new value, optional |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Value used by *clear_range* method below. |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=cut |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
sub threshold { |
|
519
|
1226
|
|
|
1226
|
1
|
2743
|
my $self = shift; |
|
520
|
1226
|
|
|
|
|
1086
|
my $value = shift; |
|
521
|
1226
|
100
|
|
|
|
1640
|
if (defined $value) { |
|
522
|
310
|
50
|
|
|
|
1154
|
$self->throw("Threshold needs to be an integer [$value]") |
|
523
|
|
|
|
|
|
|
unless $value =~ /^[-+]?\d+$/; |
|
524
|
|
|
|
|
|
|
$self->_empty_cache |
|
525
|
310
|
100
|
66
|
|
|
1075
|
if defined $self->{_threshold} and $self->{_threshold} ne $value; |
|
526
|
310
|
|
|
|
|
563
|
$self->{_threshold} = $value; |
|
527
|
|
|
|
|
|
|
} |
|
528
|
1226
|
|
|
|
|
1872
|
return $self->{_threshold}; |
|
529
|
|
|
|
|
|
|
} |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head2 mask_below_threshold |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
Title : mask_below_threshold |
|
535
|
|
|
|
|
|
|
Usage : $count = $obj->count_clear_ranges($threshold); |
|
536
|
|
|
|
|
|
|
Function: Counts number of ranges in the sequence where quality |
|
537
|
|
|
|
|
|
|
values are above the threshold |
|
538
|
|
|
|
|
|
|
Returns : count integer |
|
539
|
|
|
|
|
|
|
Args : threshold integer, optional |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
Set threshold first using method L. |
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=cut |
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub mask_below_threshold { |
|
546
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
|
547
|
4
|
|
|
|
|
4
|
my $threshold = shift; |
|
548
|
|
|
|
|
|
|
|
|
549
|
4
|
50
|
|
|
|
7
|
$self->threshold($threshold) if defined $threshold; |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
# populate the cache if needed |
|
552
|
4
|
50
|
|
|
|
12
|
$self->_find_clear_ranges unless defined $self->{_ranges}; |
|
553
|
|
|
|
|
|
|
|
|
554
|
4
|
|
|
|
|
10
|
my $maskSeq = $self->seq; |
|
555
|
4
|
|
|
|
|
6
|
my $maskQual = $self->qual; |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
## There must be a more efficient way than this! |
|
558
|
4
|
|
|
|
|
9
|
for(my $i=0; $i
|
|
559
|
|
|
|
|
|
|
#print join ("\t", $i, $maskQual->[$i]), "\n"; |
|
560
|
|
|
|
|
|
|
substr($maskSeq, $i, 1, $MASK_CHAR) |
|
561
|
64
|
100
|
|
|
|
107
|
if $maskQual->[$i] < $self->{_threshold}; |
|
562
|
|
|
|
|
|
|
} |
|
563
|
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
## This is the *wrong* way to do it! |
|
565
|
|
|
|
|
|
|
#for my $r (@{$self->{_ranges}} ){ |
|
566
|
|
|
|
|
|
|
# substr($maskSeq, $r->{start}, $r->{length}, $MASK_CHAR x $r->{length}); |
|
567
|
|
|
|
|
|
|
#} |
|
568
|
|
|
|
|
|
|
|
|
569
|
4
|
|
|
|
|
15
|
return $maskSeq; |
|
570
|
|
|
|
|
|
|
} |
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
=head2 count_clear_ranges |
|
573
|
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
Title : count_clear_ranges |
|
575
|
|
|
|
|
|
|
Usage : $count = $obj->count_clear_ranges($threshold); |
|
576
|
|
|
|
|
|
|
Function: Counts number of ranges in the sequence where quality |
|
577
|
|
|
|
|
|
|
values are above the threshold |
|
578
|
|
|
|
|
|
|
Returns : count integer |
|
579
|
|
|
|
|
|
|
Args : threshold integer, optional |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
Set threshold first using method L. |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=cut |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
sub count_clear_ranges { |
|
586
|
301
|
|
|
301
|
1
|
776
|
my $self = shift; |
|
587
|
301
|
|
|
|
|
295
|
my $threshold = shift; |
|
588
|
301
|
50
|
|
|
|
446
|
$self->threshold($threshold) if defined $threshold; |
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
# populate the cache if needed |
|
591
|
301
|
50
|
|
|
|
769
|
$self->_find_clear_ranges unless defined $self->{_ranges}; |
|
592
|
|
|
|
|
|
|
|
|
593
|
301
|
|
|
|
|
314
|
return scalar @{$self->{_ranges}}; |
|
|
301
|
|
|
|
|
770
|
|
|
594
|
|
|
|
|
|
|
} |
|
595
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
=head2 clear_ranges_length |
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
Title : clear_ranges_length |
|
599
|
|
|
|
|
|
|
Usage : $total_lenght = $obj->clear_ranges_length($threshold); |
|
600
|
|
|
|
|
|
|
Function: Return number of residues with quality values above |
|
601
|
|
|
|
|
|
|
the threshold in all clear ranges |
|
602
|
|
|
|
|
|
|
Returns : an integer |
|
603
|
|
|
|
|
|
|
Args : threshold, optional |
|
604
|
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
Set threshold first using method L. |
|
606
|
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
I think this method needs a better name! count_high_quality_bases? or |
|
608
|
|
|
|
|
|
|
sum_clear_ranges? |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=cut |
|
611
|
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
sub clear_ranges_length { |
|
613
|
300
|
|
|
300
|
1
|
1072
|
my $self = shift; |
|
614
|
300
|
|
|
|
|
294
|
my $threshold = shift; |
|
615
|
300
|
50
|
|
|
|
422
|
$self->threshold($threshold) if defined $threshold; |
|
616
|
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
# populate the cache if needed |
|
618
|
300
|
50
|
|
|
|
480
|
$self->_find_clear_ranges unless defined $self->{_ranges}; |
|
619
|
|
|
|
|
|
|
|
|
620
|
300
|
|
|
|
|
264
|
my $sum; |
|
621
|
300
|
|
|
|
|
285
|
map {$sum += $_->{length}} @{$self->{_ranges}}; |
|
|
58678
|
|
|
|
|
53542
|
|
|
|
300
|
|
|
|
|
594
|
|
|
622
|
300
|
|
|
|
|
475
|
return $sum; |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=head2 get_clear_range |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
Title : get_clear_range |
|
628
|
|
|
|
|
|
|
Usage : $newqualobj = $obj->get_clear_range($threshold); |
|
629
|
|
|
|
|
|
|
Function: Return longest subsequence that has quality values above |
|
630
|
|
|
|
|
|
|
the given threshold, or a default value of 13 |
|
631
|
|
|
|
|
|
|
Returns : a new Bio::Seq::Quality object |
|
632
|
|
|
|
|
|
|
Args : threshold, optional |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
Set threshold first using method L. |
|
635
|
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
Note, this method could be implemented using some gaussian smoothing |
|
637
|
|
|
|
|
|
|
of the quality scores. Currently one base below the threshold is |
|
638
|
|
|
|
|
|
|
enough to end the clear range. |
|
639
|
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
=cut |
|
641
|
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
sub get_clear_range { |
|
643
|
303
|
|
|
303
|
1
|
1145
|
my $self = shift; |
|
644
|
303
|
|
|
|
|
331
|
my $threshold = shift; |
|
645
|
303
|
100
|
|
|
|
477
|
$self->threshold($threshold) if defined $threshold; |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
# populate the cache if needed |
|
648
|
303
|
100
|
|
|
|
554
|
$self->_find_clear_ranges unless defined $self->{_ranges}; |
|
649
|
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
# fix for bug 2847 |
|
651
|
303
|
50
|
|
|
|
470
|
return unless defined $self->{_ranges}; |
|
652
|
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
# pick the longest |
|
654
|
303
|
|
|
|
|
294
|
for (sort {$b->{length} <=> $a->{length} } @{$self->{_ranges}} ){ |
|
|
321879
|
|
|
|
|
280795
|
|
|
|
303
|
|
|
|
|
1339
|
|
|
655
|
|
|
|
|
|
|
my $newqualobj = Bio::Seq::Quality->new( |
|
656
|
|
|
|
|
|
|
-seq => $self->subseq( $_->{start}, $_->{end}), |
|
657
|
303
|
|
|
|
|
1032
|
-qual => $self->subqual($_->{start}, $_->{end}), |
|
658
|
|
|
|
|
|
|
-id => $self->id); |
|
659
|
|
|
|
|
|
|
|
|
660
|
303
|
|
|
|
|
706
|
$newqualobj->threshold($threshold); |
|
661
|
|
|
|
|
|
|
|
|
662
|
303
|
|
|
|
|
694
|
return $newqualobj; |
|
663
|
|
|
|
|
|
|
} |
|
664
|
|
|
|
|
|
|
} |
|
665
|
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head2 get_all_clean_ranges |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
Title : get_all_clean_ranges |
|
671
|
|
|
|
|
|
|
Usage : @ranges = $obj->get_all_clean_ranges($minlength); |
|
672
|
|
|
|
|
|
|
Function: Return all ranges where quality values are above |
|
673
|
|
|
|
|
|
|
the threshold. Original ordering. |
|
674
|
|
|
|
|
|
|
Returns : an ordered array of new Bio::Seq::Quality objects |
|
675
|
|
|
|
|
|
|
Args : minimum length , optional |
|
676
|
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
Set threshold first using method L. |
|
678
|
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=cut |
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
sub get_all_clean_ranges { |
|
682
|
2
|
|
|
2
|
1
|
447
|
my $self = shift; |
|
683
|
2
|
|
100
|
|
|
8
|
my $minl = shift || 0; |
|
684
|
|
|
|
|
|
|
|
|
685
|
2
|
50
|
|
|
|
11
|
$self->throw("Mimimum length needs to be zero or a positive integer [$minl]") |
|
686
|
|
|
|
|
|
|
unless $minl =~ /^\+?\d+$/; |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
# populate the cache if needed |
|
689
|
2
|
50
|
|
|
|
6
|
$self->_find_clear_ranges unless defined $self->{_ranges}; |
|
690
|
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
# return in the order of occurrence |
|
692
|
2
|
|
|
|
|
1
|
my @ranges; |
|
693
|
2
|
|
|
|
|
2
|
for my $r (sort {$b->{start} <=> $a->{start} } @{$self->{_ranges}} ){ |
|
|
4
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
8
|
|
|
694
|
6
|
100
|
|
|
|
10
|
next if $r->{length} < $minl; |
|
695
|
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
## Constructor should allow "-threshold => ..."! |
|
697
|
|
|
|
|
|
|
push @ranges, Bio::Seq::Quality->new |
|
698
|
|
|
|
|
|
|
( -seq => $self->subseq( $r->{start}, $r->{end}), |
|
699
|
5
|
|
|
|
|
13
|
-qual => $self->subqual($r->{start}, $r->{end}), |
|
700
|
|
|
|
|
|
|
-id => $self->id |
|
701
|
|
|
|
|
|
|
); |
|
702
|
|
|
|
|
|
|
} |
|
703
|
2
|
|
|
|
|
8
|
return @ranges; |
|
704
|
|
|
|
|
|
|
} |
|
705
|
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
# |
|
708
|
|
|
|
|
|
|
# _find_clear_ranges: where range/threshold calculations happen |
|
709
|
|
|
|
|
|
|
# |
|
710
|
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
sub _find_clear_ranges { |
|
712
|
307
|
|
|
307
|
|
316
|
my $self = shift; |
|
713
|
307
|
|
|
|
|
395
|
my $qual = $self->qual; |
|
714
|
|
|
|
|
|
|
|
|
715
|
307
|
50
|
|
|
|
485
|
$self->throw("You need to set the threshold value first") |
|
716
|
|
|
|
|
|
|
unless defined $self->threshold; |
|
717
|
|
|
|
|
|
|
|
|
718
|
307
|
|
|
|
|
515
|
my $threshold = $self->threshold; |
|
719
|
|
|
|
|
|
|
|
|
720
|
307
|
|
|
|
|
379
|
my $rangeFlag = 0; |
|
721
|
|
|
|
|
|
|
|
|
722
|
307
|
|
|
|
|
612
|
for(my $i=0; $i<@$qual; $i++){ |
|
723
|
|
|
|
|
|
|
## Are we currently within a clear range or not? |
|
724
|
300190
|
100
|
|
|
|
290777
|
if($rangeFlag){ |
|
725
|
|
|
|
|
|
|
## Did we just leave the clear range? |
|
726
|
208915
|
100
|
|
|
|
306587
|
if($qual->[$i]<$threshold){ |
|
727
|
|
|
|
|
|
|
## Log the range |
|
728
|
58493
|
|
|
|
|
46623
|
my $range; |
|
729
|
58493
|
|
|
|
|
60836
|
$range->{end} = $i-1; |
|
730
|
58493
|
|
|
|
|
51109
|
$range->{start} = $rangeFlag; |
|
731
|
58493
|
|
|
|
|
52404
|
$range->{length} = $i - $rangeFlag; |
|
732
|
58493
|
|
|
|
|
47821
|
push @{$self->{_ranges}}, $range; |
|
|
58493
|
|
|
|
|
66346
|
|
|
733
|
|
|
|
|
|
|
## and reset the range flag. |
|
734
|
58493
|
|
|
|
|
81825
|
$rangeFlag = 0; |
|
735
|
|
|
|
|
|
|
} |
|
736
|
|
|
|
|
|
|
## else nothing changes |
|
737
|
|
|
|
|
|
|
} |
|
738
|
|
|
|
|
|
|
else{ |
|
739
|
|
|
|
|
|
|
## Did we just enter a clear range? |
|
740
|
91275
|
100
|
|
|
|
122969
|
if($qual->[$i]>=$threshold){ |
|
741
|
|
|
|
|
|
|
## then set the range flag! |
|
742
|
58892
|
|
|
|
|
71240
|
$rangeFlag = $i; |
|
743
|
|
|
|
|
|
|
} |
|
744
|
|
|
|
|
|
|
## else nothing changes |
|
745
|
|
|
|
|
|
|
} |
|
746
|
|
|
|
|
|
|
} |
|
747
|
|
|
|
|
|
|
## Did we exit the last clear range? |
|
748
|
307
|
100
|
|
|
|
511
|
if($rangeFlag){ |
|
749
|
194
|
|
|
|
|
234
|
my $i = scalar(@$qual); |
|
750
|
|
|
|
|
|
|
## Log the range |
|
751
|
194
|
|
|
|
|
176
|
my $range; |
|
752
|
194
|
|
|
|
|
325
|
$range->{end} = $i-1; |
|
753
|
194
|
|
|
|
|
215
|
$range->{start} = $rangeFlag; |
|
754
|
194
|
|
|
|
|
211
|
$range->{length} = $i - $rangeFlag; |
|
755
|
194
|
|
|
|
|
186
|
push @{$self->{_ranges}}, $range; |
|
|
194
|
|
|
|
|
292
|
|
|
756
|
|
|
|
|
|
|
} |
|
757
|
|
|
|
|
|
|
|
|
758
|
307
|
|
|
|
|
438
|
1; |
|
759
|
|
|
|
|
|
|
} |
|
760
|
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
sub _empty_cache { |
|
763
|
1037
|
|
|
1037
|
|
1142
|
my $self = shift; |
|
764
|
1037
|
|
|
|
|
6941
|
undef $self->{_ranges}; |
|
765
|
|
|
|
|
|
|
} |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
################## deprecated methods ################## |
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
sub trace_indices { |
|
774
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
|
775
|
1
|
|
|
|
|
3
|
return $self->named_meta('trace'); |
|
776
|
|
|
|
|
|
|
} |
|
777
|
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
sub trace_index_at { |
|
779
|
764
|
|
|
764
|
0
|
1348
|
my ($self, $val) =@_; |
|
780
|
764
|
|
|
|
|
678
|
return shift @{$self->named_submeta('trace', $val, $val)}; |
|
|
764
|
|
|
|
|
958
|
|
|
781
|
|
|
|
|
|
|
} |
|
782
|
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
sub sub_trace_index { |
|
785
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
786
|
1
|
|
|
|
|
3
|
return $self->named_submeta('trace', @_); |
|
787
|
|
|
|
|
|
|
} |
|
788
|
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
sub qualat { |
|
791
|
1030
|
|
|
1030
|
0
|
1577
|
my ($self, $val) =@_; |
|
792
|
1030
|
|
|
|
|
1029
|
return shift @{$self->submeta($val, $val)}; |
|
|
1030
|
|
|
|
|
1645
|
|
|
793
|
|
|
|
|
|
|
} |
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
sub baseat { |
|
797
|
767
|
|
|
767
|
0
|
966
|
my ($self,$val) = @_; |
|
798
|
767
|
|
|
|
|
1310
|
return $self->subseq($val,$val); |
|
799
|
|
|
|
|
|
|
} |
|
800
|
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
1; |
|
804
|
|
|
|
|
|
|
|