File Coverage

blib/lib/Bio/FastParsers/Blast/Xml/Hit.pm
Criterion Covered Total %
statement 18 22 81.8
branch n/a
condition n/a
subroutine 7 11 63.6
pod 6 6 100.0
total 31 39 79.4


line stmt bran cond sub pod time code
1             # ABSTRACT: NCBI BLAST DTD-derived internal class
2             $Bio::FastParsers::Blast::Xml::Hit::VERSION = '0.221230';
3             use Moose;
4 7     7   4183 use namespace::autoclean;
  7         14  
  7         41  
5 7     7   41685  
  7         14  
  7         59  
6             # AUTOGENERATED CODE! DO NOT MODIFY THIS FILE!
7              
8             use XML::Bare qw(forcearray);
9 7     7   543  
  7         14  
  7         451  
10             use aliased 'Bio::FastParsers::Blast::Xml::Hsp';
11 7     7   43  
  7         12  
  7         75  
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             weak_ref => 1,
26             );
27              
28              
29             # public array(s) of composed objects
30              
31              
32             has 'hsps' => (
33             traits => ['Array'],
34             is => 'ro',
35             isa => 'ArrayRef[Bio::FastParsers::Blast::Xml::Hsp]',
36             init_arg => undef,
37             lazy => 1,
38             builder => '_build_hsps',
39             handles => {
40             count_hsps => 'count',
41             all_hsps => 'elements',
42             get_hsp => 'get',
43             next_hsp => 'shift',
44             },
45             );
46              
47             ## no critic (ProhibitUnusedPrivateSubroutines)
48              
49             my $self = shift;
50             return [ map { Hsp->new( _root => $_, _parent => $self ) } @{
51 43     43   55 forcearray $self->_root->{'Hit_hsps'}->{'Hsp'}
52 651         16735 } ];
53 43         52 }
  43         1072  
54              
55             ## use critic
56              
57              
58              
59             # public composed object(s)
60              
61              
62             # public methods
63              
64              
65             return shift->_root->{'Hit_accession'}->{'value'}
66             }
67              
68 0     0 1 0  
69             return shift->_root->{'Hit_def'}->{'value'}
70             }
71              
72              
73 0     0 1 0 return shift->_root->{'Hit_id'}->{'value'}
74             }
75              
76              
77             return shift->_root->{'Hit_len'}->{'value'}
78 0     0 1 0 }
79              
80              
81             return shift->_root->{'Hit_num'}->{'value'}
82             }
83 2     2 1 49  
84              
85             # public aliases
86              
87              
88 0     0 1 0  
89             return shift->_parent->query_len
90             }
91              
92              
93             __PACKAGE__->meta->make_immutable;
94             1;
95              
96              
97             =pod
98 2     2 1 52  
99             =head1 NAME
100              
101             Bio::FastParsers::Blast::Xml::Hit - NCBI BLAST DTD-derived internal class
102              
103             =head1 VERSION
104              
105             version 0.221230
106              
107             =head1 SYNOPSIS
108              
109             # see Bio::FastParsers::Blast::Xml
110              
111             =head1 DESCRIPTION
112              
113             This class implements the C<Hit> level of the XML BLAST parser.
114              
115             =head1 ATTRIBUTES
116              
117             =head2 hsps
118              
119             ArrayRef of L<Bio::FastParsers::Blast::Xml::Hsp>
120              
121             =head1 METHODS
122              
123             =head2 count_hsps
124              
125             Returns the number of Hsps of the Hit.
126              
127             # $hit is a Bio::FastParsers::Blast::Xml::Hit
128             my $count = $hit->count_hsps;
129              
130             This method does not accept any arguments.
131              
132             =head2 all_hsps
133              
134             Returns all the Hsps of the Hit (not an array reference).
135              
136             # $hit is a Bio::FastParsers::Blast::Xml::Hit
137             my @hsps = $hit->all_hsps;
138              
139             This method does not accept any arguments.
140              
141             =head2 get_hsp
142              
143             Returns one Hsp of the Hit by its index. You can also use
144             negative index numbers, just as with Perl's core array handling. If the
145             specified Hsp does not exist, this method will return C<undef>.
146              
147             # $hit is a Bio::FastParsers::Blast::Xml::Hit
148             my $hsp = $hit->get_hsp($index);
149             croak "Hsp $index not found!" unless defined $hsp;
150              
151             This method accepts just one argument (and not an array slice).
152              
153             =head2 next_hsp
154              
155             Shifts the first Hsp of the array off and returns it, shortening the
156             array by 1 and moving everything down. If there are no more Hsps in
157             the array, returns C<undef>.
158              
159             # $hit is a Bio::FastParsers::Blast::Xml::Hit
160             while (my $hsp = $hit->next_hsp) {
161             # process $hsp
162             # ...
163             }
164              
165             This method does not accept any arguments.
166              
167             =head2 accession
168              
169             Returns the value of the element C<<Hit_accession>>.
170              
171             # $hit is a Bio::FastParsers::Blast::Xml::Hit
172             my $accession = $hit->accession;
173              
174             This method does not accept any arguments.
175              
176             =head2 def
177              
178             Returns the value of the element C<<Hit_def>>.
179              
180             # $hit is a Bio::FastParsers::Blast::Xml::Hit
181             my $def = $hit->def;
182              
183             This method does not accept any arguments.
184              
185             =head2 id
186              
187             Returns the value of the element C<<Hit_id>>.
188              
189             # $hit is a Bio::FastParsers::Blast::Xml::Hit
190             my $id = $hit->id;
191              
192             This method does not accept any arguments.
193              
194             =head2 len
195              
196             Returns the value of the element C<<Hit_len>>.
197              
198             # $hit is a Bio::FastParsers::Blast::Xml::Hit
199             my $len = $hit->len;
200              
201             This method does not accept any arguments.
202              
203             =head2 num
204              
205             Returns the value of the element C<<Hit_num>>.
206              
207             # $hit is a Bio::FastParsers::Blast::Xml::Hit
208             my $num = $hit->num;
209              
210             This method does not accept any arguments.
211              
212             =head1 ALIASES
213              
214             =head2 query_len
215              
216             Alias for C<query_len> method in Iteration object. For API completeness.
217              
218             =head1 AUTHOR
219              
220             Denis BAURAIN <denis.baurain@uliege.be>
221              
222             =head1 COPYRIGHT AND LICENSE
223              
224             This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN.
225              
226             This is free software; you can redistribute it and/or modify it under
227             the same terms as the Perl 5 programming language system itself.
228              
229             =cut