File Coverage

blib/lib/Bio/FastParsers/Blast/Xml/Hsp.pm
Criterion Covered Total %
statement 48 59 81.3
branch 8 12 66.6
condition n/a
subroutine 30 41 73.1
pod 37 37 100.0
total 123 149 82.5


line stmt bran cond sub pod time code
1             # ABSTRACT: NCBI BLAST DTD-derived internal class
2             $Bio::FastParsers::Blast::Xml::Hsp::VERSION = '0.221230';
3             use Moose;
4 7     7   4214 use namespace::autoclean;
  7         13  
  7         39  
5 7     7   41710  
  7         49  
  7         55  
6             # AUTOGENERATED CODE! DO NOT MODIFY THIS FILE!
7              
8             use XML::Bare qw(forcearray);
9 7     7   549  
  7         16  
  7         4899  
10              
11              
12             # private attributes
13              
14             has '_root' => (
15             is => 'ro',
16             isa => 'HashRef',
17             required => 1,
18             );
19              
20             has '_parent' => (
21             is => 'ro',
22             isa => 'Maybe[Object]',
23             required => 1,
24             weak_ref => 1,
25             );
26              
27              
28             # public array(s) of composed objects
29              
30              
31             # public composed object(s)
32              
33              
34             # public methods
35              
36              
37             return shift->_root->{'Hsp_align-len'}->{'value'}
38             }
39 2     2 1 46  
40              
41             return shift->_root->{'Hsp_bit-score'}->{'value'}
42             }
43              
44 0     0 1 0  
45             return shift->_root->{'Hsp_density'}->{'value'}
46             }
47              
48              
49 0     0 1 0 return shift->_root->{'Hsp_evalue'}->{'value'}
50             }
51              
52              
53             return shift->_root->{'Hsp_gaps'}->{'value'}
54 0     0 1 0 }
55              
56              
57             return shift->_root->{'Hsp_hit-frame'}->{'value'}
58             }
59 0     0 1 0  
60              
61             return shift->_root->{'Hsp_hit-from'}->{'value'}
62             }
63              
64 2     2 1 49  
65             return shift->_root->{'Hsp_hit-to'}->{'value'}
66             }
67              
68              
69 2424     2424 1 57746 return shift->_root->{'Hsp_hseq'}->{'value'}
70             }
71              
72              
73             return shift->_root->{'Hsp_identity'}->{'value'}
74 1861     1861 1 44000 }
75              
76              
77             return shift->_root->{'Hsp_midline'}->{'value'}
78             }
79 0     0 1 0  
80              
81             return shift->_root->{'Hsp_num'}->{'value'}
82             }
83              
84 56     56 1 1424  
85             return shift->_root->{'Hsp_pattern-from'}->{'value'}
86             }
87              
88              
89 40     40 1 941 return shift->_root->{'Hsp_pattern-to'}->{'value'}
90             }
91              
92              
93             return shift->_root->{'Hsp_positive'}->{'value'}
94 203     203 1 4947 }
95              
96              
97             return shift->_root->{'Hsp_qseq'}->{'value'}
98             }
99 0     0 1 0  
100              
101             return shift->_root->{'Hsp_query-frame'}->{'value'}
102             }
103              
104 0     0 1 0  
105             return shift->_root->{'Hsp_query-from'}->{'value'}
106             }
107              
108              
109 564     564 1 14504 return shift->_root->{'Hsp_query-to'}->{'value'}
110             }
111              
112              
113             return shift->_root->{'Hsp_score'}->{'value'}
114 0     0 1 0 }
115              
116              
117             # public aliases
118              
119 2     2 1 57  
120             return shift->evalue
121             }
122              
123              
124 1861     1861 1 43545 return shift->query_coverage
125             }
126              
127              
128             return shift->subject_coverage
129 1861     1861 1 44033 }
130              
131              
132             return shift->percentage_identity
133             }
134 258     258 1 6014  
135              
136             return shift->percentage_positive
137             }
138              
139              
140              
141             return shift->_parent->query_len
142             }
143 0     0 1 0  
144              
145              
146             return shift->_parent->len
147             }
148 1     1 1 5  
149              
150             # pseudo-aliases
151              
152             use Const::Fast;
153 0     0 1 0 const my $NEGFRAME => qr{\A -}xms;
154              
155              
156             my $self = shift;
157             return $self->hit_frame =~ $NEGFRAME ? -1 : 1;
158 1     1 1 4 }
159              
160              
161             my $self = shift;
162             return $self->hit_from < $self->hit_to ? $self->hit_from
163 0     0 1 0 : $self->hit_to;
164             }
165              
166              
167             my $self = shift;
168             return $self->hit_to > $self->hit_from ? $self->hit_to
169 2     2 1 52 : $self->hit_from;
170             }
171              
172              
173             my $self = shift;
174             return $self->query_frame =~ $NEGFRAME ? -1 : 1;
175 2     2 1 50 }
176              
177              
178             my $self = shift;
179             return $self->query_from < $self->query_to ? $self->query_from
180 7     7   54 : $self->query_to;
  7         12  
  7         78  
181             }
182              
183              
184             my $self = shift;
185 1     1 1 4 return $self->query_to > $self->query_from ? $self->query_to
186 1 50       4 : $self->query_from;
187             }
188              
189              
190             my $self = shift;
191 620     620 1 1805 return sprintf("%.1f",
192 620 100       963 100 * ( $self->query_end - $self->query_start + 1 ) / $self->query_len
193             );
194             }
195              
196              
197             my $self = shift;
198 620     620 1 835 return sprintf("%.1f",
199 620 100       851 100 * ( $self->hit_end - $self->hit_start + 1 ) / $self->hit_len
200             );
201             }
202              
203              
204             my $self = shift;
205 1     1 1 7 return sprintf("%.1f", 100 * ( $self->identity / $self->align_len ) );
206 1 50       5 }
207              
208              
209             my $self = shift;
210             return sprintf("%.1f", 100 * ( $self->positive / $self->align_len ) );
211 620     620 1 1724 }
212 620 50       909  
213              
214             __PACKAGE__->meta->make_immutable;
215             1;
216              
217              
218 620     620 1 859 =pod
219 620 50       948  
220             =head1 NAME
221              
222             Bio::FastParsers::Blast::Xml::Hsp - NCBI BLAST DTD-derived internal class
223              
224             =head1 VERSION
225 1     1 1 3  
226 1         4 version 0.221230
227              
228             =head1 SYNOPSIS
229              
230             # see Bio::FastParsers::Blast::Xml
231              
232             =head1 DESCRIPTION
233 1     1 1 3  
234 1         4 This class implements the C<Hsp> level of the XML BLAST parser.
235              
236             =head1 METHODS
237              
238             =head2 align_len
239              
240             Returns the value of the element C<<Hsp_align-len>>.
241 1     1 1 2  
242 1         5 # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
243             my $align_len = $hsp->align_len;
244              
245             This method does not accept any arguments.
246              
247 1     1 1 3 =head2 bit_score
248 1         3  
249             Returns the value of the element C<<Hsp_bit-score>>.
250              
251             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
252             my $bit_score = $hsp->bit_score;
253              
254             This method does not accept any arguments.
255              
256             =head2 density
257              
258             Returns the value of the element C<<Hsp_density>>.
259              
260             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
261             my $density = $hsp->density;
262              
263             This method does not accept any arguments.
264              
265             =head2 evalue
266              
267             Returns the value of the element C<<Hsp_evalue>>.
268              
269             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
270             my $evalue = $hsp->evalue;
271              
272             This method does not accept any arguments.
273              
274             =head2 gaps
275              
276             Returns the value of the element C<<Hsp_gaps>>.
277              
278             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
279             my $gaps = $hsp->gaps;
280              
281             This method does not accept any arguments.
282              
283             =head2 hit_frame
284              
285             Returns the value of the element C<<Hsp_hit-frame>>.
286              
287             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
288             my $hit_frame = $hsp->hit_frame;
289              
290             This method does not accept any arguments.
291              
292             =head2 hit_from
293              
294             Returns the value of the element C<<Hsp_hit-from>>.
295              
296             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
297             my $hit_from = $hsp->hit_from;
298              
299             This method does not accept any arguments.
300              
301             =head2 hit_to
302              
303             Returns the value of the element C<<Hsp_hit-to>>.
304              
305             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
306             my $hit_to = $hsp->hit_to;
307              
308             This method does not accept any arguments.
309              
310             =head2 hseq
311              
312             Returns the value of the element C<<Hsp_hseq>>.
313              
314             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
315             my $hseq = $hsp->hseq;
316              
317             This method does not accept any arguments.
318              
319             =head2 identity
320              
321             Returns the value of the element C<<Hsp_identity>>.
322              
323             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
324             my $identity = $hsp->identity;
325              
326             This method does not accept any arguments.
327              
328             =head2 midline
329              
330             Returns the value of the element C<<Hsp_midline>>.
331              
332             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
333             my $midline = $hsp->midline;
334              
335             This method does not accept any arguments.
336              
337             =head2 num
338              
339             Returns the value of the element C<<Hsp_num>>.
340              
341             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
342             my $num = $hsp->num;
343              
344             This method does not accept any arguments.
345              
346             =head2 pattern_from
347              
348             Returns the value of the element C<<Hsp_pattern-from>>.
349              
350             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
351             my $pattern_from = $hsp->pattern_from;
352              
353             This method does not accept any arguments.
354              
355             =head2 pattern_to
356              
357             Returns the value of the element C<<Hsp_pattern-to>>.
358              
359             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
360             my $pattern_to = $hsp->pattern_to;
361              
362             This method does not accept any arguments.
363              
364             =head2 positive
365              
366             Returns the value of the element C<<Hsp_positive>>.
367              
368             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
369             my $positive = $hsp->positive;
370              
371             This method does not accept any arguments.
372              
373             =head2 qseq
374              
375             Returns the value of the element C<<Hsp_qseq>>.
376              
377             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
378             my $qseq = $hsp->qseq;
379              
380             This method does not accept any arguments.
381              
382             =head2 query_frame
383              
384             Returns the value of the element C<<Hsp_query-frame>>.
385              
386             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
387             my $query_frame = $hsp->query_frame;
388              
389             This method does not accept any arguments.
390              
391             =head2 query_from
392              
393             Returns the value of the element C<<Hsp_query-from>>.
394              
395             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
396             my $query_from = $hsp->query_from;
397              
398             This method does not accept any arguments.
399              
400             =head2 query_to
401              
402             Returns the value of the element C<<Hsp_query-to>>.
403              
404             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
405             my $query_to = $hsp->query_to;
406              
407             This method does not accept any arguments.
408              
409             =head2 score
410              
411             Returns the value of the element C<<Hsp_score>>.
412              
413             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
414             my $score = $hsp->score;
415              
416             This method does not accept any arguments.
417              
418             =head2 hit_strand
419              
420             Returns the strand of the hit. The strand can be either 1 or -1 depending on
421             the sign of the element C<<Hsp_hit-frame>>.
422              
423             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
424             my $hit_strand = $hsp->hit_strand;
425              
426             This method does not accept any arguments.
427              
428             =head2 hit_start
429              
430             Returns the start coordinate of the hit. This value is taken either from the
431             element C<<Hsp_hit-from>> or from the element C<<Hsp_hit-to>> depending on
432             the hit orientation. The numerical value returned by this method is
433             guaranteed to be lower than the value returned by C<hit_end>.
434              
435             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
436             my ($hit_start, $hit_end) = ($hsp->hit_start, $hsp->hit_end);
437             if ($hit_start < $hit_end) { # always true
438             ...
439             }
440              
441             This method does not accept any arguments.
442              
443             =head2 hit_end
444              
445             Returns the end coordinate of the hit. This value is taken either from the
446             element C<<Hsp_hit-to>> or from the element C<<Hsp_hit-from>> depending on
447             the hit orientation. The numerical value returned by this method is
448             guaranteed to be greater than the value returned by C<hit_start>.
449              
450             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
451             my ($hit_start, $hit_end) = ($hsp->hit_start, $hsp->hit_end);
452             if ($hit_start < $hit_end) { # always true
453             ...
454             }
455              
456             This method does not accept any arguments.
457              
458             =head2 query_strand
459              
460             Returns the strand of the query. The strand can be either 1 or -1 depending
461             on the sign of the element C<<Hsp_query-frame>>.
462              
463             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
464             my $query_strand = $hsp->query_strand;
465              
466             This method does not accept any arguments.
467              
468             =head2 query_start
469              
470             Returns the start coordinate of the query. This value is taken either from
471             the element C<<Hsp_query-from>> or from the element C<<Hsp_query-to>>
472             depending on the query orientation. The numerical value returned by this
473             method is guaranteed to be lower than the value returned by C<query_end>.
474              
475             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
476             my ($query_start, $query_end) = ($hsp->query_start, $hsp->query_end);
477             if ($query_start < $query_end) { # always true
478             ...
479             }
480              
481             This method does not accept any arguments.
482              
483             =head2 query_end
484              
485             Returns the end coordinate of the query. This value is taken either from the
486             element C<<Hsp_query-to>> or from the element C<<Hsp_query-from>> depending
487             on the query orientation. The numerical value returned by this method is
488             guaranteed to be greater than the value returned by C<query_start>.
489              
490             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
491             my ($query_start, $query_end) = ($hsp->query_start, $hsp->query_end);
492             if ($query_start < $query_end) { # always true
493             ...
494             }
495              
496             This method does not accept any arguments.
497              
498             =head2 query_coverage
499              
500             Returns the query coverage of the HSP.
501              
502             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
503             my $query_coverage = $hsp->query_coverage;
504              
505             This method does not accept any arguments.
506              
507             =head2 subject_coverage
508              
509             Returns the subject (hit) coverage of the HSP.
510              
511             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
512             my $subject_coverage = $hsp->subject_coverage;
513              
514             This method does not accept any arguments.
515              
516             =head2 percentage_identity
517              
518             Returns the percentage of identity of the HSP.
519              
520             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
521             my $percentage_identity = $hsp->percentage_identity;
522              
523             This method does not accept any arguments.
524              
525             =head2 percentage_positive
526              
527             Returns the percentage of positive matches of the HSP.
528              
529             # $hsp is a Bio::FastParsers::Blast::Xml::Hsp
530             my $percentage_positive = $hsp->percentage_positive;
531              
532             This method does not accept any arguments.
533              
534             =head1 ALIASES
535              
536             =head2 expect
537              
538             Alias for C<evalue> method. For API consistency.
539              
540             =head2 qcov
541              
542             Alias for C<query_coverage> method. For API consistency.
543              
544             =head2 scov
545              
546             Alias for C<subject_coverage> method. For API consistency.
547              
548             =head2 pident
549              
550             Alias for C<percentage_identity> method. For API consistency.
551              
552             =head2 ppos
553              
554             Alias for C<percentage_positive> method. For API consistency.
555              
556             =head2 query_len
557              
558             Alias for C<query_len> method in Hit object. For API completeness.
559              
560             =head2 hit_len
561              
562             Alias for C<len> method in Hit object. For API completeness.
563              
564             =head1 AUTHOR
565              
566             Denis BAURAIN <denis.baurain@uliege.be>
567              
568             =head1 COPYRIGHT AND LICENSE
569              
570             This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN.
571              
572             This is free software; you can redistribute it and/or modify it under
573             the same terms as the Perl 5 programming language system itself.
574              
575             =cut