Bio/Search/HSP/HSPI.pm

filter: Statementstmt 37.9% 49 / 129 Branchbran 36.2% 21 / 58 Conditioncond 27.2% 6 / 22 MC/DCmcdc 16.6% 2 / 12 Subroutinesub 35.7% 10 / 28 Podpod 96.0% 24 / 25 totaltotal 40.8% 112 / 274 CC 39 SCAR 41.0
CC
39
Cov
36%
matches
198.5
seq
42.0
strand
6.5
CRAP 60.3
« Bio/SeqFeature/Tools/Unflattener.pm ↑ Summary Bio/SeqIO/Handler/GenericRichSeqHandler.pm »
1 #-----------------------------------------------------------------
2 #
3 # BioPerl module for Bio::Search::HSP::HSPI
4 #
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 #
7 # Cared for by Steve Chervitz <sac@bioperl.org>
8 # and Jason Stajich <jason@bioperl.org>
9 #
10 # You may distribute this module under the same terms as perl itself
11 #-----------------------------------------------------------------
12  
13 # POD documentation - main docs before the code
14  
15 =head1 NAME
16  
17 Bio::Search::HSP::HSPI - Interface for a High Scoring Pair in a similarity search result
18  
19 =head1 SYNOPSIS
20  
21 # Bio::Search::HSP::HSPI objects cannot be instantiated since this
22 # module defines a pure interface.
23  
24 # Given an object that implements the Bio::Search::HSP::HSPI interface,
25 # you can do the following things with it:
26  
27 $r_type = $hsp->algorithm;
28  
29 $pvalue = $hsp->pvalue();
30  
31 $evalue = $hsp->evalue();
32  
33 $frac_id = $hsp->frac_identical( ['query'|'hit'|'total'] );
34  
35 $frac_cons = $hsp->frac_conserved( ['query'|'hit'|'total'] );
36  
37 $gaps = $hsp->gaps( ['query'|'hit'|'total'] );
38  
39 $qseq = $hsp->query_string;
40  
41 $hseq = $hsp->hit_string;
42  
43 $homology_string = $hsp->homology_string;
44  
45 $len = $hsp->length( ['query'|'hit'|'total'] );
46  
47 $rank = $hsp->rank;
48  
49 =head1 DESCRIPTION
50  
51 Bio::Search::HSP::HSPI objects cannot be instantiated since this
52 module defines a pure interface.
53  
54 Given an object that implements the L<Bio::Search::HSP::HSPI> interface,
55 you can do the following things with it:
56  
57 =head1 SEE ALSO
58  
59 This interface inherits methods from these other modules:
60  
61 L<Bio::SeqFeatureI>,
62 L<Bio::SeqFeature::FeaturePair>
63 L<Bio::SeqFeature::SimilarityPair>
64  
65 Please refer to these modules for documentation of the
66 many additional inherited methods.
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 - Steve Chervitz, Jason Stajich
99  
100 Email sac-at-bioperl.org
101 Email jason-at-bioperl.org
102  
103 =head1 COPYRIGHT
104  
105 Copyright (c) 2001 Steve Chervitz, Jason Stajich. All Rights Reserved.
106  
107 =head1 DISCLAIMER
108  
109 This software is provided "as is" without warranty of any kind.
110  
111 =head1 APPENDIX
112  
113 The rest of the documentation details each of the object methods.
114 Internal methods are usually preceded with a _
115  
116 =cut
117  
118  
119 # Let the code begin...
120  
121  
122 package Bio::Search::HSP::HSPI;
123 41 $Bio::Search::HSP::HSPI::VERSION = '1.7.8';
124  
125 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
126 41 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
127  
128 41 ▶use base qw(Bio::SeqFeature::SimilarityPair Bio::Root::RootI);
Subroutine BEGIN: called CC=1 SCAR=0.0
129  
130  
131 =head2 algorithm
132  
133 Title : algorithm
134 Usage : my $r_type = $hsp->algorithm
135 Function: Obtain the name of the algorithm used to obtain the HSP
136 Returns : string (e.g., BLASTP)
137 Args : none
138  
139 =cut
140  
141 0 ▶sub algorithm{
Subroutine algorithm: not called CC=1 SCAR=6.9
Pod documented
142 0 my ($self,@args) = @_;
143 0 $self->throw_not_implemented;
144 }
145  
146 =head2 pvalue
147  
148 Title : pvalue
149 Usage : my $pvalue = $hsp->pvalue();
150 Function: Returns the P-value for this HSP or undef
151 Returns : float or exponential (2e-10)
152 P-value is not defined with NCBI Blast2 reports.
153 Args : none
154  
155 =cut
156  
157 0 ▶sub pvalue {
Subroutine pvalue: not called CC=1 SCAR=6.9
Pod documented
158 0 my ($self) = @_;
159 0 $self->throw_not_implemented;
160 }
161  
162 =head2 evalue
163  
164 Title : evalue
165 Usage : my $evalue = $hsp->evalue();
166 Function: Returns the e-value for this HSP
167 Returns : float or exponential (2e-10)
168 Args : none
169  
170 =cut
171  
172 0 ▶sub evalue {
Subroutine evalue: not called CC=1 SCAR=6.9
Pod documented
173 0 my ($self) = @_;
174 0 $self->throw_not_implemented;
175 }
176  
177  
178 =head2 frac_identical
179  
180 Title : frac_identical
181 Usage : my $frac_id = $hsp->frac_identical( ['query'|'hit'|'total'] );
182 Function: Returns the fraction of identitical positions for this HSP
183 Returns : Float in range 0.0 -> 1.0
184 Args : 'query' = num identical / length of query seq (without gaps)
185 'hit' = num identical / length of hit seq (without gaps)
186 'total' = num identical / length of alignment (with gaps)
187 default = 'total'
188  
189 =cut
190  
191 0 ▶sub frac_identical {
Subroutine frac_identical: not called CC=1 SCAR=6.9
Pod documented
192 0 my ($self, $type) = @_;
193 0 $self->throw_not_implemented;
194 }
195  
196 =head2 frac_conserved
197  
198 Title : frac_conserved
199 Usage : my $frac_cons = $hsp->frac_conserved( ['query'|'hit'|'total'] );
200 Function : Returns the fraction of conserved positions for this HSP.
201 This is the fraction of symbols in the alignment with a
202 positive score.
203 Returns : Float in range 0.0 -> 1.0
204 Args : 'query' = num conserved / length of query seq (without gaps)
205 'hit' = num conserved / length of hit seq (without gaps)
206 'total' = num conserved / length of alignment (with gaps)
207 default = 'total'
208  
209 =cut
210  
211 0 ▶sub frac_conserved {
Subroutine frac_conserved: not called CC=1 SCAR=6.9
Pod documented
212 0 my ($self, $type) = @_;
213 0 $self->throw_not_implemented;
214 }
215  
216 =head2 num_identical
217  
218 Title : num_identical
219 Usage : $obj->num_identical($newval)
220 Function: returns the number of identical residues in the alignment
221 Returns : integer
222 Args : integer (optional)
223  
224  
225 =cut
226  
227 0 ▶sub num_identical{
Subroutine num_identical: not called CC=1 SCAR=6.9
Pod documented
228 0 shift->throw_not_implemented;
229 }
230  
231 =head2 num_conserved
232  
233 Title : num_conserved
234 Usage : $obj->num_conserved($newval)
235 Function: returns the number of conserved residues in the alignment
236 Returns : inetger
237 Args : integer (optional)
238  
239  
240 =cut
241  
242 0 ▶sub num_conserved{
Subroutine num_conserved: not called CC=1 SCAR=6.9
Pod documented
243 0 shift->throw_not_implemented();
244 }
245  
246 =head2 gaps
247  
248 Title : gaps
249 Usage : my $gaps = $hsp->gaps( ['query'|'hit'|'total'] );
250 Function : Get the number of gap characters in the query, hit, or total alignment.
251 Returns : Integer, number of gap characters or 0 if none
252 Args : 'query' = num conserved / length of query seq (without gaps)
253 'hit' = num conserved / length of hit seq (without gaps)
254 'total' = num conserved / length of alignment (with gaps)
255 default = 'total'
256  
257 =cut
258  
259 0 ▶sub gaps {
Subroutine gaps: not called CC=1 SCAR=6.9
Pod documented
260 0 my ($self, $type) = @_;
261 0 $self->throw_not_implemented;
262 }
263  
264 =head2 query_string
265  
266 Title : query_string
267 Usage : my $qseq = $hsp->query_string;
268 Function: Retrieves the query sequence of this HSP as a string
269 Returns : string
270 Args : none
271  
272  
273 =cut
274  
275 0 ▶sub query_string{
Subroutine query_string: not called CC=1 SCAR=6.9
Pod documented
276 0 my ($self) = @_;
277 0 $self->throw_not_implemented;
278 }
279  
280 =head2 hit_string
281  
282 Title : hit_string
283 Usage : my $hseq = $hsp->hit_string;
284 Function: Retrieves the hit sequence of this HSP as a string
285 Returns : string
286 Args : none
287  
288  
289 =cut
290  
291 0 ▶sub hit_string{
Subroutine hit_string: not called CC=1 SCAR=6.9
Pod documented
292 0 my ($self) = @_;
293 0 $self->throw_not_implemented;
294 }
295  
296 =head2 homology_string
297  
298 Title : homology_string
299 Usage : my $homo_string = $hsp->homology_string;
300 Function: Retrieves the homology sequence for this HSP as a string.
301 : The homology sequence is the string of symbols in between the
302 : query and hit sequences in the alignment indicating the degree
303 : of conservation (e.g., identical, similar, not similar).
304 Returns : string
305 Args : none
306  
307 =cut
308  
309 0 ▶sub homology_string{
Subroutine homology_string: not called CC=1 SCAR=6.9
Pod documented
310 0 my ($self) = @_;
311 0 $self->throw_not_implemented;
312 }
313  
314 =head2 length
315  
316 Title : length
317 Usage : my $len = $hsp->length( ['query'|'hit'|'total'] );
318 Function : Returns the length of the query or hit in the alignment (without gaps)
319 or the aggregate length of the HSP (including gaps;
320 this may be greater than either hit or query )
321 Returns : integer
322 Args : 'query' = length of query seq (without gaps)
323 'hit' = length of hit seq (without gaps)
324 'total' = length of alignment (with gaps)
325 default = 'total'
326 Args : none
327  
328 =cut
329  
330 0 ▶sub length{
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
331 0 shift->throw_not_implemented();
332 }
333  
334 =head2 percent_identity
335  
336 Title : percent_identity
337 Usage : my $percentid = $hsp->percent_identity()
338 Function: Returns the calculated percent identity for an HSP
339 Returns : floating point between 0 and 100
340 Args : none
341  
342  
343 =cut
344  
345 18 ▶sub percent_identity{
Subroutine percent_identity: called CC=1 SCAR=0.0
Pod documented
346 18 my ($self) = @_;
347 18 return $self->frac_identical('hsp') * 100;
348 }
349  
350 =head2 get_aln
351  
352 Title : get_aln
353 Usage : my $aln = $hsp->get_aln
354 Function: Returns a Bio::SimpleAlign representing the HSP alignment
355 Returns : Bio::SimpleAlign
356 Args : none
357  
358 =cut
359  
360 0 ▶sub get_aln {
Subroutine get_aln: not called CC=1 SCAR=6.9
Pod documented
361 0 my ($self) = @_;
362 0 $self->throw_not_implemented;
363 }
364  
365  
366 =head2 seq_inds
367  
368 Title : seq_inds
369 Purpose : Get a list of residue positions (indices) for all identical
370 : or conserved residues in the query or sbjct sequence.
371 Example : @s_ind = $hsp->seq_inds('query', 'identical');
372 : @h_ind = $hsp->seq_inds('hit', 'conserved');
373 : @h_ind = $hsp->seq_inds('hit', 'conserved', 1);
374 Returns : List of integers
375 : May include ranges if collapse is true.
376 Argument : seq_type = 'query' or 'hit' or 'sbjct' (default = query)
377 ('sbjct' is synonymous with 'hit')
378 class = 'identical' or 'conserved' or 'nomatch' or 'gap'
379 (default = identical)
380 (can be shortened to 'id' or 'cons')
381  
382 collapse = boolean, if true, consecutive positions are merged
383 using a range notation, e.g., "1 2 3 4 5 7 9 10 11"
384 collapses to "1-5 7 9-11". This is useful for
385 consolidating long lists. Default = no collapse.
386 Throws : n/a.
387 Comments :
388  
389 See Also : L<Bio::Search::BlastUtils::collapse_nums()|Bio::Search::BlastUtils>, L<Bio::Search::Hit::HitI::seq_inds()|Bio::Search::Hit::HitI>
390  
391 =cut
392  
393 0 ▶sub seq_inds {
Subroutine seq_inds: not called CC=1 SCAR=6.9
Pod documented
394 0 shift->throw_not_implemented();
395 }
396  
397 =head2 Inherited from L<Bio::SeqFeature::SimilarityPair>
398  
399 These methods come from L<Bio::SeqFeature::SimilarityPair>
400  
401 =head2 query
402  
403 Title : query
404 Usage : my $query = $hsp->query
405 Function: Returns a SeqFeature representing the query in the HSP
406 Returns : Bio::SeqFeature::Similarity
407 Args : [optional] new value to set
408  
409  
410 =head2 hit
411  
412 Title : hit
413 Usage : my $hit = $hsp->hit
414 Function: Returns a SeqFeature representing the hit in the HSP
415 Returns : Bio::SeqFeature::Similarity
416 Args : [optional] new value to set
417  
418  
419 =head2 significance
420  
421 Title : significance
422 Usage : $evalue = $obj->significance();
423 $obj->significance($evalue);
424 Function: Get/Set the significance value (see Bio::SeqFeature::SimilarityPair)
425 Returns : significance value (scientific notation string)
426 Args : significance value (sci notation string)
427  
428  
429 =head2 score
430  
431 Title : score
432 Usage : my $score = $hsp->score();
433 Function: Returns the score for this HSP or undef
434 Returns : numeric
435 Args : [optional] numeric to set value
436  
437 =head2 bits
438  
439 Title : bits
440 Usage : my $bits = $hsp->bits();
441 Function: Returns the bit value for this HSP or undef
442 Returns : numeric
443 Args : none
444  
445 =cut
446  
447 # override
448  
449 =head2 strand
450  
451 Title : strand
452 Usage : $hsp->strand('query')
453 Function: Retrieves the strand for the HSP component requested
454 Returns : +1 or -1 (0 if unknown)
455 Args : 'hit' or 'subject' or 'sbjct' to retrieve the strand of the subject
456 'query' to retrieve the query strand (default)
457 'list' or 'array' to retrieve both query and hit together
458  
459 =cut
460  
461 562 ▶sub strand {
Subroutine strand: called CC=5 SCAR=18.7
Pod documented
462 562 my $self = shift;
463 562 my $val = shift;
464 562 ▶ $val = 'query' unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 562 562
465 562 $val =~ s/^\s+//;
466  
467 562 ▶ if ( $val =~ /^q/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($val =~ /^q/i) { } 278 284 562
elsif ($val =~ /^hi|^s/i) { } 284 0 284
elsif ($val =~ /^list|array/i) { } 0 0 0
468 278 return $self->query->strand(@_);
469 }
470 elsif ( $val =~ /^hi|^s/i ) {
471 284 return $self->hit->strand(@_);
472 }
473 elsif ( $val =~ /^list|array/i ) {
474  
475 # Do we really need to pass on additional arguments here? HL
476 # (formerly this was strand(shift) which is really bad coding because
477 # it breaks if the callee allows setting to undef)
478 0 return ( $self->query->strand(@_), $self->hit->strand(@_) );
479 }
480 else {
481 0 $self->warn("unrecognized component '$val' requested\n");
482 }
483 0 return 0;
484 }
485  
486 =head2 start
487  
488 Title : start
489 Usage : $hsp->start('query')
490 Function: Retrieves the start for the HSP component requested
491 Returns : integer
492 Args : 'hit' or 'subject' or 'sbjct' to retrieve the start of the subject
493 'query' to retrieve the query start (default)
494  
495 =cut
496  
497 113 ▶sub start {
Subroutine start: called CC=5 SCAR=17.8
Pod documented
498 113 my $self = shift;
499 113 my $val = shift;
500 113 ▶ $val = 'query' unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 99 14 113
501 113 $val =~ s/^\s+//;
502  
503 113 ▶ if( $val =~ /^q/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($val =~ /^q/i) { } 102 11 113
elsif ($val =~ /^(hi|s)/i) { } 11 0 11
elsif ($val =~ /^list|array/i) { } 0 0 0
504 102 return $self->query->start(@_);
505 } elsif( $val =~ /^(hi|s)/i ) {
506 11 return $self->hit->start(@_);
507 } elsif ( $val =~ /^list|array/i ) {
508 # do we really need to pass on additional arguments here? HL
509 # (formerly this was strand(shift) which is really bad coding because
510 # it breaks if the callee allows setting to undef)
511 0 return ($self->query->start(@_),
512 $self->hit->start(@_) );
513 } else {
514 0 $self->warn("unrecognized component '$val' requested\n");
515 }
516 0 return 0;
517 }
518  
519 =head2 end
520  
521 Title : end
522 Usage : $hsp->end('query')
523 Function: Retrieves the end for the HSP component requested
524 Returns : integer
525 Args : 'hit' or 'subject' or 'sbjct' to retrieve the end of the subject
526 'query' to retrieve the query end (default)
527  
528 =cut
529  
530 112 ▶sub end {
Subroutine end: called CC=5 SCAR=17.8
Pod documented
531 112 my $self = shift;
532 112 my $val = shift;
533 112 ▶ $val = 'query' unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 98 14 112
534 112 $val =~ s/^\s+//;
535  
536 112 ▶ if( $val =~ /^q/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($val =~ /^q/i) { } 102 10 112
elsif ($val =~ /^(hi|s)/i) { } 10 0 10
elsif ($val =~ /^list|array/i) { } 0 0 0
537 102 return $self->query->end(@_);
538 } elsif( $val =~ /^(hi|s)/i ) {
539 10 return $self->hit->end(@_);
540 } elsif ( $val =~ /^list|array/i ) {
541 # do we really need to pass on additional arguments here? HL
542 # (formerly this was strand(shift) which is really bad coding because
543 # it breaks if the callee allows setting to undef)
544 0 return ($self->query->end(@_),
545 $self->hit->end(@_) );
546 } else {
547 0 $self->warn("unrecognized end component '$val' requested\n");
548 }
549 0 return 0;
550 }
551  
552 =head2 seq
553  
554 Usage : $hsp->seq( [seq_type] );
555 Purpose : Get the query or sbjct sequence as a Bio::Seq.pm object.
556 Example : $seqObj = $hsp->seq('query');
557 Returns : Object reference for a Bio::Seq.pm object.
558 Argument : seq_type = 'query' or 'hit' or 'sbjct' (default = 'query').
559 : ('sbjct' is synonymous with 'hit')
560 : default is 'query'
561 Throws : Propagates any exception that occurs during construction
562 : of the Bio::Seq.pm object.
563 Comments : The sequence is returned in an array of strings corresponding
564 : to the strings in the original format of the Blast alignment.
565 : (i.e., same spacing).
566  
567 See Also : L</seq_str>, L</seq_inds>, L<Bio::Seq>
568  
569 =cut
570  
571 0 ▶sub seq {
Subroutine seq: not called CC=6 SCAR=37.4
Pod documented
572 0 my($self,$seqType) = @_;
573 0 ▶ $seqType ||= 'query';
Condition0%0/2
$seqType ||= "query"
l!l
00
MC/DC0%0/1
$seqType ||= "query"
$seqType
Truth table0%0/2
A
A= $seqType
Aresult
11
00
574 0 ▶ $seqType = 'sbjct' if $seqType eq 'hit';
Branch: 1 branch
BranchTrueFalseTotal
if $seqType eq "hit" 0 0 0
575 0 my $str = $self->seq_str($seqType);
576 0 ▶ if( $seqType =~ /^(m|ho)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seqType =~ /^(m|ho)/i) 0 0 0
577 0 $self->throw("cannot call seq on the homology match string, it isn't really a sequence, use get_aln to convert the HSP to a Bio::AlignIO and generate a consensus from that.");
578 }
579 0 require Bio::LocatableSeq;
580 0 ▶ my $id = $seqType =~ /^q/i ? $self->query->seq_id : $self->hit->seq_id;
Branch: 1 branch
BranchTrueFalseTotal
$seqType =~ /^q/i ? : 0 0 0
581 0 ▶ return Bio::LocatableSeq->new( -ID => $id,
Branch: 1 branch
BranchTrueFalseTotal
$id ? : 0 0 0
582 -SEQ => $str,
583 -START => $self->start($seqType),
584 -END => $self->end($seqType),
585 -STRAND => $self->strand($seqType),
586 -FORCE_NSE => $id ? 0 : 1,
587 -DESC => "$seqType sequence " );
588 }
589  
590 =head2 seq_str
591  
592 Usage : $hsp->seq_str( seq_type );
593 Purpose : Get the full query, sbjct, or 'match' sequence as a string.
594 : The 'match' sequence is the string of symbols in between the
595 : query and sbjct sequences.
596 Example : $str = $hsp->seq_str('query');
597 Returns : String
598 Argument : seq_Type = 'query' or 'hit' or 'sbjct' or 'match'
599 : ('sbjct' is synonymous with 'hit')
600 : default is 'query'
601 Throws : Exception if the argument does not match an accepted seq_type.
602 Comments :
603  
604 See Also : L</seq>, L</seq_inds>, C<_set_match_seq>
605  
606 =cut
607  
608 7427 ▶sub seq_str {
Subroutine seq_str: called CC=5 SCAR=16.4
Pod documented
609 7427 my $self = shift;
610 7427 ▶ my $type = shift || 'query';
Condition100%2/2
shift() || 'query'
l!l
74243
MC/DC100%1/1
shift() || 'query'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
611  
612 7427 ▶ if( $type =~ /^q/i ) { return $self->query_string(@_) }
Branch: 3 branches
BranchTrueFalseTotal
if ($type =~ /^q/i) { } 376 7051 7427
elsif ($type =~ /^(s)|(hi)/i) { } 394 6657 7051
elsif ($type =~ /^(ho)|(ma)/i) { } 6657 0 6657
613 394 elsif( $type =~ /^(s)|(hi)/i ) { return $self->hit_string(@_)}
614 6657 elsif ( $type =~ /^(ho)|(ma)/i ) { return $self->homology_string(@_) }
615 else {
616 0 $self->warn("unknown sequence type $type");
617 }
618 0 return '';
619 }
620  
621  
622 =head2 rank
623  
624 Usage : $hsp->rank( [string] );
625 Purpose : Get the rank of the HSP within a given Blast hit.
626 Example : $rank = $hsp->rank;
627 Returns : Integer (1..n) corresponding to the order in which the HSP
628 appears in the BLAST report.
629  
630 =cut
631  
632 0 ▶sub rank { shift->throw_not_implemented }
Subroutine rank: not called CC=1 SCAR=6.9
Pod documented
633  
634 =head2 matches
635  
636 Usage : $hsp->matches(-seq => 'hit'|'query',
637 -start => $start,
638 -stop => $stop);
639 Purpose : Get the total number of identical and conservative matches
640 : in the query or sbjct sequence for the given HSP. Optionally can
641 : report data within a defined interval along the seq.
642 : (Note: 'conservative' matches are called 'positives' in the
643 : Blast report.)
644 Example : ($id,$cons) = $hsp_object->matches(-seq => 'hit');
645 : ($id,$cons) = $hsp_object->matches(-seq => 'query',
646 -start => 300,
647 -stop => 400);
648 Returns : 2-element array of integers
649 Argument : (1) seq_type = 'query' or 'hit' or 'sbjct' (default = query)
650 : ('sbjct' is synonymous with 'hit')
651 : (2) start = Starting coordinate (optional)
652 : (3) stop = Ending coordinate (optional)
653 Throws : Exception if the supplied coordinates are out of range.
654 Comments : Relies on seq_str('match') to get the string of alignment symbols
655 : between the query and sbjct lines which are used for determining
656 : the number of identical and conservative matches.
657  
658 See Also : L</length>, L</gaps>, L</seq_str>, L<Bio::Search::Hit::BlastHit::_adjust_contigs()|Bio::Search::Hit::BlastHit>
659  
660 =cut
661  
662 #-----------
663 24 ▶sub matches {
Subroutine matches: called CC=18 SCAR=52.9
Pod documented
664 #-----------
665 24 my( $self, %param ) = @_;
666 24 my(@data);
667 my($seqType, $beg, $end) = ($param{-SEQ},
668 $param{-START},
669 24 $param{-STOP});
670 24 ▶ $seqType ||= 'query';
Condition100%2/2
$seqType ||= "query"
l!l
420
MC/DC100%1/1
$seqType ||= "query"
$seqType
Truth table100%2/2
A
A= $seqType
Aresult
11
00
671 24 ▶ $seqType = 'sbjct' if $seqType eq 'hit';
Branch: 1 branch
BranchTrueFalseTotal
if $seqType eq "hit" 0 24 24
672  
673 24 ▶ if( (!defined $beg && !defined $end) || ! $self->seq_str('match') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not +(defined $beg || defined $end) && $self->seq_str('match')) { } 24 0 24
Condition33%2/6
(defined $beg || defined $end) && $self->seq_str('match')
!ll&&!rl&&r
2400
defined $beg or defined $end
l!l&&r!l&&!r
0024
MC/DC0%0/3
(defined $beg || defined $end) && $self->seq_str('match')
defined $beg defined $end $self->seq_str('match')
Truth table20%1/5
A or B && C
A= defined $begB= defined $endC= $self->seq_str('match')
ABCresult
00X0
1X00
0100
1X11
0111
674 ## Get data for the whole alignment.
675 24 push @data, ($self->num_identical, $self->num_conserved);
676 } else {
677  
678 ## Get the substring representing the desired sub-section of aln.
679 0 ▶ $beg ||= 0;
Condition0%0/2
$beg ||= 0
l!l
00
MC/DC0%0/1
$beg ||= 0
$beg
Truth table0%0/2
A
A= $beg
Aresult
11
00
680 0 ▶ $end ||= 0;
Condition0%0/2
$end ||= 0
l!l
00
MC/DC0%0/1
$end ||= 0
$end
Truth table0%0/2
A
A= $end
Aresult
11
00
681 0 my($start,$stop) = $self->range($seqType);
682 0 ▶ if($beg == 0) { $beg = $start; $end = $beg+$end; } # sane?
Branch: 2 branches
BranchTrueFalseTotal
if ($beg == 0) { } 0 0 0
elsif ($end == 0) { } 0 0 0
683 0 elsif($end == 0) { $end = $stop; $beg = $end-$beg; } # sane?
684
685 0 ▶ if($end > $stop) { $end = $stop; }
Branch: 1 branch
BranchTrueFalseTotal
if ($end > $stop) 0 0 0
686 0 ▶ if($beg < $start) { $beg = $start; }
Branch: 1 branch
BranchTrueFalseTotal
if ($beg < $start) 0 0 0
687  
688 # now with gap handling! /maj
689 0 my $match_str = $self->seq_str('match');
690 0 ▶ if ($self->gaps) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->gaps) 0 0 0
691 # strip the homology string of gap positions relative
692 # to the target type
693 0 $match_str = $self->seq_str('match');
694 0 my $tgt = $self->seq_str($seqType);
695 0 my $encode = $match_str ^ $tgt;
696 0 my $zap = '-'^' ';
697 0 $encode =~ s/$zap//g;
698 0 $tgt =~ s/-//g;
699 0 $match_str = $tgt ^ $encode;
700 }
701
702 ## ML: START fix for substr out of range error ------------------
703 0 my $seq = "";
704 0 ▶ if (($self->algorithm =~ /TBLAST[NX]/) && ($seqType eq 'sbjct'))
Branch: 2 branches
BranchTrueFalseTotal
if ($self->algorithm =~ /TBLAST[NX]/ and $seqType eq 'sbjct') { } 0 0 0
elsif ($self->algorithm =~ /T?BLASTX/ and $seqType eq 'query') { } 0 0 0
Condition0%0/3
$self->algorithm =~ /TBLAST[NX]/ and $seqType eq "sbjct"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->algorithm =~ /TBLAST[NX]/ and $seqType eq "sbjct"
$self->algorithm =~ /TBLAST[NX]/ $seqType eq "sbjct"
Truth table0%0/3
A and B
A= $self->algorithm =~ /TBLAST[NX]/B= $seqType eq "sbjct"
ABresult
0X0
100
111
705 {
706 0 $seq = substr($match_str,
707 int(($beg-$start)/3),
708 int(($end-$beg+1)/3));
709  
710 ▶ } elsif (($self->algorithm =~ /T?BLASTX/) && ($seqType eq 'query')) {
Condition0%0/3
$self->algorithm =~ /T?BLASTX/ and $seqType eq "query"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->algorithm =~ /T?BLASTX/ and $seqType eq "query"
$self->algorithm =~ /T?BLASTX/ $seqType eq "query"
Truth table0%0/3
A and B
A= $self->algorithm =~ /T?BLASTX/B= $seqType eq "query"
ABresult
0X0
100
111
711 0 $seq = substr($match_str,
712 int(($beg-$start)/3), int(($end-$beg+1)/3));
713 } else {
714 0 $seq = substr($match_str,
715 $beg-$start, ($end-$beg+1));
716 }
717 ## ML: End of fix for substr out of range error -----------------
718
719 0 ▶ if(!CORE::length $seq) {
Branch: 1 branch
BranchTrueFalseTotal
unless (CORE::length $seq) 0 0 0
720 0 $self->throw("Undefined sub-sequence ($beg,$end). Valid range = $start - $stop");
721 }
722
723 0 $seq =~ s/ //g; # remove space (no info).
724 0 my $len_cons = CORE::length $seq;
725 0 $seq =~ s/\+//g; # remove '+' characters (conservative substitutions)
726 0 my $len_id = CORE::length $seq;
727 0 push @data, ($len_id, $len_cons);
728 }
729 24 @data;
730 }
731  
732 =head2 n
733  
734 Usage : $hsp_obj->n()
735 Purpose : Get the N value (num HSPs on which P/Expect is based).
736 : This value is not defined with NCBI Blast2 with gapping.
737 Returns : Integer or null string if not defined.
738 Argument : n/a
739 Throws : n/a
740 Comments : The 'N' value is listed in parenthesis with P/Expect value:
741 : e.g., P(3) = 1.2e-30 ---> (N = 3).
742 : Not defined in NCBI Blast2 with gaps.
743 : This typically is equal to the number of HSPs but not always.
744 : To obtain the number of HSPs, use Bio::Search::Hit::HitI::num_hsps().
745  
746 See Also : L<Bio::SeqFeature::SimilarityPair::score()|Bio::SeqFeature::SimilarityPair>
747  
748 =cut
749  
750 0 ▶sub n { shift->throw_not_implemented }
Subroutine n: not called CC=1 SCAR=6.9
Pod documented
751  
752 =head2 range
753  
754 Usage : $hsp->range( [seq_type] );
755 Purpose : Gets the (start, end) coordinates for the query or sbjct sequence
756 : in the HSP alignment.
757 Example : ($query_beg, $query_end) = $hsp->range('query');
758 : ($hit_beg, $hit_end) = $hsp->range('hit');
759 Returns : Two-element array of integers
760 Argument : seq_type = string, 'query' or 'hit' or 'sbjct' (default = 'query')
761 : ('sbjct' is synonymous with 'hit')
762 Throws : n/a
763 Comments : This is a convenience method for constructions such as
764 ($hsp->query->start, $hsp->query->end)
765  
766 =cut
767  
768 0 ▶sub range { shift->throw_not_implemented }
Subroutine range: not called CC=1 SCAR=6.9
Pod documented
769  
770 24 ▶sub expect { shift->evalue(@_) }
Subroutine expect: called CC=1 SCAR=0.0
Pod undocumented
771  
772 41 1;
773  
« Bio/SeqFeature/Tools/Unflattener.pm ↑ Summary Bio/SeqIO/Handler/GenericRichSeqHandler.pm »