File Coverage

blib/lib/Bio/FastParsers/Blast/Xml/Hit.pm
Criterion Covered Total %
statement 16 21 76.1
branch n/a
condition n/a
subroutine 5 10 50.0
pod 5 5 100.0
total 26 36 72.2


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