File Coverage

blib/lib/Bio/FastParsers/Blast/Xml/Iteration.pm
Criterion Covered Total %
statement 20 28 71.4
branch n/a
condition n/a
subroutine 7 14 50.0
pod 7 7 100.0
total 34 49 69.3


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