Bio/Search/HSP/GenericHSP.pm

filter: Statementstmt 86.7% 491 / 566 Branchbran 72.9% 261 / 358 Conditioncond 65.2% 126 / 193 MC/DCmcdc 38.7% 43 / 111 Subroutinesub 96.0% 48 / 50 Podpod 100% 35 / 35 totaltotal 76.4% 1004 / 1313 CC 263 SCAR 28.3
CC
263
Cov
79%
_calculate_seq_positions
46.3
_query_seq_feature
24.8
_subject_seq_feature
24.8
CRAP 16.9
« Bio/Matrix/IO/phylip.pm ↑ Summary Bio/SeqIO/table.pm »
1 #
2 # BioPerl module for Bio::Search::HSP::GenericHSP
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason@bioperl.org>
7 #
8 # Copyright Jason Stajich
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Search::HSP::GenericHSP - A "Generic" implementation of a High Scoring Pair
17  
18 =head1 SYNOPSIS
19  
20 my $hsp = Bio::Search::HSP::GenericHSP->new( -algorithm => 'blastp',
21 -evalue => '1e-30',
22 );
23  
24 $r_type = $hsp->algorithm;
25  
26 $pvalue = $hsp->p();
27  
28 $evalue = $hsp->evalue();
29  
30 $frac_id = $hsp->frac_identical( ['query'|'hit'|'total'] );
31  
32 $frac_cons = $hsp->frac_conserved( ['query'|'hit'|'total'] );
33  
34 $gaps = $hsp->gaps( ['query'|'hit'|'total'] );
35  
36 $qseq = $hsp->query_string;
37  
38 $hseq = $hsp->hit_string;
39  
40 $homo_string = $hsp->homology_string;
41  
42 $len = $hsp->length( ['query'|'hit'|'total'] );
43  
44 $len = $hsp->length( ['query'|'hit'|'total'] );
45  
46 $rank = $hsp->rank;
47  
48 # TODO: Describe how to configure a SearchIO stream so that it generates
49 # GenericHSP objects.
50  
51 =head1 DESCRIPTION
52  
53 This implementation is "Generic", meaning it is is suitable for
54 holding information about High Scoring pairs from most Search reports
55 such as BLAST and FastA. Specialized objects can be derived from
56 this.
57  
58 Unless you're writing a parser, you won't ever need to create a
59 GenericHSP or any other HSPI-implementing object. If you use
60 the SearchIO system, HSPI objects are created automatically from
61 a SearchIO stream which returns Bio::Search::Result::ResultI objects
62 and you get the HSPI objects via the ResultI API.
63  
64 For documentation on what you can do with GenericHSP (and other HSPI
65 objects), please see the API documentation in
66 L<Bio::Search::HSP::HSPI|Bio::Search::HSP::HSPI>.
67  
68 =head1 FEEDBACK
69  
70 =head2 Mailing Lists
71  
72 User feedback is an integral part of the evolution of this and other
73 Bioperl modules. Send your comments and suggestions preferably to
74 the Bioperl mailing list. Your participation is much appreciated.
75  
76 bioperl-l@bioperl.org - General discussion
77 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
78  
79 =head2 Support
80  
81 Please direct usage questions or support issues to the mailing list:
82  
83 I<bioperl-l@bioperl.org>
84  
85 rather than to the module maintainer directly. Many experienced and
86 reponsive experts will be able look at the problem and quickly
87 address it. Please include a thorough description of the problem
88 with code and data examples if at all possible.
89  
90 =head2 Reporting Bugs
91  
92 Report bugs to the Bioperl bug tracking system to help us keep track
93 of the bugs and their resolution. Bug reports can be submitted via the
94 web:
95  
96 https://github.com/bioperl/bioperl-live/issues
97  
98 =head1 AUTHOR - Jason Stajich and Steve Chervitz
99  
100 Email jason-at-bioperl.org
101 Email sac-at-bioperl.org
102  
103 =head1 CONTRIBUTORS
104  
105 Sendu Bala, bix@sendu.me.uk
106  
107 =head1 APPENDIX
108  
109 The rest of the documentation details each of the object methods.
110 Internal methods are usually preceded with a _
111  
112 =cut
113  
114 # Let the code begin...
115  
116 package Bio::Search::HSP::GenericHSP;
117 32 $Bio::Search::HSP::GenericHSP::VERSION = '1.7.8';
118 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
119  
120 32 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
121 32 ▶use Bio::SeqFeature::Similarity;
Subroutine BEGIN: called CC=1 SCAR=0.0
122  
123 32 ▶use base qw(Bio::Search::HSP::HSPI);
Subroutine BEGIN: called CC=1 SCAR=0.0
124  
125 =head2 new
126  
127 Title : new
128 Usage : my $obj = Bio::Search::HSP::GenericHSP->new();
129 Function: Builds a new Bio::Search::HSP::GenericHSP object
130 Returns : Bio::Search::HSP::GenericHSP
131 Args : -algorithm => algorithm used (BLASTP, TBLASTX, FASTX, etc)
132 -evalue => evalue
133 -pvalue => pvalue
134 -bits => bit value for HSP
135 -score => score value for HSP (typically z-score but depends on
136 analysis)
137 -hsp_length=> Length of the HSP (including gaps)
138 -identical => # of residues that that matched identically
139 -percent_identity => (optional) percent identity
140 -conserved => # of residues that matched conservatively
141 (only protein comparisons;
142 conserved == identical in nucleotide comparisons)
143 -hsp_gaps => # of gaps in the HSP
144 -query_gaps => # of gaps in the query in the alignment
145 -hit_gaps => # of gaps in the subject in the alignment
146 -query_name => HSP Query sequence name (if available)
147 -query_start => HSP Query start (in original query sequence coords)
148 -query_end => HSP Query end (in original query sequence coords)
149 -query_length=> total length of the query sequence
150 -query_seq => query sequence portion of the HSP
151 -query_desc => textual description of the query
152 -hit_name => HSP Hit sequence name (if available)
153 -hit_start => HSP Hit start (in original hit sequence coords)
154 -hit_end => HSP Hit end (in original hit sequence coords)
155 -hit_length => total length of the hit sequence
156 -hit_seq => hit sequence portion of the HSP
157 -hit_desc => textual description of the hit
158 -homology_seq=> homology sequence for the HSP
159 -hit_frame => hit frame (only if hit is translated protein)
160 -query_frame => query frame (only if query is translated protein)
161 -rank => HSP rank
162 -links => HSP links information (WU-BLAST only)
163 -hsp_group => HSP Group informat (WU-BLAST only)
164 -gap_symbol => symbol representing a gap (default = '-')
165 -hit_features=> string of features found in or near HSP hit
166 region (reported in some BLAST text output,
167 v. 2.2.13 and up)
168 -stranded => If the algorithm isn't known (i.e. defaults to
169 'generic'), setting this will indicate start/end
170 coordinates are to be used to determine the strand
171 for 'query', 'subject', 'hit', 'both', or 'none'
172 (default = 'none')
173  
174 =cut
175  
176 1073 ▶sub new {
Subroutine new: called CC=9 SCAR=23.1
Pod documented
177 1073 my($class,%args) = @_;
178  
179 # don't pass anything to SUPER; complex hierarchy results in lots of work
180 # for nothing
181
182 1073 my $self = $class->SUPER::new();
183  
184 # for speed, don't use _rearrange and just store all input data directly
185 # with no method calls and no work done. work can be carried
186 # out just-in-time later if desired
187 1073 ▶ while (my ($arg, $value) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 19884 1073 20957
188 19884 $arg =~ tr/a-z\055/A-Z/d;
189 19884 $self->{$arg} = $value;
190 }
191 1073 my $bits = $self->{BITS};
192  
193 1073 ▶ defined $self->{VERBOSE} && $self->verbose($self->{VERBOSE});
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"VERBOSE"} and $self->verbose($self->{"VERBOSE"}) 447 626 1073
194 1073 ▶ if (exists $self->{GAP_SYMBOL}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'GAP_SYMBOL'}) { } 0 1073 1073
195 # not checking anything else but the length (must be 1 as only one gap
196 # symbol allowed currently); can add in support for symbol checks or
197 # multiple symbols later if needed
198 $self->throw("Gap symbol must be of length 1") if
199 0 ▶ CORE::length($self->{GAP_SYMBOL}) != 1;
Branch: 1 branch
BranchTrueFalseTotal
if CORE::length $self->{"GAP_SYMBOL"} != 1 0 0 0
200 } else {
201 # dafault
202 1073 $self->{GAP_SYMBOL} = '-';
203 }
204 1073 ▶ $self->{ALGORITHM} ||= 'GENERIC';
Condition100%2/2
$self->{"ALGORITHM"} ||= "GENERIC"
l!l
10721
MC/DC100%1/1
$self->{"ALGORITHM"} ||= "GENERIC"
$self->{"ALGORITHM"}
Truth table100%2/2
A
A= $self->{"ALGORITHM"}
Aresult
11
00
205 1073 ▶ $self->{STRANDED} ||= 'NONE';
Condition100%2/2
$self->{"STRANDED"} ||= "NONE"
l!l
615458
MC/DC100%1/1
$self->{"STRANDED"} ||= "NONE"
$self->{"STRANDED"}
Truth table100%2/2
A
A= $self->{"STRANDED"}
Aresult
11
00
206
207 1073 ▶ if (! defined $self->{QUERY_LENGTH} || ! defined $self->{HIT_LENGTH}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"QUERY_LENGTH"} and defined $self->{"HIT_LENGTH"}) 0 1073 1073
Condition33%1/3
defined $self->{"QUERY_LENGTH"} and defined $self->{"HIT_LENGTH"}
!ll&&!rl&&r
001073
MC/DC0%0/2
defined $self->{"QUERY_LENGTH"} and defined $self->{"HIT_LENGTH"}
defined $self->{"QUERY_LENGTH"} defined $self->{"HIT_LENGTH"}
Truth table33%1/3
A and B
A= defined $self->{"QUERY_LENGTH"}B= defined $self->{"HIT_LENGTH"}
ABresult
0X0
100
111
208 0 $self->throw("Must define hit and query length");
209 }
210  
211 1073 $self->{'_sequenceschanged'} = 1;
212
213 1073 $self->{_finished_new} = 1;
214 1073 return $self;
215 }
216  
217 214 ▶sub _logical_length {
Subroutine _logical_length: called CC=4 SCAR=13.9
218 214 my ($self, $type) = @_;
219 214 ▶ if (!defined($self->{_sbjct_offset}) || !defined($self->{_query_offset})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_sbjct_offset"} and defined $self->{"_query_offset"}) 72 142 214
Condition66%2/3
defined $self->{"_sbjct_offset"} and defined $self->{"_query_offset"}
!ll&&!rl&&r
720142
MC/DC50%1/2
defined $self->{"_sbjct_offset"} and defined $self->{"_query_offset"}
defined $self->{"_sbjct_offset"} defined $self->{"_query_offset"}
Truth table66%2/3
A and B
A= defined $self->{"_sbjct_offset"}B= defined $self->{"_query_offset"}
ABresult
0X0
100
111
220 72 $self->_calculate_seq_offsets();
221 }
222 214 ▶ my $key = $type =~ /sbjct|hit|tot/i ? 'sbjct' : 'query';
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /sbjct|hit|tot/i ? : 143 71 214
223
224 214 my $offset = $self->{"_${key}_offset"};
225 214 return $self->length($type) / $offset ;
226 }
227  
228 =head2 L<Bio::Search::HSP::HSPI> methods
229  
230 Implementation of L<Bio::Search::HSP::HSPI> methods follow
231  
232 =head2 algorithm
233  
234 Title : algorithm
235 Usage : my $r_type = $hsp->algorithm
236 Function: Obtain the name of the algorithm used to obtain the HSP
237 Returns : string (e.g., BLASTP)
238 Args : [optional] scalar string to set value
239  
240 =cut
241  
242 7118 ▶sub algorithm{
Subroutine algorithm: called CC=4 SCAR=18.7
Pod documented
243 7118 my ($self,$value) = @_;
244 7118 my $previous = $self->{'ALGORITHM'};
245 7118 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 0 7118 7118
Condition33%1/3
defined $value or not defined $previous
l!l&&r!l&&!r
007118
MC/DC0%0/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table33%1/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
246 0 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
247 0 $self->{'ALGORITHM'} = $value;
248 }
249  
250 7118 return $previous;
251 }
252  
253 =head2 pvalue
254  
255 Title : pvalue
256 Usage : my $pvalue = $hsp->pvalue();
257 Function: Returns the P-value for this HSP or undef
258 Returns : float or exponential (2e-10)
259 P-value is not defined with NCBI Blast2 reports.
260 Args : [optional] numeric to set value
261  
262 =cut
263  
264 44 ▶sub pvalue {
Subroutine pvalue: called CC=2 SCAR=7.4
Pod documented
265 44 my ($self,$value) = @_;
266 44 my $previous = $self->{'PVALUE'};
267 44 ▶ if( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 44 44
268 0 $self->{'PVALUE'} = $value;
269 }
270 44 return $previous;
271 }
272  
273 =head2 evalue
274  
275 Title : evalue
276 Usage : my $evalue = $hsp->evalue();
277 Function: Returns the e-value for this HSP
278 Returns : float or exponential (2e-10)
279 Args : [optional] numeric to set value
280  
281 =cut
282  
283 84 ▶sub evalue {
Subroutine evalue: called CC=2 SCAR=7.4
Pod documented
284 84 my ($self,$value) = @_;
285 84 my $previous = $self->{'EVALUE'};
286 84 ▶ if( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 84 84
287 0 $self->{'EVALUE'} = $value;
288 }
289 84 return $previous;
290 }
291  
292 =head2 frac_identical
293  
294 Title : frac_identical
295 Usage : my $frac_id = $hsp->frac_identical( ['query'|'hit'|'total'] );
296 Function: Returns the fraction of identitical positions for this HSP
297 Returns : Float in range 0.0 -> 1.0
298 Args : arg 1: 'query' = num identical / length of query seq (without gaps)
299 'hit' = num identical / length of hit seq (without gaps)
300 synonyms: 'sbjct', 'subject'
301 'total' = num identical / length of alignment (with gaps)
302 synonyms: 'hsp'
303 default = 'total'
304 arg 2: [optional] frac identical value to set for the type requested
305 Note : for translated sequences, this adjusts the length accordingly
306  
307 =cut
308  
309 354 ▶sub frac_identical {
Subroutine frac_identical: called CC=13 SCAR=26.5
Pod documented
310 354 my ($self, $type,$value) = @_;
311  
312 354 ▶ unless ($self->{_did_prefrac}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_did_prefrac"}) 72 282 354
313 72 $self->_pre_frac;
314 }
315  
316 354 ▶ $type = lc $type if defined $type;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type 354 0 354
317 354 ▶ $type = 'hit' if( defined $type &&
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type =~ /subject|sbjct/ 0 354 354
Condition33%1/3
defined $type and $type =~ /subject|sbjct/
!ll&&!rl&&r
03540
MC/DC0%0/2
defined $type and $type =~ /subject|sbjct/
defined $type $type =~ /subject|sbjct/
Truth table33%1/3
A and B
A= defined $typeB= $type =~ /subject|sbjct/
ABresult
0X0
100
111
318 $type =~ /subject|sbjct/);
319 354 ▶ $type = 'total' if( ! defined $type || $type eq 'hsp' ||
Branch: 1 branch
BranchTrueFalseTotal
if not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/ 18 336 354
Condition66%4/6
not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/
l!l&&r!l&&!r
180336
not defined $type or $type eq "hsp"
l!l&&r!l&&!r
018336
MC/DC33%1/3
not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/
not defined $type $type eq "hsp" not $type =~ /query|hit|subject|sbjct|total/
Truth table50%2/4
not(A) or B or not(C)
A= not defined $typeB= $type eq "hsp"C= not $type =~ /query|hit|subject|sbjct|total/
ABCresult
1XX1
01X1
0011
0000
320 $type !~ /query|hit|subject|sbjct|total/);
321 354 my $previous = $self->{'_frac_identical'}->{$type};
322 354 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 214 140 354
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
2140140
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
323 214 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 214 214
324 214 ▶ if( $type eq 'hit' || $type eq 'query' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "hit" or $type eq "query") 142 72 214
Condition100%3/3
$type eq "hit" or $type eq "query"
l!l&&r!l&&!r
717172
MC/DC100%2/2
$type eq "hit" or $type eq "query"
$type eq "hit" $type eq "query"
Truth table100%3/3
A or B
A= $type eq "hit"B= $type eq "query"
ABresult
1X1
011
000
325 142 $self->$type()->frac_identical( $value);
326 }
327 214 $self->{'_frac_identical'}->{$type} = $value;
328 }
329 354 return $previous;
330  
331 }
332  
333 =head2 frac_conserved
334  
335 Title : frac_conserved
336 Usage : my $frac_cons = $hsp->frac_conserved( ['query'|'hit'|'total'] );
337 Function : Returns the fraction of conserved positions for this HSP.
338 This is the fraction of symbols in the alignment with a
339 positive score.
340 Returns : Float in range 0.0 -> 1.0
341 Args : arg 1: 'query' = num conserved / length of query seq (without gaps)
342 'hit' = num conserved / length of hit seq (without gaps)
343 synonyms: 'sbjct', 'subject'
344 'total' = num conserved / length of alignment (with gaps)
345 synonyms: 'hsp'
346 default = 'total'
347 arg 2: [optional] frac conserved value to set for the type requested
348  
349 =cut
350  
351 304 ▶sub frac_conserved {
Subroutine frac_conserved: called CC=11 SCAR=28.4
Pod documented
352 304 my ($self, $type,$value) = @_;
353  
354 304 ▶ unless ($self->{_did_prefrac}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_did_prefrac"}) 0 304 304
355 0 $self->_pre_frac;
356 }
357  
358 304 ▶ $type = lc $type if defined $type;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type 304 0 304
359 304 ▶ $type = 'hit' if( defined $type && $type =~ /subject|sbjct/);
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type =~ /subject|sbjct/ 0 304 304
Condition33%1/3
defined $type and $type =~ /subject|sbjct/
!ll&&!rl&&r
03040
MC/DC0%0/2
defined $type and $type =~ /subject|sbjct/
defined $type $type =~ /subject|sbjct/
Truth table33%1/3
A and B
A= defined $typeB= $type =~ /subject|sbjct/
ABresult
0X0
100
111
360 304 ▶ $type = 'total' if( ! defined $type || $type eq 'hsp' ||
Branch: 1 branch
BranchTrueFalseTotal
if not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/ 0 304 304
Condition33%2/6
not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/
l!l&&r!l&&!r
00304
not defined $type or $type eq "hsp"
l!l&&r!l&&!r
00304
MC/DC0%0/3
not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/
not defined $type $type eq "hsp" not $type =~ /query|hit|subject|sbjct|total/
Truth table25%1/4
not(A) or B or not(C)
A= not defined $typeB= $type eq "hsp"C= not $type =~ /query|hit|subject|sbjct|total/
ABCresult
1XX1
01X1
0011
0000
361 $type !~ /query|hit|subject|sbjct|total/);
362 304 my $previous = $self->{'_frac_conserved'}->{$type};
363 304 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 214 90 304
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
214090
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
364 214 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 214 214
365 214 $self->{'_frac_conserved'}->{$type} = $value;
366 }
367 304 return $previous;
368 }
369  
370 =head2 gaps
371  
372 Title : gaps
373 Usage : my $gaps = $hsp->gaps( ['query'|'hit'|'total'] );
374 Function : Get the number of gap characters in the query, hit, or total alignment.
375 Returns : Integer, number of gaps or 0 if none
376 Args : arg 1: 'query' = num gap characters in query seq
377 'hit' = num gap characters in hit seq; synonyms: 'sbjct', 'subject'
378 'total' = num gap characters in whole alignment; synonyms: 'hsp'
379 default = 'total'
380 arg 2: [optional] integer gap value to set for the type requested
381  
382 =cut
383  
384 2393 ▶sub gaps {
Subroutine gaps: called CC=11 SCAR=24.0
Pod documented
385 2393 my ($self, $type, $value) = @_;
386  
387 2393 ▶ unless ($self->{_did_pregaps}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_did_pregaps"}) 271 2122 2393
388 271 $self->_pre_gaps;
389 }
390  
391 2393 ▶ $type = lc $type if defined $type;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type 1365 1028 2393
392 2393 ▶ $type = 'total' if( ! defined $type || $type eq 'hsp' ||
Branch: 1 branch
BranchTrueFalseTotal
if not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/ 1028 1365 2393
Condition66%4/6
not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/
l!l&&r!l&&!r
102801365
not defined $type or $type eq "hsp"
l!l&&r!l&&!r
102801365
MC/DC33%1/3
not defined $type or $type eq "hsp" or not $type =~ /query|hit|subject|sbjct|total/
not defined $type $type eq "hsp" not $type =~ /query|hit|subject|sbjct|total/
Truth table50%2/4
not(A) or B or not(C)
A= not defined $typeB= $type eq "hsp"C= not $type =~ /query|hit|subject|sbjct|total/
ABCresult
1XX1
01X1
0011
0000
393 $type !~ /query|hit|subject|sbjct|total/);
394 2393 ▶ $type = 'hit' if $type =~ /sbjct|subject/;
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /sbjct|subject/ 20 2373 2393
395 2393 my $previous = $self->{'_gaps'}->{$type};
396 2393 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 789 1604 2393
Condition100%3/3
defined $value or not defined $previous
l!l&&r!l&&!r
78631604
MC/DC100%2/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table100%3/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
397 789 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 786 789
398 789 $self->{'_gaps'}->{$type} = $value;
399 }
400 2393 ▶ return $previous || 0;
Condition100%2/2
$previous || 0
l!l
10151378
MC/DC100%1/1
$previous || 0
$previous
Truth table100%2/2
A
A= $previous
Aresult
11
00
401 }
402  
403 =head2 query_string
404  
405 Title : query_string
406 Usage : my $qseq = $hsp->query_string;
407 Function: Retrieves the query sequence of this HSP as a string
408 Returns : string
409 Args : [optional] string to set for query sequence
410  
411  
412 =cut
413  
414 517 ▶sub query_string{
Subroutine query_string: called CC=4 SCAR=14.0
Pod documented
415 517 my ($self,$value) = @_;
416 517 my $previous = $self->{QUERY_SEQ};
417 517 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 3 514 517
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
03514
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
418 3 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 0 3
419 3 $self->{QUERY_SEQ} = $value;
420 # do some housekeeping so we know when to
421 # re-run _calculate_seq_positions
422 3 $self->{'_sequenceschanged'} = 1;
423 }
424 517 return $previous;
425 }
426  
427 =head2 hit_string
428  
429 Title : hit_string
430 Usage : my $hseq = $hsp->hit_string;
431 Function: Retrieves the hit sequence of this HSP as a string
432 Returns : string
433 Args : [optional] string to set for hit sequence
434  
435  
436 =cut
437  
438 535 ▶sub hit_string{
Subroutine hit_string: called CC=4 SCAR=19.4
Pod documented
439 535 my ($self,$value) = @_;
440 535 my $previous = $self->{HIT_SEQ};
441 535 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 0 535 535
Condition33%1/3
defined $value or not defined $previous
l!l&&r!l&&!r
00535
MC/DC0%0/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table33%1/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
442 0 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
443 0 $self->{HIT_SEQ} = $value;
444 # do some housekeeping so we know when to
445 # re-run _calculate_seq_positions
446 0 $self->{'_sequenceschanged'} = 1;
447 }
448 535 return $previous;
449 }
450  
451 =head2 homology_string
452  
453 Title : homology_string
454 Usage : my $homo_string = $hsp->homology_string;
455 Function: Retrieves the homology sequence for this HSP as a string.
456 : The homology sequence is the string of symbols in between the
457 : query and hit sequences in the alignment indicating the degree
458 : of conservation (e.g., identical, similar, not similar).
459 Returns : string
460 Args : [optional] string to set for homology sequence
461  
462 =cut
463  
464 6764 ▶sub homology_string{
Subroutine homology_string: called CC=4 SCAR=14.0
Pod documented
465 6764 my ($self,$value) = @_;
466 6764 my $previous = $self->{HOMOLOGY_SEQ};
467 6764 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 3 6761 6764
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
036761
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
468 3 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 0 3
469 3 $self->{HOMOLOGY_SEQ} = $value;
470 # do some housekeeping so we know when to
471 # re-run _calculate_seq_positions
472 3 $self->{'_sequenceschanged'} = 1;
473 }
474 6764 return $previous;
475 }
476  
477 =head2 consensus_string
478  
479 Title : consensus_string
480 Usage : my $cs_string = $hsp->consensus_string;
481 Function: Retrieves the consensus structure line for this HSP as a string (HMMER).
482 : If the model had any consensus structure or reference line annotation
483 : that it inherited from a multiple alignment (#=GC SS cons,
484 : #=GC RF annotation in Stockholm files), that information is shown
485 : as CS or RF annotation line.
486 Returns : string
487 Args : [optional] string to set for consensus structure
488  
489 =cut
490  
491 0 ▶sub consensus_string {
Subroutine consensus_string: not called CC=4 SCAR=30.0
Pod documented
492 0 my ($self,$value) = @_;
493 0 my $previous = $self->{CS_SEQ};
494 0 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 0 0 0
Condition0%0/3
defined $value or not defined $previous
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table0%0/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
495 0 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
496 0 $self->{CS_SEQ} = $value;
497 # do some housekeeping so we know when to
498 # re-run _calculate_seq_positions
499 0 $self->{'_sequenceschanged'} = 1;
500 }
501 0 return $previous;
502 }
503  
504 =head2 posterior_string
505  
506 Title : posterior_string
507 Usage : my $pp_string = $hsp->posterior_string;
508 Function: Retrieves the posterior probability line for this HSP as a string (HMMer3).
509 : The posterior probability is the string of symbols at the bottom
510 : of the alignment indicating the expected accuracy of each aligned residue.
511 : A 0 means 0-5%, 1 means 5-15%, and so on; 9 means 85-95%,
512 : and a * means 95-100% posterior probability.
513 Returns : string
514 Args : [optional] string to set for posterior probability
515  
516 =cut
517  
518 1 ▶sub posterior_string {
Subroutine posterior_string: called CC=4 SCAR=19.4
Pod documented
519 1 my ($self,$value) = @_;
520 1 my $previous = $self->{PP_SEQ};
521 1 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 0 1 1
Condition33%1/3
defined $value or not defined $previous
l!l&&r!l&&!r
001
MC/DC0%0/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table33%1/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
522 0 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
523 0 $self->{PP_SEQ} = $value;
524 # do some housekeeping so we know when to
525 # re-run _calculate_seq_positions
526 0 $self->{'_sequenceschanged'} = 1;
527 }
528 1 return $previous;
529 }
530  
531 =head2 length
532  
533 Title : length
534 Usage : my $len = $hsp->length( ['query'|'hit'|'total'] );
535 Function : Returns the length of the query or hit in the alignment
536 (without gaps)
537 or the aggregate length of the HSP (including gaps;
538 this may be greater than either hit or query )
539 Returns : integer
540 Args : arg 1: 'query' = length of query seq (without gaps)
541 'hit' = length of hit seq (without gaps) (synonyms: sbjct, subject)
542 'total' = length of alignment (with gaps)
543 default = 'total'
544 arg 2: [optional] integer length value to set for specific type
545  
546 =cut
547  
548 3526 ▶sub length {
Subroutine length: called CC=5 SCAR=16.1
Pod documented
549  
550 3526 my $self = shift;
551 3526 my $type = shift;
552  
553 3526 ▶ $type = 'total' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 609 2917 3526
554 3526 $type = lc $type;
555  
556 3526 ▶ if( $type =~ /^q/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /^q/i) { } 1552 1974 3526
elsif ($type =~ /^(hit|subject|sbjct)/) { } 926 1048 1974
557 1552 return $self->query()->length(shift);
558 } elsif( $type =~ /^(hit|subject|sbjct)/ ) {
559 926 return $self->hit()->length(shift);
560 } else {
561 1048 my $v = shift;
562 1048 ▶ if( defined $v ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) 72 976 1048
563 72 $self->{HSP_LENGTH} = $v;
564 }
565 1048 return $self->{HSP_LENGTH};
566 }
567 0 return 0; # should never get here
568 }
569  
570 =head2 hsp_length
571  
572 Title : hsp_length
573 Usage : my $len = $hsp->hsp_length()
574 Function: shortcut length('hsp')
575 Returns : floating point between 0 and 100
576 Args : none
577  
578 =cut
579  
580 3 ▶sub hsp_length { return shift->length('hsp', shift); }
Subroutine hsp_length: called CC=1 SCAR=0.0
Pod documented
581  
582 =head2 percent_identity
583  
584 Title : percent_identity
585 Usage : my $percentid = $hsp->percent_identity()
586 Function: Returns the calculated percent identity for an HSP
587 Returns : floating point between 0 and 100
588 Args : none
589  
590  
591 =cut
592  
593 18 ▶sub percent_identity {
Subroutine percent_identity: called CC=2 SCAR=6.9
Pod documented
594 18 my $self = shift;
595  
596 18 ▶ unless ($self->{_did_prepi}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_did_prepi"}) 9 9 18
597 9 $self->_pre_pi;
598 }
599  
600 18 return $self->SUPER::percent_identity(@_);
601 }
602  
603 =head2 frame
604  
605 Title : frame
606 Usage : my ($qframe, $hframe) = $hsp->frame('list',$queryframe,$subjectframe)
607 Function: Set the Frame for both query and subject and insure that
608 they agree.
609 This overrides the frame() method implementation in
610 FeaturePair.
611 Returns : array of query and subject frame if return type wants an array
612 or query frame if defined or subject frame if not defined
613 Args : 'hit' or 'subject' or 'sbjct' to retrieve the frame of the subject (default)
614 'query' to retrieve the query frame
615 'list' or 'array' to retrieve both query and hit frames together
616 Note : Frames are stored in the GFF way (0-2) not 1-3
617 as they are in BLAST (negative frames are deduced by checking
618 the strand of the query or hit)
619  
620 =cut
621  
622 # Note: changed 4/19/08 - bug 2485
623 #
624 # frame() is supposed to be a getter/setter (as is implied by the Function desc
625 # above; this is also consistent with Bio::SeqFeature::SimilarityPair). Also,
626 # the API is not consistent with the other HSP/SimilarityPair methods such as
627 # strand(), start(), end(), etc.
628 #
629 # In order to make this consistent with other methods all work is now done
630 # when the features are instantiated and not delayed. We compromise by
631 # defaulting back 'to hit' w/o passed args. Setting is now allowed.
632  
633 551 ▶sub frame {
Subroutine frame: called CC=7 SCAR=28.0
Pod documented
634 551 my $self = shift;
635 551 my $val = shift;
636 551 ▶ if (!defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val) 0 551 551
637 # unfortunately, w/o args we need to warn about API changes
638 0 $self->warn("API for frame() has changed.\n".
639 "Please refer to documentation for Bio::Search::HSP::GenericHSP;\n".
640 "returning query frame");
641 0 $val = 'query';
642 }
643 551 $val =~ s/^\s+//;
644  
645 551 ▶ if( $val =~ /^q/i ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($val =~ /^q/i) { } 276 275 551
elsif ($val =~ /^hi|^s/i) { } 275 0 275
elsif ($val =~ /^list|array/i) { } 0 0 0
elsif ($val =~ /^\d+$/) { } 0 0 0
646 276 return $self->query->frame(@_);
647 } elsif( $val =~ /^hi|^s/i ) {
648 275 return $self->hit->frame(@_);
649 } elsif ( $val =~ /^list|array/i ) {
650 0 return ($self->query->frame($_[0]),
651 $self->hit->frame($_[1]) );
652 } elsif ( $val =~ /^\d+$/) {
653 # old API i.e. frame($query_frame, $hit_frame). This catches all but one
654 # case, where no arg is passed (so the hit is wanted).
655 0 $self->warn("API for frame() has changed.\n".
656 "Please refer to documentation for Bio::Search::HSP::GenericHSP");
657 wantarray ?
658 0 ▶ return ($self->query->frame($val),
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
659 $self->hit->frame(@_) ) :
660 return $self->hit->frame($val,@_);
661 } else {
662 0 $self->warn("unrecognized component '$val' requested\n");
663 }
664 0 return 0;
665 }
666  
667 =head2 get_aln
668  
669 Title : get_aln
670 Usage : my $aln = $hsp->gel_aln
671 Function: Returns a L<Bio::SimpleAlign> object representing the HSP alignment
672 Returns : L<Bio::SimpleAlign>
673 Args : none
674  
675 =cut
676  
677 18 ▶sub get_aln {
Subroutine get_aln: called CC=3 SCAR=11.0
Pod documented
678 18 my ($self) = @_;
679 18 require Bio::LocatableSeq;
680 18 require Bio::SimpleAlign;
681  
682 18 my $aln = Bio::SimpleAlign->new();
683 18 my $hs = $self->hit_string();
684 18 my $qs = $self->query_string();
685 # FASTA specific stuff moved to the FastaHSP object
686 18 my $seqonly = $qs;
687 18 $seqonly =~ s/[\-\s]//g;
688 18 my ($q_nm,$s_nm) = ($self->query->seq_id(),
689 $self->hit->seq_id());
690 # Should we silently change the name of the query or hit if it isn't
691 # defined? May need revisiting... cjfields 2008-12-3 (commented out below)
692
693 #unless( defined $q_nm && CORE::length ($q_nm) ) {
694 # $q_nm = 'query';
695 #}
696 #unless( defined $s_nm && CORE::length ($s_nm) ) {
697 # $s_nm = 'hit';
698 #}
699
700 # mapping: 1 residues for every x coordinate positions
701 my $query = Bio::LocatableSeq->new(
702 -seq => $qs,
703 -id => $q_nm,
704 -start => $self->query->start,
705 -end => $self->query->end,
706 -strand => $self->query->strand,
707 -force_nse => $q_nm ? 0 : 1,
708 18 ▶ -mapping => [ 1, $self->{_query_mapping} ]
Branch: 1 branch
BranchTrueFalseTotal
$q_nm ? : 16 2 18
709 );
710 18 $seqonly = $hs;
711 18 $seqonly =~ s/[\-\s]//g;
712 my $hit = Bio::LocatableSeq->new(
713 -seq => $hs,
714 -id => $s_nm,
715 -start => $self->hit->start,
716 -end => $self->hit->end,
717 -strand => $self->hit->strand,
718 -force_nse => $s_nm ? 0 : 1,
719 18 ▶ -mapping => [ 1, $self->{_hit_mapping} ]
Branch: 1 branch
BranchTrueFalseTotal
$s_nm ? : 18 0 18
720 );
721 18 $aln->add_seq($query);
722 18 $aln->add_seq($hit);
723 18 return $aln;
724 }
725  
726 =head2 num_conserved
727  
728 Title : num_conserved
729 Usage : $obj->num_conserved($newval)
730 Function: returns the number of conserved residues in the alignment
731 Returns : integer
732 Args : integer (optional)
733  
734  
735 =cut
736  
737 1786 ▶sub num_conserved{
Subroutine num_conserved: called CC=3 SCAR=12.7
Pod documented
738 1786 my ($self,$value) = @_;
739  
740 1786 ▶ unless ($self->{_did_presimilar}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_did_presimilar"}) 0 1786 1786
741 0 $self->_pre_similar_stats;
742 }
743  
744 1786 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 1786 1786
745 0 $self->{CONSERVED} = $value;
746 }
747 1786 return $self->{CONSERVED};
748 }
749  
750 =head2 num_identical
751  
752 Title : num_identical
753 Usage : $obj->num_identical($newval)
754 Function: returns the number of identical residues in the alignment
755 Returns : integer
756 Args : integer (optional)
757  
758  
759 =cut
760  
761 1786 ▶sub num_identical{
Subroutine num_identical: called CC=3 SCAR=11.2
Pod documented
762 1786 my ($self,$value) = @_;
763  
764 1786 ▶ unless ($self->{_did_presimilar}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_did_presimilar"}) 345 1441 1786
765 345 $self->_pre_similar_stats;
766 }
767  
768 1786 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 1786 1786
769 0 $self->{IDENTICAL} = $value;
770 }
771 1786 return $self->{IDENTICAL};
772 }
773  
774 =head2 rank
775  
776 Usage : $hsp->rank( [string] );
777 Purpose : Get the rank of the HSP within a given Blast hit.
778 Example : $rank = $hsp->rank;
779 Returns : Integer (1..n) corresponding to the order in which the HSP
780 appears in the BLAST report.
781  
782 =cut
783  
784 4506 ▶sub rank {
Subroutine rank: called CC=2 SCAR=7.6
Pod documented
785 4506 my ($self,$value) = @_;
786 4506 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 4506 4506
787 0 $self->{RANK} = $value;
788 }
789 4506 return $self->{RANK};
790 }
791  
792 =head2 seq_inds
793  
794 Title : seq_inds
795 Purpose : Get a list of residue positions (indices) for all identical
796 : or conserved residues in the query or sbjct sequence.
797 Example : @s_ind = $hsp->seq_inds('query', 'identical');
798 : @h_ind = $hsp->seq_inds('hit', 'conserved');
799 : @h_ind = $hsp->seq_inds('hit', 'conserved-not-identical');
800 : @h_ind = $hsp->seq_inds('hit', 'conserved', 1);
801 Returns : List of integers
802 : May include ranges if collapse is true.
803 Argument : seq_type = 'query' or 'hit' or 'sbjct' (default = query)
804 : ('sbjct' is synonymous with 'hit')
805 : class = 'identical' - identical positions
806 : 'conserved' - conserved positions
807 : 'nomatch' - mismatched residue or gap positions
808 : 'mismatch' - mismatched residue positions (no gaps)
809 : 'gap' - gap positions only
810 : 'frameshift'- frameshift positions only
811 : 'conserved-not-identical' - conserved positions w/o
812 : identical residues
813 : The name can be shortened to 'id' or 'cons' unless
814 : the name is . The default value is
815 : 'identical'
816 :
817 : collapse = boolean, if true, consecutive positions are merged
818 : using a range notation, e.g., "1 2 3 4 5 7 9 10 11"
819 : collapses to "1-5 7 9-11". This is useful for
820 : consolidating long lists. Default = no collapse.
821 :
822 Throws : n/a.
823 Comments : For HSPs partially or completely derived from translated sequences
824 : (TBLASTN, BLASTX, TBLASTX, or similar), some positional data
825 : cannot easily be attributed to a single position (i.e. the
826 : positional data is ambiguous). In these cases all three codon
827 : positions are reported. Under these conditions you can check
828 : ambiguous_seq_inds() to determine whether the query, subject,
829 : or both are ambiguous.
830 :
831 See Also : L<Bio::Search::SearchUtils::collapse_nums()|Bio::Search::SearchUtils>,
832 L<Bio::Search::Hit::HitI::seq_inds()|Bio::Search::Hit::HitI>
833  
834 =cut
835  
836 131 ▶sub seq_inds{
Subroutine seq_inds: called CC=20 SCAR=30.9
Pod documented
837 131 my ($self, $seqType, $class, $collapse) = @_;
838  
839 # prepare the internal structures - this is cached so
840 # if the strings have not changed we're okay
841 131 $self->_calculate_seq_positions();
842  
843 131 ▶ $seqType ||= 'query';
Condition50%1/2
$seqType ||= "query"
l!l
1310
MC/DC0%0/1
$seqType ||= "query"
$seqType
Truth table50%1/2
A
A= $seqType
Aresult
11
00
844 131 ▶ $class ||= 'identical';
Condition50%1/2
$class ||= "identical"
l!l
1310
MC/DC0%0/1
$class ||= "identical"
$class
Truth table50%1/2
A
A= $class
Aresult
11
00
845 131 ▶ $collapse ||= 0;
Condition100%2/2
$collapse ||= 0
l!l
30101
MC/DC100%1/1
$collapse ||= 0
$collapse
Truth table100%2/2
A
A= $collapse
Aresult
11
00
846 131 ▶ $seqType = 'sbjct' if $seqType eq 'hit';
Branch: 1 branch
BranchTrueFalseTotal
if $seqType eq "hit" 63 68 131
847 131 my $t = lc(substr($seqType,0,1));
848 131 ▶ if( $t eq 'q' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($t eq 'q') { } 68 63 131
elsif ($t eq 's' or $t eq 'h') { } 63 0 63
849 68 $seqType = 'query';
850 ▶ } elsif ( $t eq 's' || $t eq 'h' ) {
Condition33%1/3
$t eq "s" or $t eq "h"
l!l&&r!l&&!r
6300
MC/DC0%0/2
$t eq "s" or $t eq "h"
$t eq "s" $t eq "h"
Truth table33%1/3
A or B
A= $t eq "s"B= $t eq "h"
ABresult
1X1
011
000
851 63 $seqType = 'sbjct';
852 } else {
853 0 $self->warn("unknown seqtype $seqType using 'query'");
854 0 $seqType = 'query';
855 }
856
857 131 $t = lc(substr($class,0,1));
858  
859 131 ▶ if( $t eq 'c' ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($t eq 'c') { } 8 123 131
elsif ($t eq 'i') { } 0 123 123
elsif ($t eq 'n') { } 8 115 123
elsif ($t eq 'm') { } 8 107 115
elsif ($t eq 'g') { } 99 8 107
elsif ($t eq 'f') { } 8 0 8
860 8 ▶ if( $class =~ /conserved\-not\-identical/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class =~ /conserved\-not\-identical/) { } 0 8 8
861 0 $class = 'conserved';
862 } else {
863 8 $class = 'conservedall';
864 }
865 } elsif( $t eq 'i' ) {
866 0 $class = 'identical';
867 } elsif( $t eq 'n' ) {
868 8 $class = 'nomatch';
869 } elsif( $t eq 'm' ) {
870 8 $class = 'mismatch';
871 } elsif( $t eq 'g' ) {
872 99 $class = 'gap';
873 } elsif( $t eq 'f' ) {
874 8 $class = 'frameshift';
875 } else {
876 0 $self->warn("unknown sequence class $class using 'identical'");
877 0 $class = 'identical';
878 }
879  
880 ## Sensitive to member name changes.
881 131 $seqType = "_\L$seqType\E";
882 131 $class = "_\L$class\E";
883 131 my @ary;
884  
885 131 ▶ if( $class eq '_gap' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq '_gap') { } 99 32 131
elsif ($class eq '_conservedall') { } 8 24 32
886 # this means that we are remapping the gap length that is stored
887 # in the hash (for example $self->{'_gapRes_query'} )
888 # so we'll return an array which has the values of the position of the
889 # of the gap (the key in the hash) + the gap length (value in the
890 # hash for this key - 1.
891
892 # changing this; since the index is the position prior to the insertion,
893 # repeat the position based on the number of gaps inserted
894 37 @ary = map { my @tmp;
895 # position holds number of gaps inserted
896 37 for my $g (1..$self->{seqinds}{"${class}Res$seqType"}->{$_}) {
897 192 push @tmp, $_ ;
898 }
899 37 @tmp}
900 99 sort { $a <=> $b } keys %{ $self->{seqinds}{"${class}Res$seqType"}};
901 } elsif( $class eq '_conservedall' ) {
902 13448 @ary = sort { $a <=> $b }
903 8 keys %{ $self->{seqinds}{"_conservedRes$seqType"}},
904 8 keys %{ $self->{seqinds}{"_identicalRes$seqType"}},
905 } else {
906 24 @ary = sort { $a <=> $b } keys %{ $self->{seqinds}{"${class}Res$seqType"}};
907 }
908 131 ▶ require Bio::Search::BlastUtils if $collapse;
Branch: 1 branch
BranchTrueFalseTotal
if $collapse 30 101 131
909  
910 131 ▶ return $collapse ? &Bio::Search::SearchUtils::collapse_nums(@ary) : @ary;
Branch: 1 branch
BranchTrueFalseTotal
$collapse ? : 30 101 131
911 }
912  
913 =head2 ambiguous_seq_inds
914  
915 Title : ambiguous_seq_inds
916 Purpose : returns a string denoting whether sequence indices for query,
917 : subject, or both are ambiguous
918 Returns : String; 'query', 'subject', 'query/subject', or empty string ''
919 Argument : none
920 Comments : For HSPs partially or completely derived from translated sequences
921 : (TBLASTN, BLASTX, TBLASTX, or similar), some positional data
922 : cannot easily be attributed to a single position (i.e. the
923 : positional data is ambiguous). In these cases all three codon
924 : positions are reported when using seq_inds(). Under these
925 : conditions you can check ambiguous_seq_inds() to determine whether
926 : the query, subject, or both are ambiguous.
927 See Also : L<Bio::Search::Hit::HSPI::seq_inds()>
928  
929 =cut
930  
931 2 ▶sub ambiguous_seq_inds {
Subroutine ambiguous_seq_inds: called CC=5 SCAR=16.7
Pod documented
932 2 my $self = shift;
933 2 $self->_calculate_seq_positions();
934 my $type = ($self->{_query_offset} == 3 && $self->{_sbjct_offset} == 3) ?
935 'query/subject' :
936 ($self->{_query_offset} == 3) ? 'query' :
937 2 ▶ ($self->{_sbjct_offset} == 3) ? 'subject' : '';
Branch: 3 branches
BranchTrueFalseTotal
$self->{'_query_offset'} == 3 && $self->{'_sbjct_offset'} == 3 ? : 0 2 2
$self->{'_query_offset'} == 3 ? : 1 1 2
$self->{'_sbjct_offset'} == 3 ? : 0 1 1
Condition66%2/3
$self->{"_query_offset"} == 3 and $self->{"_sbjct_offset"} == 3
!ll&&!rl&&r
110
MC/DC0%0/2
$self->{"_query_offset"} == 3 and $self->{"_sbjct_offset"} == 3
$self->{"_query_offset"} == 3 $self->{"_sbjct_offset"} == 3
Truth table66%2/3
A and B
A= $self->{"_query_offset"} == 3B= $self->{"_sbjct_offset"} == 3
ABresult
0X0
100
111
938 2 return $type;
939 }
940  
941 =head2 Inherited from L<Bio::SeqFeature::SimilarityPair>
942  
943 These methods come from L<Bio::SeqFeature::SimilarityPair>
944  
945 =head2 query
946  
947 Title : query
948 Usage : my $query = $hsp->query
949 Function: Returns a SeqFeature representing the query in the HSP
950 Returns : L<Bio::SeqFeature::Similarity>
951 Args : [optional] new value to set
952  
953 =cut
954  
955 4784 ▶sub query {
Subroutine query: called CC=2 SCAR=6.9
Pod documented
956 4784 my $self = shift;
957 4784 ▶ unless ($self->{_created_qff}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_created_qff"}) 1035 3749 4784
958 1035 $self->_query_seq_feature;
959 }
960 4784 return $self->SUPER::query(@_);
961 }
962  
963 5863 ▶sub feature1 {
Subroutine feature1: called CC=5 SCAR=16.2
Pod documented
964 5863 my $self = shift;
965 5863 ▶ if (! $self->{_finished_new} || $self->{_making_qff}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"_finished_new"} or $self->{"_making_qff"}) 1073 4790 5863
Condition66%2/3
not $self->{"_finished_new"} or $self->{"_making_qff"}
l!l&&r!l&&!r
107304790
MC/DC50%1/2
not $self->{"_finished_new"} or $self->{"_making_qff"}
not $self->{"_finished_new"} $self->{"_making_qff"}
Truth table66%2/3
not(A) or B
A= not $self->{"_finished_new"}B= $self->{"_making_qff"}
ABresult
1X1
011
000
966 1073 ▶ return $self->{_sim1} if $self->{_sim1};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_sim1"} 0 1073 1073
967 1073 $self->{_sim1} = Bio::SeqFeature::Similarity->new();
968 1073 return $self->{_sim1};
969 }
970 4790 ▶ unless ($self->{_created_qff}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_created_qff"}) 2 4788 4790
971 2 $self->_query_seq_feature;
972 }
973 4790 return $self->SUPER::feature1(@_);
974 }
975  
976 =head2 hit
977  
978 Title : hit
979 Usage : my $hit = $hsp->hit
980 Function: Returns a SeqFeature representing the hit in the HSP
981 Returns : L<Bio::SeqFeature::Similarity>
982 Args : [optional] new value to set
983  
984 =cut
985  
986 3740 ▶sub hit {
Subroutine hit: called CC=2 SCAR=6.9
Pod documented
987 3740 my $self = shift;
988 3740 ▶ unless ($self->{_created_sff}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_created_sff"}) 434 3306 3740
989 434 $self->_subject_seq_feature;
990 }
991 3740 return $self->SUPER::hit(@_);
992 }
993  
994 3746 ▶sub feature2 {
Subroutine feature2: called CC=5 SCAR=20.3
Pod documented
995 3746 my $self = shift;
996 3746 ▶ if (! $self->{_finished_new} || $self->{_making_sff}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"_finished_new"} or $self->{"_making_sff"}) 0 3746 3746
Condition33%1/3
not $self->{"_finished_new"} or $self->{"_making_sff"}
l!l&&r!l&&!r
003746
MC/DC0%0/2
not $self->{"_finished_new"} or $self->{"_making_sff"}
not $self->{"_finished_new"} $self->{"_making_sff"}
Truth table33%1/3
not(A) or B
A= not $self->{"_finished_new"}B= $self->{"_making_sff"}
ABresult
1X1
011
000
997 0 ▶ return $self->{_sim2} if $self->{_sim2};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_sim2"} 0 0 0
998 0 $self->{_sim2} = Bio::SeqFeature::Similarity->new();
999 0 return $self->{_sim2};
1000 }
1001 3746 ▶ unless ($self->{_created_sff}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_created_sff"}) 3 3743 3746
1002 3 $self->_subject_seq_feature;
1003 }
1004 3746 return $self->SUPER::feature2(@_);
1005 }
1006  
1007 =head2 significance
1008  
1009 Title : significance
1010 Usage : $evalue = $obj->significance();
1011 $obj->significance($evalue);
1012 Function: Get/Set the significance value
1013 Returns : numeric
1014 Args : [optional] new value to set
1015  
1016 =cut
1017  
1018 # Override significance to return the e-value or, if this is
1019 # not defined (WU-BLAST), return the p-value.
1020 6 ▶sub significance {
Subroutine significance: called CC=6 SCAR=19.6
Pod documented
1021 6 my ($self, $val) = @_;
1022 6 ▶ if (!defined $self->{SIGNIFICANCE} || defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"SIGNIFICANCE"} or defined $val) 6 0 6
Condition33%1/3
not defined $self->{"SIGNIFICANCE"} or defined $val
l!l&&r!l&&!r
600
MC/DC0%0/2
not defined $self->{"SIGNIFICANCE"} or defined $val
not defined $self->{"SIGNIFICANCE"} defined $val
Truth table33%1/3
not(A) or B
A= not defined $self->{"SIGNIFICANCE"}B= defined $val
ABresult
1X1
011
000
1023 6 ▶ $self->{SIGNIFICANCE} = defined $val ? $val :
Branch: 3 branches
BranchTrueFalseTotal
defined $val ? : 0 6 6
defined $self->evalue ? : 4 2 6
defined $self->pvalue ? : 0 2 2
1024 defined $self->evalue ? $self->evalue :
1025 defined $self->pvalue ? $$self->pvalue :
1026 undef;
1027 6 $self->query->significance($self->{SIGNIFICANCE});
1028 }
1029 6 return $self->{SIGNIFICANCE};
1030 }
1031  
1032 =head2 strand
1033  
1034 Title : strand
1035 Usage : $hsp->strand('query')
1036 Function: Retrieves the strand for the HSP component requested
1037 Returns : +1 or -1
1038 Args : 'hit' or 'subject' or 'sbjct' to retrieve the strand of the subject,
1039 'query' to retrieve the query strand (default)
1040  
1041 =cut
1042  
1043 562 ▶sub strand {
Subroutine strand: called CC=5 SCAR=18.9
Pod documented
1044 562 my ($self,$type) = @_;
1045  
1046 562 ▶ if( $type =~ /^q/i && defined $self->{'QUERY_STRAND'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /^q/i and defined $self->{'QUERY_STRAND'}) { } 0 562 562
elsif ($type =~ /^(hit|subject|sbjct)/i and defined $self->{'HIT_STRAND'}) { } 0 840 840
Condition66%2/3
$type =~ /^q/i and defined $self->{"QUERY_STRAND"}
!ll&&!rl&&r
2842780
MC/DC0%0/2
$type =~ /^q/i and defined $self->{"QUERY_STRAND"}
$type =~ /^q/i defined $self->{"QUERY_STRAND"}
Truth table66%2/3
A and B
A= $type =~ /^q/iB= defined $self->{"QUERY_STRAND"}
ABresult
0X0
100
111
1047 0 return $self->{'QUERY_STRAND'};
1048 ▶ } elsif( $type =~ /^(hit|subject|sbjct)/i && defined $self->{'HIT_STRAND'} ) {
Condition66%2/3
$type =~ /^(hit|subject|sbjct)/i and defined $self->{"HIT_STRAND"}
!ll&&!rl&&r
2782840
MC/DC0%0/2
$type =~ /^(hit|subject|sbjct)/i and defined $self->{"HIT_STRAND"}
$type =~ /^(hit|subject|sbjct)/i defined $self->{"HIT_STRAND"}
Truth table66%2/3
A and B
A= $type =~ /^(hit|subject|sbjct)/iB= defined $self->{"HIT_STRAND"}
ABresult
0X0
100
111
1049 0 return $self->{'HIT_STRAND'};
1050 }
1051  
1052 562 return $self->SUPER::strand($type)
1053 }
1054  
1055 =head2 score
1056  
1057 Title : score
1058 Usage : $score = $obj->score();
1059 $obj->score($value);
1060 Function: Get/Set the score value
1061 Returns : numeric
1062 Args : [optional] new value to set
1063  
1064 =head2 bits
1065  
1066 Title : bits
1067 Usage : $bits = $obj->bits();
1068 $obj->bits($value);
1069 Function: Get/Set the bits value
1070 Returns : numeric
1071 Args : [optional] new value to set
1072  
1073 =head1 Private methods
1074  
1075 =cut
1076  
1077 =head2 _calculate_seq_positions
1078  
1079 Title : _calculate_seq_positions
1080 Usage : $self->_calculate_seq_positions
1081 Function: Internal function
1082 Returns :
1083 Args :
1084  
1085  
1086 =cut
1087  
1088 138 ▶sub _calculate_seq_positions {
Subroutine _calculate_seq_positions: called CC=44 SCAR=38.3
1089 138 my ($self,@args) = @_;
1090 138 ▶ return unless ( $self->{'_sequenceschanged'} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_sequenceschanged"} 90 48 138
1091 48 $self->{'_sequenceschanged'} = 0;
1092 48 my ($seqString, $qseq,$sseq) = ( $self->homology_string(),
1093 $self->query_string(),
1094 $self->hit_string() );
1095 48 my ($mlen, $qlen, $slen) = (CORE::length($seqString), CORE::length($qseq), CORE::length($sseq));
1096 48 ▶ my $qdir = $self->query->strand || 1;
Condition100%2/2
$self->query->strand || 1
l!l
462
MC/DC100%1/1
$self->query->strand || 1
$self->query->strand
Truth table100%2/2
A
A= $self->query->strand
Aresult
11
00
1097 48 ▶ my $sdir = $self->hit->strand || 1;
Condition100%2/2
$self->hit->strand || 1
l!l
453
MC/DC100%1/1
$self->hit->strand || 1
$self->hit->strand
Truth table100%2/2
A
A= $self->hit->strand
Aresult
11
00
1098 48 ▶ my ($resCount_query, $endpoint_query) = ($qdir <=0) ? ($self->query->end, $self->query->start)
Branch: 1 branch
BranchTrueFalseTotal
$qdir <= 0 ? : 16 32 48
1099 : ($self->query->start, $self->query->end);
1100 48 ▶ my ($resCount_sbjct, $endpoint_sbjct) = ($sdir <=0) ? ($self->hit->end, $self->hit->start)
Branch: 1 branch
BranchTrueFalseTotal
$sdir <= 0 ? : 11 37 48
1101 : ($self->hit->start, $self->hit->end);
1102
1103 48 my $prog = $self->algorithm;
1104
1105 48 ▶ if( $prog =~ /FAST|SSEARCH|SMITH-WATERMAN/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prog =~ /FAST|SSEARCH|SMITH-WATERMAN/i) 4 44 48
1106
1107 # we infer the end of the regional sequence where the first and last
1108 # non spaces are in the homology string
1109 # then we use the HSP->length to tell us how far to read
1110 # to cut off the end of the sequence
1111
1112 4 my ($start, $rest) = (0,0);
1113 4 ▶ if( $seqString =~ /^(\s+)?(.*?)\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seqString =~ /^(\s+)?(.*?)\s*$/) 4 0 4
1114 4 ▶ ($start, $rest) = ($1 ? CORE::length($1) : 0, CORE::length($2));
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 3 1 4
1115 }
1116
1117 4 $seqString = substr($seqString, $start, $rest);
1118 4 $qseq = substr($qseq, $start, $rest);
1119 4 $sseq = substr($sseq, $start, $rest);
1120  
1121 # commented out 10/29/08
1122 # removing frameshift symbols doesn't take into account the following:
1123 # 1) does not remove the same point in the homology string (get
1124 # positional errors)
1125 # 2) adjustments to the overall position in the string due to the
1126 # frameshift must be taken into consideration (get balancing errors)
1127 #
1128 # Frameshifts will be handled directly in the main loop.
1129 # --chris
1130
1131 # fasta reports some extra 'regional' sequence information
1132 # we need to clear out first
1133 # this seemed a bit insane to me at first, but it appears to
1134 # work --jason
1135
1136 #$qseq =~ s![\\\/]!!g;
1137 #$sseq =~ s![\\\/]!!g;
1138 }
1139  
1140 48 ▶ if (!defined($self->{_sbjct_offset}) || !defined($self->{_query_offset})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_sbjct_offset"} and defined $self->{"_query_offset"}) 2 46 48
Condition66%2/3
defined $self->{"_sbjct_offset"} and defined $self->{"_query_offset"}
!ll&&!rl&&r
2046
MC/DC50%1/2
defined $self->{"_sbjct_offset"} and defined $self->{"_query_offset"}
defined $self->{"_sbjct_offset"} defined $self->{"_query_offset"}
Truth table66%2/3
A and B
A= defined $self->{"_sbjct_offset"}B= defined $self->{"_query_offset"}
ABresult
0X0
100
111
1141 2 $self->_calculate_seq_offsets();
1142 }
1143
1144 48 my ($qfs, $sfs) = (0,0);
1145 CHAR_LOOP:
1146 48 for my $pos (0..CORE::length($seqString)-1) {
1147 3501 my @qrange = (0 - $qfs)..($self->{_query_offset} - 1);
1148 3501 my @srange = (0 - $sfs)..($self->{_sbjct_offset} - 1);
1149 # $self->debug("QRange:@qrange SRange:@srange\n") if ($qfs || $sfs);
1150 3501 ($qfs, $sfs) = (0,0);
1151 3501 ▶ my ($mchar, $qchar, $schar) = (
Branch: 2 branches
BranchTrueFalseTotal
$pos < CORE::length $qseq ? : 3501 0 3501
$pos < CORE::length $sseq ? : 3501 0 3501
Condition100%2/2
unpack("x$pos A1", $seqString) || ' '
l!l
2620881
MC/DC100%1/1
unpack("x$pos A1", $seqString) || ' '
unpack("x$pos A1", $seqString)
Truth table100%2/2
A
A= unpack("x$pos A1", $seqString)
Aresult
11
00
1152 unpack("x$pos A1",$seqString) || ' ',
1153 $pos < CORE::length($qseq) ? unpack("x$pos A1",$qseq) : '-',
1154 $pos < CORE::length($sseq) ? unpack("x$pos A1",$sseq) : '-'
1155 );
1156 3501 my $matchtype = '';
1157 3501 my ($qgap, $sgap) = (0,0);
1158 3501 ▶ if( $mchar eq '+' || $mchar eq '.') { # conserved
Branch: 3 branches
BranchTrueFalseTotal
if ($mchar eq '+' or $mchar eq '.') { } 358 3143 3501
elsif ($mchar eq ':' or $mchar ne ' ') { } 2262 881 3143
elsif ($mchar eq ' ') { } 881 0 881
Condition100%3/3
$mchar eq "+" or $mchar eq "."
l!l&&r!l&&!r
1901683143
MC/DC100%2/2
$mchar eq "+" or $mchar eq "."
$mchar eq "+" $mchar eq "."
Truth table100%3/3
A or B
A= $mchar eq "+"B= $mchar eq "."
ABresult
1X1
011
000
1159 358 $self->{seqinds}{_conservedRes_query}{ $resCount_query + ($_ * $qdir) } = 1 for @qrange;
1160 358 $self->{seqinds}{_conservedRes_sbjct}{ $resCount_sbjct + ($_ * $sdir) } = 1 for @srange;
1161 358 $matchtype = 'conserved';
1162 ▶ } elsif( $mchar eq ':' || $mchar ne ' ' ) { # identical
Condition100%3/3
$mchar eq ":" or $mchar ne " "
l!l&&r!l&&!r
5601702881
MC/DC100%2/2
$mchar eq ":" or $mchar ne " "
$mchar eq ":" $mchar ne " "
Truth table100%3/3
A or B
A= $mchar eq ":"B= $mchar ne " "
ABresult
1X1
011
000
1163 2262 $self->{seqinds}{_identicalRes_query}{ $resCount_query + ($_ * $qdir) } = 1 for @qrange;
1164 2262 $self->{seqinds}{_identicalRes_sbjct}{ $resCount_sbjct + ($_ * $sdir) } = 1 for @srange;
1165 2262 $matchtype = 'identical';
1166 } elsif( $mchar eq ' ' ) { # possible mismatch/nomatch/frameshift
1167 881 ▶ $qfs = $qchar eq '/' ? -1 : # base inserted to match frame
Branch: 2 branches
BranchTrueFalseTotal
$qchar eq '/' ? : 0 881 881
$qchar eq '\\' ? : 2 879 881
1168 $qchar eq '\\' ? 1 : # base deleted to match frame
1169 0;
1170 881 ▶ $sfs = $schar eq '/' ? -1 :
Branch: 2 branches
BranchTrueFalseTotal
$schar eq '/' ? : 0 881 881
$schar eq '\\' ? : 0 881 881
1171 $schar eq '\\' ? 1 :
1172 0;
1173 881 ▶ if ($qfs) {
Branch: 4 branches
BranchTrueFalseTotal
if ($qfs) { } 2 879 881
elsif ($sfs) { } 0 879 879
elsif ($qchar eq $self->{'GAP_SYMBOL'}) { } 27 852 879
elsif ($schar eq $self->{'GAP_SYMBOL'}) { } 78 774 852
1174 # Frameshifts are tricky.
1175
1176 # '/' indicates that the next residue is shifted back one
1177 # (-1) frame position and is a deletion of one base (so to
1178 # correctly align, a base is inserted). That residue should only
1179 # occupy two sequence positions instead of three.
1180
1181 # '\' indicates that the next residue is shifted forward
1182 # one (+1) frame position and is an insertion of one base (so to
1183 # correctly align, a base is removed). That residue should
1184 # occupy four sequence positions instead of three.
1185
1186 # Note that gaps are not counted across from frameshifts.
1187 # Frameshift indices are a range of positions starting in the
1188 # previous sequence position in which the frameshift occurs;
1189 # they are ambiguous by nature.
1190 2 $self->{seqinds}{_frameshiftRes_query}{ $resCount_query - ($_ * $qdir * $qfs) } = $qfs for @qrange;
1191 2 $matchtype = "$qfs frameshift-query";
1192 2 $sgap = $qgap = 1;
1193 }
1194 elsif ($sfs) {
1195 0 $self->{seqinds}{_frameshiftRes_sbjct}{ $resCount_sbjct - ($_ * $sdir * $sfs) } = $sfs for @srange;
1196 0 $matchtype = "$sfs frameshift-sbcjt";
1197 0 $sgap = $qgap = 1;
1198 }
1199 elsif ($qchar eq $self->{GAP_SYMBOL}) {
1200 # gap are counted as being in the immediately preceeding residue
1201 # position; for translated sequences this is not the start of
1202 # the previous codon, but the third codon position
1203 27 $self->{seqinds}{_gapRes_query}{ $resCount_query - $qdir }++ for @qrange;
1204 27 $matchtype = 'gap-query';
1205 27 $qgap++;
1206 }
1207 elsif ($schar eq $self->{GAP_SYMBOL}) {
1208 78 $self->{seqinds}{_gapRes_sbjct}{ $resCount_sbjct - $sdir }++ for @srange;
1209 78 $matchtype = 'gap-sbjct';
1210 78 $sgap++;
1211 }
1212 else {
1213 # if not a gap or frameshift in either seq, must be mismatch
1214 774 $self->{seqinds}{_mismatchRes_query}{ $resCount_query + ($_ * $qdir) } = 1 for @qrange;
1215 774 $self->{seqinds}{_mismatchRes_sbjct}{ $resCount_sbjct + ($_ * $sdir) } = 1 for @srange;
1216 774 $matchtype = 'mismatch';
1217 }
1218 # always add a nomatch unless the current position in the seq is a gap
1219 881 ▶ if (!$sgap) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sgap) 801 80 881
1220 801 $self->{seqinds}{_nomatchRes_sbjct}{ $resCount_sbjct + ($_ * $sdir) } = 1 for @srange;
1221 }
1222 881 ▶ if (!$qgap) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($qgap) 852 29 881
1223 852 $self->{seqinds}{_nomatchRes_query}{ $resCount_query + ($_ * $qdir) } = 1 for @qrange;
1224 }
1225 } else {
1226 0 $self->warn("Unknown midline character: [$mchar]");
1227 }
1228 # leave in and uncomment for future debugging
1229 #$self->debug(sprintf("%7d %1s[%1s]%1s %-7d Type: %-20s QOff:%-2d SOff:%-2d\n",
1230 # $resCount_query,
1231 # $qchar,
1232 # $mchar,
1233 # $schar,
1234 # $resCount_sbjct,
1235 # $matchtype,
1236 # ($self->{_query_offset} * $qdir),
1237 # ($self->{_sbjct_offset} * $sdir)));
1238 3501 ▶ $resCount_query += ($qdir * (scalar(@qrange) + $qfs)) if !$qgap;
Branch: 1 branch
BranchTrueFalseTotal
unless $qgap 3472 29 3501
1239 3501 ▶ $resCount_sbjct += ($sdir * (scalar(@srange) + $sfs)) if !$sgap;
Branch: 1 branch
BranchTrueFalseTotal
unless $sgap 3421 80 3501
1240 }
1241 48 return 1;
1242 }
1243  
1244 74 ▶sub _calculate_seq_offsets {
Subroutine _calculate_seq_offsets: called CC=5 SCAR=16.3
1245 74 my $self = shift;
1246 74 my $prog = $self->algorithm;
1247 74 ($self->{_sbjct_offset}, $self->{_query_offset}) = (1,1);
1248 74 ▶ if($prog =~ /^(?:PSI)?T(BLAST|FAST)(N|X|Y)/oi ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($prog =~ /^(?:PSI)?T(BLAST|FAST)(N|X|Y)/io) { } 63 11 74
elsif ($prog =~ /^(BLAST|FAST)(X|Y|XY)/io) { } 1 10 11
1249 63 $self->{_sbjct_offset} = 3;
1250 63 ▶ if ($1 eq 'BLAST' && $2 eq 'X') { #TBLASTX
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq "BLAST" and $2 eq "X") 63 0 63
Condition33%1/3
$1 eq "BLAST" and $2 eq "X"
!ll&&!rl&&r
0063
MC/DC0%0/2
$1 eq "BLAST" and $2 eq "X"
$1 eq "BLAST" $2 eq "X"
Truth table33%1/3
A and B
A= $1 eq "BLAST"B= $2 eq "X"
ABresult
0X0
100
111
1251 63 $self->{_query_offset} = 3;
1252 }
1253 } elsif($prog =~ /^(BLAST|FAST)(X|Y|XY)/oi ) {
1254 1 $self->{_query_offset} = 3;
1255 }
1256 74 1;
1257 }
1258  
1259 =head2 n
1260  
1261 See documentation in L<Bio::Search::HSP::HSPI::n()|Bio::Search::HSP::HSPI>
1262  
1263 =cut
1264  
1265 1 ▶sub n {
Subroutine n: called CC=3 SCAR=12.5
Pod documented
1266 1 my $self = shift;
1267 0 ▶ if(@_) { $self->{'N'} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
1268 # note that returning 1 is completely an assumption
1269 1 ▶ defined $self->{'N'} ? $self->{'N'} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'N'} ? : 0 1 1
1270 }
1271  
1272 =head2 range
1273  
1274 See documentation in L<Bio::Search::HSP::HSPI::range()|Bio::Search::HSP::HSPI>
1275  
1276 =cut
1277  
1278 1521 ▶sub range {
Subroutine range: called CC=4 SCAR=13.9
Pod documented
1279 1521 my ($self, $seqType) = @_;
1280  
1281 1521 ▶ $seqType ||= 'query';
Condition100%2/2
$seqType ||= "query"
l!l
15183
MC/DC100%1/1
$seqType ||= "query"
$seqType
Truth table100%2/2
A
A= $seqType
Aresult
11
00
1282 1521 ▶ $seqType = 'sbjct' if $seqType eq 'hit';
Branch: 1 branch
BranchTrueFalseTotal
if $seqType eq "hit" 757 764 1521
1283  
1284 1521 my ($start, $end);
1285 1521 ▶ if( $seqType eq 'query' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seqType eq 'query') { } 762 759 1521
1286 762 $start = $self->query->start;
1287 762 $end = $self->query->end;
1288 }
1289 else {
1290 759 $start = $self->hit->start;
1291 759 $end = $self->hit->end;
1292 }
1293 1521 return ($start, $end);
1294 }
1295  
1296  
1297 =head2 links
1298  
1299 Title : links
1300 Usage : $obj->links($newval)
1301 Function: Get/Set the Links value (from WU-BLAST)
1302 Indicates the placement of the alignment in the group of HSPs
1303 Returns : Value of links
1304 Args : On set, new value (a scalar or undef, optional)
1305  
1306  
1307 =cut
1308  
1309 45 ▶sub links{
Subroutine links: called CC=2 SCAR=7.1
Pod documented
1310 45 my $self = shift;
1311  
1312 45 ▶ return $self->{LINKS} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 45 45
1313 45 return $self->{LINKS};
1314 }
1315  
1316 =head2 hsp_group
1317  
1318 Title : hsp_group
1319 Usage : $obj->hsp_group($newval)
1320 Function: Get/Set the Group value (from WU-BLAST)
1321 Indicates a grouping of HSPs
1322 Returns : Value of group
1323 Args : On set, new value (a scalar or undef, optional)
1324  
1325  
1326 =cut
1327  
1328 3 ▶sub hsp_group {
Subroutine hsp_group: called CC=2 SCAR=7.1
Pod documented
1329 3 my $self = shift;
1330  
1331 3 ▶ return $self->{HSP_GROUP} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 3 3
1332 3 return $self->{HSP_GROUP};
1333 }
1334  
1335 =head2 hit_features
1336  
1337 Title : hit_features
1338 Usage : $obj->hit_features($newval)
1339 Function: Get/Set the HSP hit feature string (from some BLAST 2.2.13 text
1340 output), which is a string of overlapping or nearby features in HSP
1341 hit
1342 Returns : Value of hit features, if present
1343 Args : On set, new value (a scalar or undef, optional)
1344  
1345  
1346 =cut
1347  
1348 0 ▶sub hit_features {
Subroutine hit_features: not called CC=2 SCAR=17.9
Pod documented
1349 0 my $self = shift;
1350  
1351 0 ▶ return $self->{HIT_FEATURES} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
1352 0 return $self->{HIT_FEATURES};
1353 }
1354  
1355 # The cigar string code is written by Juguang Xiao <juguang@fugu-sg.org>
1356  
1357 =head1 Brief introduction on cigar string
1358  
1359 NOTE: the concept is originally from EnsEMBL docs at
1360 http://may2005.archive.ensembl.org/Docs/wiki/html/EnsemblDocs/CigarFormat.html
1361 Please append to these docs if you have a better definition.
1362  
1363 Sequence alignment hits can be stored in a database as ungapped alignments.
1364 This imposes 2 major constraints on alignments:
1365  
1366 a) alignments for a single hit record require multiple rows in the database,
1367 and
1368 b) it is not possible to accurately retrieve the exact original alignment.
1369  
1370 Alternatively, sequence alignments can be stored as gapped alignments using
1371 the CIGAR line format (where CIGAR stands for Concise Idiosyncratic Gapped
1372 Alignment Report).
1373  
1374 In the cigar line format alignments are stored as follows:
1375  
1376 M: Match
1377 D: Deletion
1378 I: Insertion
1379  
1380 An example of an alignment for a hypthetical protein match is shown below:
1381  
1382  
1383 Query: 42 PGPAGLP----GSVGLQGPRGLRGPLP-GPLGPPL...
1384  
1385 PG P G GP R PLGP
1386  
1387 Sbjct: 1672 PGTP*TPLVPLGPWVPLGPSSPR--LPSGPLGPTD...
1388  
1389  
1390 protein_align_feature table as the following cigar line:
1391  
1392 7M4D12M2I2MD7M
1393  
1394 =head2 cigar_string
1395  
1396 Name: cigar_string
1397 Usage: $cigar_string = $hsp->cigar_string
1398 Function: Generate and return cigar string for this HSP alignment
1399 Args: No input needed
1400 Return: a cigar string
1401  
1402 =cut
1403  
1404  
1405 8 ▶sub cigar_string {
Subroutine cigar_string: called CC=3 SCAR=11.0
Pod documented
1406 8 my ($self, $arg) = @_;
1407 8 ▶ $self->warn("this is not a setter") if(defined $arg);
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 0 8 8
1408  
1409 8 ▶ unless(defined $self->{_cigar_string}){ # generate cigar string
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_cigar_string"}) 7 1 8
1410 7 my $cigar_string = $self->generate_cigar_string($self->query_string, $self->hit_string);
1411 7 $self->{_cigar_string} = $cigar_string;
1412 } # end of unless
1413  
1414 8 return $self->{_cigar_string};
1415 }
1416  
1417 =head2 generate_cigar_string
1418  
1419 Name: generate_cigar_string
1420 Usage: my $cigar_string = Bio::Search::HSP::GenericHSP::generate_cigar_string ($qstr, $hstr);
1421 Function: generate cigar string from a simple sequence of alignment.
1422 Args: the string of query and subject
1423 Return: cigar string
1424  
1425 =cut
1426  
1427 7 ▶sub generate_cigar_string {
Subroutine generate_cigar_string: called CC=7 SCAR=19.6
Pod documented
1428 7 my ($self, $qstr, $hstr) = @_;
1429 7 my @qchars = split //, $qstr;
1430 7 my @hchars = split //, $hstr;
1431  
1432 7 ▶ unless(scalar(@qchars) == scalar(@hchars)){
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @qchars == scalar @hchars) 0 7 7
1433 0 $self->throw("two sequences are not equal in lengths");
1434 }
1435  
1436 7 $self->{_count_for_cigar_string} = 0;
1437 7 $self->{_state_for_cigar_string} = 'M';
1438  
1439 7 my $cigar_string = '';
1440 7 ▶ for(my $i=0; $i <= $#qchars; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#qchars) 1917 7 1924
1441 1917 my $qchar = $qchars[$i];
1442 1917 my $hchar = $hchars[$i];
1443 1917 ▶ if($qchar ne $self->{GAP_SYMBOL} && $hchar ne $self->{GAP_SYMBOL}){ # Match
Branch: 3 branches
BranchTrueFalseTotal
if ($qchar ne $self->{'GAP_SYMBOL'} and $hchar ne $self->{'GAP_SYMBOL'}) { } 1837 80 1917
elsif ($qchar eq $self->{'GAP_SYMBOL'}) { } 13 67 80
elsif ($hchar eq $self->{'GAP_SYMBOL'}) { } 67 0 67
Condition100%3/3
$qchar ne $self->{"GAP_SYMBOL"} and $hchar ne $self->{"GAP_SYMBOL"}
!ll&&!rl&&r
13671837
MC/DC100%2/2
$qchar ne $self->{"GAP_SYMBOL"} and $hchar ne $self->{"GAP_SYMBOL"}
$qchar ne $self->{"GAP_SYMBOL"} $hchar ne $self->{"GAP_SYMBOL"}
Truth table100%3/3
A and B
A= $qchar ne $self->{"GAP_SYMBOL"}B= $hchar ne $self->{"GAP_SYMBOL"}
ABresult
0X0
100
111
1444 1837 $cigar_string .= $self->_sub_cigar_string('M');
1445 }elsif($qchar eq $self->{GAP_SYMBOL}){ # Deletion
1446 13 $cigar_string .= $self->_sub_cigar_string('D');
1447 }elsif($hchar eq $self->{GAP_SYMBOL}){ # Insertion
1448 67 $cigar_string .= $self->_sub_cigar_string('I');
1449 }else{
1450 0 $self->throw("Impossible state that 2 gaps on each seq aligned");
1451 }
1452 }
1453 7 $cigar_string .= $self->_sub_cigar_string('X'); # not forget the tail.
1454 7 return $cigar_string;
1455 }
1456  
1457 # an internal method to help generate cigar string
1458  
1459 1924 ▶sub _sub_cigar_string {
Subroutine _sub_cigar_string: called CC=3 SCAR=11.0
1460 1924 my ($self, $new_state) = @_;
1461  
1462 1924 my $sub_cigar_string = '';
1463 1924 ▶ if($self->{_state_for_cigar_string} eq $new_state){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_state_for_cigar_string'} eq $new_state) { } 1835 89 1924
1464 1835 $self->{_count_for_cigar_string} += 1; # Remain the state and increase the counter
1465 }else{
1466 $sub_cigar_string .= $self->{_count_for_cigar_string}
1467 89 ▶ unless $self->{_count_for_cigar_string} == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_count_for_cigar_string"} == 1 55 34 89
1468 89 $sub_cigar_string .= $self->{_state_for_cigar_string};
1469 89 $self->{_count_for_cigar_string} = 1;
1470 89 $self->{_state_for_cigar_string} = $new_state;
1471 }
1472 1924 return $sub_cigar_string;
1473 }
1474  
1475 # needed before seqfeatures can be made
1476 1038 ▶sub _pre_seq_feature {
Subroutine _pre_seq_feature: called CC=15 SCAR=27.6
1477 1038 my $self = shift;
1478 1038 my $algo = $self->{ALGORITHM};
1479  
1480 1038 my ($queryfactor, $hitfactor) = (0,0);
1481 1038 my ($hitmap, $querymap) = (1,1);
1482 1038 ▶ if( $algo =~ /^(?:PSI)?T(?:BLAST|FAST|SW)[NY]/oi ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($algo =~ /^(?:PSI)?T(?:BLAST|FAST|SW)[NY]/io) { } 6 1032 1038
elsif ($algo =~ /^(?:FAST|BLAST)(?:X|Y|XY)/io or $algo =~ /^P?GENEWISE/io) { } 23 1009 1032
elsif ($algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/io or $algo =~ /^(BLAST|FAST|SW)N/io or $algo =~ /^WABA|AXT|BLAT|BLASTZ|PSL|MEGABLAST|EXONERATE|SW|SSEARCH|SMITH\-WATERMAN|SIM4$/) { } 232 777 1009
elsif ($algo =~ /^RPS-BLAST/) { } 0 777 777
1483 6 $hitfactor = 1;
1484 6 $hitmap = 3;
1485 }
1486 ▶ elsif ($algo =~ /^(?:FAST|BLAST)(?:X|Y|XY)/oi || $algo =~ /^P?GENEWISE/oi ) {
Condition100%3/3
$algo =~ /^(?:FAST|BLAST)(?:X|Y|XY)/io or $algo =~ /^P?GENEWISE/io
l!l&&r!l&&!r
2031009
MC/DC100%2/2
$algo =~ /^(?:FAST|BLAST)(?:X|Y|XY)/io or $algo =~ /^P?GENEWISE/io
$algo =~ /^(?:FAST|BLAST)(?:X|Y|XY)/io $algo =~ /^P?GENEWISE/io
Truth table100%3/3
A or B
A= $algo =~ /^(?:FAST|BLAST)(?:X|Y|XY)/ioB= $algo =~ /^P?GENEWISE/io
ABresult
1X1
011
000
1487 23 $queryfactor = 1;
1488 23 $querymap = 3;
1489 }
1490 ▶ elsif ($algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/oi || $algo =~ /^(BLAST|FAST|SW)N/oi || $algo =~ /^WABA|AXT|BLAT|BLASTZ|PSL|MEGABLAST|EXONERATE|SW|SSEARCH|SMITH\-WATERMAN|SIM4$/){
Condition100%6/6
$algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/io or $algo =~ /^(BLAST|FAST|SW)N/io or $algo =~ /^WABA|AXT|BLAT|BLASTZ|PSL|MEGABLAST|EXONERATE|SW|SSEARCH|SMITH\-WATERMAN|SIM4$/
l!l&&r!l&&!r
17854777
$algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/io or $algo =~ /^(BLAST|FAST|SW)N/io
l!l&&r!l&&!r
11959831
MC/DC100%3/3
$algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/io or $algo =~ /^(BLAST|FAST|SW)N/io or $algo =~ /^WABA|AXT|BLAT|BLASTZ|PSL|MEGABLAST|EXONERATE|SW|SSEARCH|SMITH\-WATERMAN|SIM4$/
$algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/io $algo =~ /^(BLAST|FAST|SW)N/io $algo =~ /^WABA|AXT|BLAT|BLASTZ|PSL|MEGABLAST|EXONERATE|SW|SSEARCH|SMITH\-WATERMAN|SIM4$/
Truth table100%4/4
A or B or C
A= $algo =~ /^T(BLAST|FAST|SW)(X|Y|XY)/ioB= $algo =~ /^(BLAST|FAST|SW)N/ioC= $algo =~ /^WABA|AXT|BLAT|BLASTZ|PSL|MEGABLAST|EXONERATE|SW|SSEARCH|SMITH\-WATERMAN|SIM4$/
ABCresult
1XX1
01X1
0011
0000
1491 232 ▶ if ($2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2) 119 113 232
1492 119 $hitmap = $querymap = 3;
1493 }
1494 232 $hitfactor = 1;
1495 232 $queryfactor = 1;
1496 }
1497 elsif ($algo =~ /^RPS-BLAST/) {
1498 0 ▶ if ($algo =~ /^RPS-BLAST\(BLASTX\)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($algo =~ /^RPS-BLAST\(BLASTX\)/) 0 0 0
1499 0 $queryfactor = 1;
1500 0 $querymap = 3;
1501 }
1502 0 $hitfactor = 0;
1503 }
1504 else {
1505 777 my $stranded = lc substr($self->{STRANDED}, 0,1);
1506 777 ▶ $queryfactor = ($stranded eq 'q' || $stranded eq 'b') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$stranded eq 'q' || $stranded eq 'b' ? : 602 175 777
Condition66%2/3
$stranded eq "q" or $stranded eq "b"
l!l&&r!l&&!r
0602175
MC/DC50%1/2
$stranded eq "q" or $stranded eq "b"
$stranded eq "q" $stranded eq "b"
Truth table66%2/3
A or B
A= $stranded eq "q"B= $stranded eq "b"
ABresult
1X1
011
000
1507 777 ▶ $hitfactor = ($stranded eq 'h' || $stranded eq 's' || $stranded eq 'b') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$stranded eq 'h' || $stranded eq 's' || $stranded eq 'b' ? : 608 169 777
Condition83%5/6
$stranded eq "h" or $stranded eq "s" or $stranded eq "b"
l!l&&r!l&&!r
6602169
$stranded eq "h" or $stranded eq "s"
l!l&&r!l&&!r
60771
MC/DC66%2/3
$stranded eq "h" or $stranded eq "s" or $stranded eq "b"
$stranded eq "h" $stranded eq "s" $stranded eq "b"
Truth table75%3/4
A or B or C
A= $stranded eq "h"B= $stranded eq "s"C= $stranded eq "b"
ABCresult
1XX1
01X1
0011
0000
1508 }
1509 1038 $self->{_query_factor} = $queryfactor;
1510 1038 $self->{_hit_factor} = $hitfactor;
1511 1038 $self->{_hit_mapping} = $hitmap;
1512 1038 $self->{_query_mapping} = $querymap;
1513 }
1514  
1515 # make query seq feature
1516 1037 ▶sub _query_seq_feature {
Subroutine _query_seq_feature: called CC=21 SCAR=32.1
1517 1037 my $self = shift;
1518 1037 $self->{_making_qff} = 1;
1519 1037 my $qs = $self->{QUERY_START};
1520 1037 my $qe = $self->{QUERY_END};
1521 1037 ▶ unless (defined $self->{_query_factor}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_query_factor"}) 1004 33 1037
1522 1004 $self->_pre_seq_feature;
1523 }
1524 1037 my $queryfactor = $self->{_query_factor};
1525  
1526 0 ▶ unless( defined $qe && defined $qs ) { $self->throw("Did not specify a Query End or Query Begin"); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $qe and defined $qs) 0 1037 1037
Condition33%1/3
defined $qe and defined $qs
!ll&&!rl&&r
001037
MC/DC0%0/2
defined $qe and defined $qs
defined $qe defined $qs
Truth table33%1/3
A and B
A= defined $qeB= defined $qs
ABresult
0X0
100
111
1527  
1528 1037 my $strand;
1529 1037 ▶ if ($qe > $qs) { # normal query: start < end
Branch: 1 branch
BranchTrueFalseTotal
if ($qe > $qs) { } 969 68 1037
1530 969 ▶ if ($queryfactor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($queryfactor) { } 789 180 969
1531 789 $strand = 1;
1532 }
1533 else {
1534 180 $strand = undef;
1535 }
1536 }
1537 else {
1538 68 ▶ if ($queryfactor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($queryfactor) { } 68 0 68
1539 68 $strand = -1;
1540 }
1541 else {
1542 0 $strand = undef;
1543 }
1544 68 ($qs,$qe) = ($qe,$qs);
1545 }
1546  
1547 # Note: many of these data are not query- and hit-specific.
1548 # Only start, end, name, length are.
1549 # We could be more efficient by only storing this info once.
1550 # steve chervitz --- Sat Apr 5 00:55:07 2003
1551  
1552 1037 ▶ my $sim1 = $self->{_sim1} || Bio::SeqFeature::Similarity->new();
Condition33%1/3
$self->{'_sim1'} || 'Bio::SeqFeature::Similarity'->new
l!l&&r!l&&!r
103700
MC/DC0%0/2
$self->{'_sim1'} || 'Bio::SeqFeature::Similarity'->new
$self->{'_sim1'} 'Bio::SeqFeature::Similarity'->new
Truth table33%1/3
A || B
A= $self->{'_sim1'}B= 'Bio::SeqFeature::Similarity'->new
ABresult
1X1
011
000
1553 1037 $sim1->start($qs);
1554 1037 $sim1->end($qe);
1555 1037 $sim1->significance($self->{EVALUE});
1556 1037 $sim1->bits($self->{BITS});
1557 1037 $sim1->score($self->{SCORE});
1558 1037 $sim1->strand($strand);
1559 1037 $sim1->seq_id($self->{QUERY_NAME});
1560 1037 $sim1->seqlength($self->{QUERY_LENGTH});
1561 1037 $sim1->source_tag($self->{ALGORITHM});
1562 1037 $sim1->seqdesc($self->{QUERY_DESC});
1563 1037 ▶ $sim1->add_tag_value('meta', $self->{META}) if $self->can('meta');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("meta") 5 1032 1037
1564 # to determine frame from something like FASTXY which doesn't
1565 # report the frame
1566 1037 my $qframe = $self->{QUERY_FRAME};
1567
1568 1037 ▶ if (defined $strand && !defined $qframe && $queryfactor) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $strand and not defined $qframe and $queryfactor) { } 603 434 1037
elsif (not defined $strand) { } 180 254 434
Condition83%5/6
defined $strand and not defined $qframe and $queryfactor
!ll&&!rl&&r
4340603
defined $strand and not defined $qframe
!ll&&!rl&&r
180254603
MC/DC66%2/3
defined $strand and not defined $qframe and $queryfactor
defined $strand not defined $qframe $queryfactor
Truth table75%3/4
A and not(B) and C
A= defined $strandB= not defined $qframeC= $queryfactor
ABCresult
0XX0
10X0
1100
1111
1569 603 $qframe = ( $qs % 3 ) * $strand;
1570 }
1571 elsif (!defined $strand) {
1572 180 $qframe = 0;
1573 }
1574
1575 1037 ▶ if( $qframe =~ /^([+-])?([0-3])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qframe =~ /^([+-])?([0-3])/) { } 1037 0 1037
1576 1037 ▶ my $dir = $1 || '+';
Condition100%2/2
$1 || '+'
l!l
141896
MC/DC100%1/1
$1 || '+'
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
1577 1037 ▶ if($qframe && (($dir eq '-' && $strand >= 0) || ($dir eq '+' && $strand <= 0)) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qframe and $dir eq "-" && $strand >= 0 || $dir eq "+" && $strand <= 0) 0 1037 1037
Condition58%7/12
$qframe and $dir eq "-" && $strand >= 0 || $dir eq "+" && $strand <= 0
!ll&&!rl&&r
4236140
$dir eq "-" and $strand >= 0 or $dir eq "+" and $strand <= 0
l!l&&r!l&&!r
00614
$dir eq "-" and $strand >= 0
!ll&&!rl&&r
554600
$dir eq "+" and $strand <= 0
!ll&&!rl&&r
605540
MC/DC0%0/5
$qframe and $dir eq "-" && $strand >= 0 || $dir eq "+" && $strand <= 0
$qframe $dir eq "-" $strand >= 0 $dir eq "+" $strand <= 0
Truth table37%3/8
A and B and C or D and E
A= $qframeB= $dir eq "-"C= $strand >= 0D= $dir eq "+"E= $strand <= 0
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
1578 0 $self->warn("Query frame ($qframe) did not match strand of query ($strand)");
1579 }
1580 1037 ▶ $qframe = $2 != 0 ? $2 - 1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
$2 != 0 ? : 614 423 1037
1581 } else {
1582 0 $self->warn("Unknown query frame ($qframe)");
1583 0 $qframe = 0;
1584 }
1585
1586 1037 $sim1->frame($qframe);
1587 1037 $self->SUPER::feature1($sim1);
1588  
1589 1037 $self->{_created_qff} = 1;
1590 1037 $self->{_making_qff} = 0;
1591 }
1592  
1593 # make subject seq feature
1594 437 ▶sub _subject_seq_feature {
Subroutine _subject_seq_feature: called CC=21 SCAR=32.1
1595 437 my $self = shift;
1596 437 $self->{_making_sff} = 1;
1597 437 my $hs = $self->{HIT_START};
1598 437 my $he = $self->{HIT_END};
1599 437 ▶ unless (defined $self->{_hit_factor}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_hit_factor"}) 34 403 437
1600 34 $self->_pre_seq_feature;
1601 }
1602 437 my $hitfactor = $self->{_hit_factor};
1603  
1604 0 ▶ unless( defined $he && defined $hs ) { $self->throw("Did not specify a Hit End or Hit Begin"); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $he and defined $hs) 0 437 437
Condition33%1/3
defined $he and defined $hs
!ll&&!rl&&r
00437
MC/DC0%0/2
defined $he and defined $hs
defined $he defined $hs
Truth table33%1/3
A and B
A= defined $heB= defined $hs
ABresult
0X0
100
111
1605  
1606 437 my $strand;
1607 437 ▶ if ($he > $hs) { # normal subject
Branch: 1 branch
BranchTrueFalseTotal
if ($he > $hs) { } 345 92 437
1608 345 ▶ if ($hitfactor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hitfactor) { } 153 192 345
1609 153 $strand = 1;
1610 }
1611 else {
1612 192 $strand = undef;
1613 }
1614 }
1615 else {
1616 92 ▶ if ($hitfactor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hitfactor) { } 92 0 92
1617 92 $strand = -1;
1618 }
1619 else {
1620 0 $strand = undef;
1621 }
1622 92 ($hs,$he) = ( $he,$hs); # reverse subject: start bigger than end
1623 }
1624  
1625 437 ▶ my $sim2 = $self->{_sim2} || Bio::SeqFeature::Similarity->new();
Condition33%1/3
$self->{'_sim2'} || 'Bio::SeqFeature::Similarity'->new
l!l&&r!l&&!r
04370
MC/DC0%0/2
$self->{'_sim2'} || 'Bio::SeqFeature::Similarity'->new
$self->{'_sim2'} 'Bio::SeqFeature::Similarity'->new
Truth table33%1/3
A || B
A= $self->{'_sim2'}B= 'Bio::SeqFeature::Similarity'->new
ABresult
1X1
011
000
1626 437 $sim2->start($hs);
1627 437 $sim2->end($he);
1628 437 $sim2->significance($self->{EVALUE});
1629 437 $sim2->bits($self->{BITS});
1630 437 $sim2->score($self->{SCORE});
1631 437 $sim2->strand($strand);
1632 437 $sim2->seq_id($self->{HIT_NAME});
1633 437 $sim2->seqlength($self->{HIT_LENGTH});
1634 437 $sim2->source_tag($self->{ALGORITHM});
1635 437 $sim2->seqdesc($self->{HIT_DESC});
1636 437 ▶ $sim2->add_tag_value('meta', $self->{META}) if $self->can('meta');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("meta") 6 431 437
1637 437 my $hframe = $self->{HIT_FRAME};
1638
1639 437 ▶ if (defined $strand && !defined $hframe && $hitfactor) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $strand and not defined $hframe and $hitfactor) { } 3 434 437
elsif (not defined $strand) { } 192 242 434
Condition83%5/6
defined $strand and not defined $hframe and $hitfactor
!ll&&!rl&&r
43403
defined $strand and not defined $hframe
!ll&&!rl&&r
1922423
MC/DC66%2/3
defined $strand and not defined $hframe and $hitfactor
defined $strand not defined $hframe $hitfactor
Truth table75%3/4
A and not(B) and C
A= defined $strandB= not defined $hframeC= $hitfactor
ABCresult
0XX0
10X0
1100
1111
1640 3 $hframe = ( $hs % 3 ) * $strand;
1641 }
1642 elsif (!defined $strand) {
1643 192 $hframe = 0;
1644 }
1645
1646 437 ▶ if( $hframe =~ /^([+-])?([0-3])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hframe =~ /^([+-])?([0-3])/) { } 437 0 437
1647 437 ▶ my $dir = $1 || '+';
Condition100%2/2
$1 || '+'
l!l
126311
MC/DC100%1/1
$1 || '+'
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
1648 437 ▶ if($hframe && (($dir eq '-' && $strand >= 0) || ($dir eq '+' && $strand <= 0)) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hframe and $dir eq "-" && $strand >= 0 || $dir eq "+" && $strand <= 0) 0 437 437
Condition58%7/12
$hframe and $dir eq "-" && $strand >= 0 || $dir eq "+" && $strand <= 0
!ll&&!rl&&r
3101270
$dir eq "-" and $strand >= 0 or $dir eq "+" and $strand <= 0
l!l&&r!l&&!r
00127
$dir eq "-" and $strand >= 0
!ll&&!rl&&r
93340
$dir eq "+" and $strand <= 0
!ll&&!rl&&r
34930
MC/DC0%0/5
$hframe and $dir eq "-" && $strand >= 0 || $dir eq "+" && $strand <= 0
$hframe $dir eq "-" $strand >= 0 $dir eq "+" $strand <= 0
Truth table37%3/8
A and B and C or D and E
A= $hframeB= $dir eq "-"C= $strand >= 0D= $dir eq "+"E= $strand <= 0
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
1649 0 $self->warn("Subject frame ($hframe) did not match strand of subject ($strand)");
1650 }
1651 437 ▶ $hframe = $2 != 0 ? $2 - 1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
$2 != 0 ? : 127 310 437
1652 } else {
1653 0 $self->warn("Unknown subject frame ($hframe)");
1654 0 $hframe = 0;
1655 }
1656
1657 437 $sim2->frame($hframe);
1658 437 $self->SUPER::feature2($sim2);
1659  
1660 437 $self->{_created_sff} = 1;
1661 437 $self->{_making_sff} = 0;
1662 }
1663  
1664 # before calling the num_* methods
1665 345 ▶sub _pre_similar_stats {
Subroutine _pre_similar_stats: called CC=5 SCAR=21.5
1666 345 my $self = shift;
1667 345 my $identical = $self->{IDENTICAL};
1668 345 my $conserved = $self->{CONSERVED};
1669 345 my $percent_id = $self->{PERCENT_IDENTITY};
1670  
1671 345 ▶ if (! defined $identical) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $identical) 0 345 345
1672 0 ▶ if (! defined $percent_id) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $percent_id) { } 0 0 0
1673 0 $self->warn("Did not defined the number of identical matches or overall percent identity in the HSP; assuming 0");
1674 0 $identical = 0;
1675 }
1676 else {
1677 0 $identical = sprintf("%.0f",$percent_id * $self->{HSP_LENGTH});
1678 }
1679 }
1680  
1681 345 ▶ if (! defined $conserved) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $conserved) 0 345 345
1682 $self->warn("Did not define the number of conserved matches in the HSP; assuming conserved == identical ($identical)")
1683 0 ▶ if( $self->{ALGORITHM} !~ /^((FAST|BLAST)N)|EXONERATE|SIM4|AXT|PSL|BLAT|BLASTZ|WABA/oi);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ALGORITHM"} =~ /^((FAST|BLAST)N)|EXONERATE|SIM4|AXT|PSL|BLAT|BLASTZ|WABA/io 0 0 0
1684 0 $conserved = $identical;
1685 }
1686 345 $self->{IDENTICAL} = $identical;
1687 345 $self->{CONSERVED} = $conserved;
1688 345 $self->{_did_presimilar} = 1;
1689 }
1690  
1691 # before calling the frac_* methods
1692  
1693 72 ▶sub _pre_frac {
Subroutine _pre_frac: called CC=4 SCAR=13.9
1694 72 my $self = shift;
1695
1696 72 my $hsp_len = $self->{HSP_LENGTH};
1697 72 my $hit_len = $self->{HIT_LENGTH};
1698 72 my $query_len = $self->{QUERY_LENGTH};
1699  
1700 72 my $identical = $self->num_identical;
1701 72 my $conserved = $self->num_conserved;
1702  
1703 72 $self->{_did_prefrac} = 1;
1704 72 my $logical;
1705 72 ▶ if( $hsp_len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hsp_len) 72 0 72
1706 72 $self->length('total', $hsp_len);
1707 72 $logical = $self->_logical_length('total');
1708 72 $self->frac_identical( 'total', $identical / $hsp_len);
1709 72 $self->frac_conserved( 'total', $conserved / $hsp_len);
1710 }
1711 72 ▶ if( $hit_len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hit_len) 71 1 72
1712 71 $logical = $self->_logical_length('hit');
1713 71 $self->frac_identical( 'hit', $identical / $logical);
1714 71 $self->frac_conserved( 'hit', $conserved / $logical);
1715 }
1716 72 ▶ if( $query_len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query_len) 71 1 72
1717 71 $logical = $self->_logical_length('query');
1718 71 $self->frac_identical( 'query', $identical / $logical) ;
1719 71 $self->frac_conserved( 'query', $conserved / $logical);
1720 }
1721 }
1722  
1723 # before calling gaps()
1724 # This relies first on passed parameters (parser-dependent), then on gaps
1725 # calculated by seq_inds() (if set), then falls back to directly checking
1726 # for '-' or '.' as a last resort
1727  
1728 271 ▶sub _pre_gaps {
Subroutine _pre_gaps: called CC=12 SCAR=25.0
1729 271 my $self = shift;
1730 271 my $query_gaps = $self->{QUERY_GAPS};
1731 271 my $query_seq = $self->{QUERY_SEQ};
1732 271 my $hit_gaps = $self->{HIT_GAPS};
1733 271 my $hit_seq = $self->{HIT_SEQ};
1734 271 my $gaps = $self->{HSP_GAPS};
1735  
1736 271 $self->{_did_pregaps} = 1; # well, we're in the process; avoid recursion
1737 271 ▶ if( defined $query_gaps ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $query_gaps) { } 0 271 271
elsif (defined $query_seq) { } 256 15 271
1738 0 $self->gaps('query', $query_gaps);
1739 } elsif( defined $query_seq ) {
1740 256 ▶ my $qg = (defined $self->{'_query_offset'}) ? $self->seq_inds('query','gaps')
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'_query_offset'} ? : 46 210 256
$self->algorithm eq 'ERPIN' ? : 0 210 210
1741 : ($self->algorithm eq 'ERPIN') ? scalar( $hit_seq =~ tr/\-//)
1742 : scalar( $query_seq =~ tr/\-\.// ); # HMMER3 and Infernal uses '.' and '-'
1743 256 ▶ my $offset = $self->{'_query_offset'} || 1;
Condition100%2/2
$self->{'_query_offset'} || 1
l!l
46210
MC/DC100%1/1
$self->{'_query_offset'} || 1
$self->{'_query_offset'}
Truth table100%2/2
A
A= $self->{'_query_offset'}
Aresult
11
00
1744 256 $self->gaps('query', $qg/$offset);
1745 }
1746 271 ▶ if( defined $hit_gaps ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $hit_gaps) { } 0 271 271
elsif (defined $hit_seq) { } 259 12 271
1747 0 $self->gaps('hit', $hit_gaps);
1748 } elsif( defined $hit_seq ) {
1749 259 ▶ my $hg = (defined $self->{'_sbjct_offset'}) ? $self->seq_inds('hit','gaps')
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'_sbjct_offset'} ? : 46 213 259
$self->algorithm eq 'ERPIN' ? : 2 211 213
1750 : ($self->algorithm eq 'ERPIN') ? scalar( $hit_seq =~ tr/\-//)
1751 : scalar( $hit_seq =~ tr/\-\.// ); # HMMER3 and Infernal uses '.' and '-'
1752 259 ▶ my $offset = $self->{'_sbjct_offset'} || 1;
Condition100%2/2
$self->{'_sbjct_offset'} || 1
l!l
46213
MC/DC100%1/1
$self->{'_sbjct_offset'} || 1
$self->{'_sbjct_offset'}
Truth table100%2/2
A
A= $self->{'_sbjct_offset'}
Aresult
11
00
1753 259 $self->gaps('hit', $hg/$offset);
1754 }
1755 271 ▶ if( ! defined $gaps ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $gaps) 244 27 271
1756 244 $gaps = $self->gaps("query") + $self->gaps("hit");
1757 }
1758 271 $self->gaps('total', $gaps);
1759 }
1760  
1761 # before percent_identity
1762 9 ▶sub _pre_pi {
Subroutine _pre_pi: called CC=3 SCAR=12.5
1763 9 my $self = shift;
1764 9 $self->{_did_prepi} = 1;
1765 9 ▶ $self->percent_identity($self->{PERCENT_IDENTITY} || $self->frac_identical('total')*100) if( $self->{HSP_LENGTH} > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"HSP_LENGTH"} > 0 9 0 9
Condition33%1/3
$self->{'PERCENT_IDENTITY'} || $self->frac_identical('total') * 100
l!l&&r!l&&!r
090
MC/DC0%0/2
$self->{'PERCENT_IDENTITY'} || $self->frac_identical('total') * 100
$self->{'PERCENT_IDENTITY'} $self->frac_identical('total') * 100
Truth table33%1/3
A || B
A= $self->{'PERCENT_IDENTITY'}B= $self->frac_identical('total') * 100
ABresult
1X1
011
000
1766 }
1767  
1768 32 1;
« Bio/Matrix/IO/phylip.pm ↑ Summary Bio/SeqIO/table.pm »