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