Bio/Search/Result/GenericResult.pm

filter: Statementstmt 88.7% 166 / 187 Branchbran 81.0% 81 / 100 Conditioncond 69.7% 30 / 43 MC/DCmcdc 50.0% 14 / 28 Subroutinesub 82.3% 28 / 34 Podpod 100% 29 / 29 totaltotal 82.6% 348 / 421 CC 68 SCAR 21.5
CC
68
Cov
84%
new
24.5
query_gi
12.0
hits
5.2
CRAP 8.6
« Bio/SeqFeature/SimilarityPair.pm ↑ Summary Bio/LocatableSeq.pm »
1 #
2 # BioPerl module for Bio::Search::Result::GenericResult
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason@bioperl.org>
7 #
8 # Copyright Jason Stajich
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Search::Result::GenericResult - Generic Implementation of
17 Bio::Search::Result::ResultI interface applicable to most search
18 results.
19  
20 =head1 SYNOPSIS
21  
22  
23 # typically one gets Results from a SearchIO stream
24 use Bio::SearchIO;
25 my $io = Bio::SearchIO->new(-format => 'blast',
26 -file => 't/data/HUMBETGLOA.tblastx');
27 while( my $result = $io->next_result ) {
28 # process all search results within the input stream
29 while( my $hit = $result->next_hit ) {
30 # insert code here for hit processing
31 }
32 }
33  
34 use Bio::Search::Result::GenericResult;
35 my @hits = (); # would be a list of Bio::Search::Hit::HitI objects
36 # typically these are created from a Bio::SearchIO stream
37 my $result = Bio::Search::Result::GenericResult->new
38 ( -query_name => 'HUMBETGLOA',
39 -query_accession => ''
40 -query_description => 'Human haplotype C4 beta-globin gene, complete cds.'
41 -query_length => 3002
42 -database_name => 'ecoli.aa'
43 -database_letters => 4662239,
44 -database_entries => 400,
45 -parameters => { 'e' => '0.001' },
46 -statistics => { 'kappa' => 0.731 },
47 -algorithm => 'blastp',
48 -algorithm_version => '2.1.2',
49 );
50  
51 my $id = $result->query_name();
52  
53 my $desc = $result->query_description();
54  
55 my $name = $result->database_name();
56  
57 my $size = $result->database_letters();
58  
59 my $num_entries = $result->database_entries();
60  
61 my $gap_ext = $result->get_parameter('e');
62  
63 my @params = $result->available_parameters;
64  
65 my $kappa = $result->get_statistic('kappa');
66  
67 my @statnames = $result->available_statistics;
68  
69 # TODO: Show how to configure a SearchIO stream so that it generates
70 # GenericResult objects.
71  
72  
73 =head1 DESCRIPTION
74  
75 This object is an implementation of the Bio::Search::Result::ResultI
76 interface and provides a generic place to store results from a
77 sequence database search.
78  
79 Unless you're writing a parser, you won't ever need to create a
80 GenericResult or any other ResultI-implementing object. If you use
81 the SearchIO system, ResultI objects are created automatically from
82 a SearchIO stream which returns Bio::Search::Result::ResultI objects.
83  
84 For documentation on what you can do with GenericResult (and other ResultI
85 objects), please see the API documentation in
86 L<Bio::Search::Result::ResultI|Bio::Search::Result::ResultI>.
87  
88 =head1 FEEDBACK
89  
90 =head2 Mailing Lists
91  
92 User feedback is an integral part of the evolution of this and other
93 Bioperl modules. Send your comments and suggestions preferably to
94 the Bioperl mailing list. Your participation is much appreciated.
95  
96 bioperl-l@bioperl.org - General discussion
97 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
98  
99 =head2 Support
100  
101 Please direct usage questions or support issues to the mailing list:
102  
103 I<bioperl-l@bioperl.org>
104  
105 rather than to the module maintainer directly. Many experienced and
106 reponsive experts will be able look at the problem and quickly
107 address it. Please include a thorough description of the problem
108 with code and data examples if at all possible.
109  
110 =head2 Reporting Bugs
111  
112 Report bugs to the Bioperl bug tracking system to help us keep track
113 of the bugs and their resolution. Bug reports can be submitted via the
114 web:
115  
116 https://github.com/bioperl/bioperl-live/issues
117  
118 =head1 AUTHOR - Jason Stajich and Steve Chervitz
119  
120 Email jason@bioperl.org
121 Email sac@bioperl.org
122  
123 =head1 CONTRIBUTORS
124  
125 Sendu Bala, bix@sendu.me.uk
126  
127 =head1 APPENDIX
128  
129 The rest of the documentation details each of the object methods.
130 Internal methods are usually preceded with a _
131  
132 =cut
133  
134  
135 # Let the code begin...
136  
137  
138 package Bio::Search::Result::GenericResult;
139 31 $Bio::Search::Result::GenericResult::VERSION = '1.7.8';
140 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
141  
142 31 ▶use Bio::Search::GenericStatistics;
Subroutine BEGIN: called CC=1 SCAR=0.0
143 31 ▶use Bio::Tools::Run::GenericParameters;
Subroutine BEGIN: called CC=1 SCAR=0.0
144  
145 # bug #1420
146 #use overload
147 # '""' => \&to_string;
148  
149 31 ▶use base qw(Bio::Root::Root Bio::Search::Result::ResultI);
Subroutine BEGIN: called CC=1 SCAR=0.0
150  
151 =head2 new
152  
153 Title : new
154 Usage : my $obj = Bio::Search::Result::GenericResult->new();
155 Function: Builds a new Bio::Search::Result::GenericResult object
156 Returns : Bio::Search::Result::GenericResult
157 Args : -query_name => Name of query Sequence
158 -query_accession => Query accession number (if available)
159 -query_description => Description of query sequence
160 -query_length => Length of query sequence
161 -database_name => Name of database
162 -database_letters => Number of residues in database
163 -database_entries => Number of entries in database
164 -hits => array ref of Bio::Search::Hit::HitI objects
165 -parameters => hash ref of search parameters (key => value)
166 -statistics => hash ref of search statistics (key => value)
167 -algorithm => program name (blastx)
168 -algorithm_version => version of the algorithm (2.1.2)
169 -algorithm_reference => literature reference string for this algorithm
170 -rid => value of the BLAST Request ID (eg. RID: ZABJ4EA7014)
171 -hit_factory => Bio::Factory::ObjectFactoryI capable of making
172 Bio::Search::Hit::HitI objects
173  
174 =cut
175  
176 148 ▶sub new {
Subroutine new: called CC=24 SCAR=32.0
Pod documented
177 148 my($class,@args) = @_;
178  
179 148 my $self = $class->SUPER::new(@args);
180  
181 148 $self->{'_hits'} = [];
182 148 $self->{'_hitindex'} = 0;
183 148 $self->{'_statistics'} = Bio::Search::GenericStatistics->new();
184 148 $self->{'_parameters'} = Bio::Tools::Run::GenericParameters->new();
185  
186 148 my ($qname,$qacc,$qdesc,$qlen, $qgi,
187 $dbname,$dblet,$dbent,$params,
188 $stats, $hits, $algo, $algo_v,
189 $prog_ref, $algo_r, $rid, $hit_factory) = $self->_rearrange([qw(QUERY_NAME
190 QUERY_ACCESSION
191 QUERY_DESCRIPTION
192 QUERY_LENGTH
193 QUERY_GI
194 DATABASE_NAME
195 DATABASE_LETTERS
196 DATABASE_ENTRIES
197 PARAMETERS
198 STATISTICS
199 HITS
200 ALGORITHM
201 ALGORITHM_VERSION
202 PROGRAM_REFERENCE
203 ALGORITHM_REFERENCE
204 RID
205 HIT_FACTORY
206 )],@args);
207  
208 148 ▶ $algo_r ||= $prog_ref;
Condition66%2/3
$algo_r ||= $prog_ref
l!l&&r!l&&!r
300118
MC/DC50%1/2
$algo_r ||= $prog_ref
$algo_r $prog_ref
Truth table66%2/3
A ||= B
A= $algo_rB= $prog_ref
ABresult
1X1
011
000
209 148 ▶ defined $algo && $self->algorithm($algo);
Branch: 1 branch
BranchTrueFalseTotal
defined $algo and $self->algorithm($algo) 87 61 148
210 148 ▶ defined $algo_v && $self->algorithm_version($algo_v);
Branch: 1 branch
BranchTrueFalseTotal
defined $algo_v and $self->algorithm_version($algo_v) 49 99 148
211 148 ▶ defined $algo_r && $self->algorithm_reference($algo_r);
Branch: 1 branch
BranchTrueFalseTotal
defined $algo_r and $self->algorithm_reference($algo_r) 30 118 148
212  
213 148 ▶ defined $rid && $self->rid($rid);
Branch: 1 branch
BranchTrueFalseTotal
defined $rid and $self->rid($rid) 2 146 148
214  
215 148 ▶ defined $qname && $self->query_name($qname);
Branch: 1 branch
BranchTrueFalseTotal
defined $qname and $self->query_name($qname) 83 65 148
216 148 ▶ defined $qacc && $self->query_accession($qacc);
Branch: 1 branch
BranchTrueFalseTotal
defined $qacc and $self->query_accession($qacc) 44 104 148
217 148 ▶ defined $qdesc && $self->query_description($qdesc);
Branch: 1 branch
BranchTrueFalseTotal
defined $qdesc and $self->query_description($qdesc) 61 87 148
218 148 ▶ defined $qlen && $self->query_length($qlen);
Branch: 1 branch
BranchTrueFalseTotal
defined $qlen and $self->query_length($qlen) 62 86 148
219 148 ▶ defined $qgi && $self->query_gi($qgi);
Branch: 1 branch
BranchTrueFalseTotal
defined $qgi and $self->query_gi($qgi) 0 148 148
220 148 ▶ defined $dbname && $self->database_name($dbname);
Branch: 1 branch
BranchTrueFalseTotal
defined $dbname and $self->database_name($dbname) 50 98 148
221 148 ▶ defined $dblet && $self->database_letters($dblet);
Branch: 1 branch
BranchTrueFalseTotal
defined $dblet and $self->database_letters($dblet) 48 100 148
222 148 ▶ defined $dbent && $self->database_entries($dbent);
Branch: 1 branch
BranchTrueFalseTotal
defined $dbent and $self->database_entries($dbent) 47 101 148
223  
224 148 ▶ defined $hit_factory && $self->hit_factory($hit_factory);
Branch: 1 branch
BranchTrueFalseTotal
defined $hit_factory and $self->hit_factory($hit_factory) 0 148 148
225
226 148 ▶ if( defined $params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params) 46 102 148
227 46 ▶ if( ref($params) !~ /hash/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref($params) =~ /hash/i) 0 46 46
228 0 $self->throw("Must specify a hash reference with the parameter '-parameters");
229 }
230 46 ▶ while( my ($key,$value) = each %{$params} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$params;}) 274 46 320
231 274 $self->{'_parameters'}->set_parameter($key => $value);
232 # $self->add_parameter($key,$value);
233 }
234 }
235 148 ▶ if( defined $stats ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stats) 46 102 148
236 46 ▶ if( ref($stats) !~ /hash/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref($stats) =~ /hash/i) 0 46 46
237 0 $self->throw("Must specify a hash reference with the parameter '-statistics");
238 }
239 46 ▶ while( my ($key,$value) = each %{$stats} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$stats;}) 1077 46 1123
240 1077 $self->{'_statistics'}->set_statistic($key => $value);
241 # $self->add_statistic($key,$value);
242 }
243 }
244  
245 148 ▶ if( defined $hits ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hits) 46 102 148
246 46 ▶ $self->throw("Must define arrayref of Hits when initializing a $class\n") unless ref($hits) =~ /array/i;
Branch: 1 branch
BranchTrueFalseTotal
unless ref($hits) =~ /array/i 0 46 46
247  
248 46 foreach my $s ( @$hits ) {
249 900 $self->add_hit($s);
250 }
251 }
252 148 return $self;
253 }
254  
255 =head2 algorithm
256  
257 Title : algorithm
258 Usage : my $r_type = $hsp->algorithm
259 Function: Obtain the name of the algorithm used to obtain the Result
260 Returns : string (e.g., BLASTP)
261 Args : [optional] scalar string to set value
262  
263 =cut
264  
265 230 ▶sub algorithm{
Subroutine algorithm: called CC=4 SCAR=14.0
Pod documented
266 230 my ($self,$value) = @_;
267 230 my $previous = $self->{'_algorithm'};
268 230 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 148 82 230
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
148082
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
269 148 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 148 148
270 148 $self->{'_algorithm'} = $value;
271 }
272 230 return $previous;
273 }
274  
275 =head2 algorithm_version
276  
277 Title : algorithm_version
278 Usage : my $r_version = $hsp->algorithm_version
279 Function: Obtain the version of the algorithm used to obtain the Result
280 Returns : string (e.g., 2.1.2)
281 Args : [optional] scalar string to set algorithm version value
282  
283 =cut
284  
285 63 ▶sub algorithm_version{
Subroutine algorithm_version: called CC=4 SCAR=14.0
Pod documented
286 63 my ($self,$value) = @_;
287 63 my $previous = $self->{'_algorithm_version'};
288 63 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 49 14 63
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
49014
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
289 49 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 49 49
290 49 $self->{'_algorithm_version'} = $value;
291 }
292  
293 63 return $previous;
294 }
295  
296 =head2 Bio::Search::Result::ResultI interface methods
297  
298 Bio::Search::Result::ResultI implementation
299  
300 =head2 next_hit
301  
302 Title : next_hit
303 Usage : while( $hit = $result->next_hit()) { ... }
304 Function: Returns the next available Hit object, representing potential
305 matches between the query and various entities from the database.
306 Returns : a Bio::Search::Hit::HitI object or undef if there are no more.
307 Args : none
308  
309  
310 =cut
311  
312 65 ▶sub next_hit {
Subroutine next_hit: called CC=4 SCAR=14.0
Pod documented
313 65 my ($self,@args) = @_;
314 65 my $index = $self->_nexthitindex;
315 65 ▶ return if $index > scalar @{$self->{'_hits'}};
Branch: 1 branch
BranchTrueFalseTotal
if $index > scalar @{$self->{"_hits"};} 0 65 65
316
317 65 my $hit = $self->{'_hits'}->[$index];
318 65 ▶ if (ref($hit) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hit eq "HASH") 50 15 65
319 50 ▶ my $factory = $self->hit_factory || $self->throw("Tried to get a Hit, but it was a hash ref and we have no hit factory");
Condition33%1/3
$self->hit_factory || $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
l!l&&r!l&&!r
5000
MC/DC0%0/2
$self->hit_factory || $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
$self->hit_factory $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
Truth table33%1/3
A || B
A= $self->hit_factoryB= $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
ABresult
1X1
011
000
320 50 $hit = $factory->create_object(%{$hit});
321 50 $self->{'_hits'}->[$index] = $hit;
322 50 delete $self->{_hashes}->{$index};
323 }
324 65 return $hit;
325 }
326  
327 =head2 query_name
328  
329 Title : query_name
330 Usage : $id = $result->query_name();
331 Function: Get the string identifier of the query used by the
332 algorithm that performed the search.
333 Returns : a string.
334 Args : [optional] new string value for query name
335  
336 =cut
337  
338 245 ▶sub query_name {
Subroutine query_name: called CC=4 SCAR=14.0
Pod documented
339 245 my ($self,$value) = @_;
340 245 my $previous = $self->{'_queryname'};
341 245 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 144 101 245
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
1440101
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
342 144 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 144 144
343 144 $self->{'_queryname'} = $value;
344 }
345 245 return $previous;
346 }
347  
348 =head2 query_accession
349  
350 Title : query_accession
351 Usage : $id = $result->query_accession();
352 Function: Get the accession (if available) for the query sequence
353 Returns : a string
354 Args : [optional] new string value for accession
355  
356 =cut
357  
358 109 ▶sub query_accession {
Subroutine query_accession: called CC=4 SCAR=14.0
Pod documented
359 109 my ($self,$value) = @_;
360 109 my $previous = $self->{'_queryacc'};
361 109 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 105 4 109
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
10504
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
362 105 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 105 105
363 105 $self->{'_queryacc'} = $value;
364 }
365 109 return $previous;
366 }
367  
368 =head2 query_gi
369  
370 Title : query_gi
371 Usage : $acc = $hit->query_gi();
372 Function: Retrieve the NCBI Unique ID (aka the GI #),
373 if available, for the query
374 Returns : a scalar string (empty string if not set)
375 Args : none
376  
377 =cut
378  
379 0 ▶sub query_gi {
Subroutine query_gi: not called CC=3 SCAR=24.8
Pod documented
380 0 my ($self,$value) = @_;
381 0 ▶ if( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
382 0 $self->{'_query_gi'} = $value;
383 } else {
384 0 ▶ $self->{'_query_gi'} = $self->query_name =~ m{^gi\|(\d+)} ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->query_name =~ /^gi\|(\d+)/ ? : 0 0 0
385 }
386 0 return $self->{'_query_gi'};
387 }
388  
389 =head2 query_length
390  
391 Title : query_length
392 Usage : $id = $result->query_length();
393 Function: Get the length of the query sequence
394 used in the search.
395 Returns : a number
396 Args : [optional] new integer value for query length
397  
398 =cut
399  
400 123 ▶sub query_length {
Subroutine query_length: called CC=4 SCAR=13.9
Pod documented
401 123 my ($self,$value) = @_;
402 123 my $previous = $self->{'_querylength'};
403 123 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 63 60 123
Condition100%3/3
defined $value or not defined $previous
l!l&&r!l&&!r
62160
MC/DC100%2/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table100%3/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
404 63 ▶ $value = $previous = 0 unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1 62 63
405 63 $self->{'_querylength'} = $value;
406 }
407 123 return $previous;
408 }
409  
410 =head2 query_description
411  
412 Title : query_description
413 Usage : $id = $result->query_description();
414 Function: Get the description of the query sequence
415 used in the search.
416 Returns : a string
417 Args : [optional] new string for the query description
418  
419 =cut
420  
421 131 ▶sub query_description {
Subroutine query_description: called CC=4 SCAR=13.9
Pod documented
422 131 my ($self,$value) = @_;
423 131 my $previous = $self->{'_querydesc'};
424 131 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 123 8 131
Condition100%3/3
defined $value or not defined $previous
l!l&&r!l&&!r
12218
MC/DC100%2/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table100%3/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
425 123 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1 122 123
426 123 $self->{'_querydesc'} = $value;
427 }
428 131 return $previous;
429 }
430  
431  
432 =head2 database_name
433  
434 Title : database_name
435 Usage : $name = $result->database_name()
436 Function: Used to obtain the name of the database that the query was searched
437 against by the algorithm.
438 Returns : a scalar string
439 Args : [optional] new string for the db name
440  
441 =cut
442  
443 64 ▶sub database_name {
Subroutine database_name: called CC=4 SCAR=14.0
Pod documented
444 64 my ($self,$value) = @_;
445 64 my $previous = $self->{'_dbname'};
446 64 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 50 14 64
Condition66%2/3
defined $value or not defined $previous
l!l&&r!l&&!r
50014
MC/DC50%1/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table66%2/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
447 50 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 50 50
448 50 $self->{'_dbname'} = $value;
449 }
450 64 return $previous;
451 }
452  
453 =head2 database_letters
454  
455 Title : database_letters
456 Usage : $size = $result->database_letters()
457 Function: Used to obtain the size of database that was searched against.
458 Returns : a scalar integer (units specific to algorithm, but probably the
459 total number of residues in the database, if available) or undef if
460 the information was not available to the Processor object.
461 Args : [optional] new scalar integer for number of letters in db
462  
463  
464 =cut
465  
466 60 ▶sub database_letters {
Subroutine database_letters: called CC=4 SCAR=13.9
Pod documented
467 60 my ($self,$value) = @_;
468 60 my $previous = $self->{'_dbletters'};
469 60 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 50 10 60
Condition100%3/3
defined $value or not defined $previous
l!l&&r!l&&!r
48210
MC/DC100%2/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table100%3/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
470 50 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 2 48 50
471 50 $self->{'_dbletters'} = $value;
472 }
473 60 return $previous;
474 }
475  
476 =head2 database_entries
477  
478 Title : database_entries
479 Usage : $num_entries = $result->database_entries()
480 Function: Used to obtain the number of entries contained in the database.
481 Returns : a scalar integer representing the number of entities in the database
482 or undef if the information was not available.
483 Args : [optional] new integer for the number of sequence entries in the db
484  
485  
486 =cut
487  
488 59 ▶sub database_entries {
Subroutine database_entries: called CC=4 SCAR=13.9
Pod documented
489 59 my ($self,$value) = @_;
490 59 my $previous = $self->{'_dbentries'};
491 59 ▶ if( defined $value || ! defined $previous ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value or not defined $previous) 50 9 59
Condition100%3/3
defined $value or not defined $previous
l!l&&r!l&&!r
4739
MC/DC100%2/2
defined $value or not defined $previous
defined $value not defined $previous
Truth table100%3/3
A or not(B)
A= defined $valueB= not defined $previous
ABresult
1X1
011
000
492 50 ▶ $value = $previous = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3 47 50
493 50 $self->{'_dbentries'} = $value;
494 }
495 59 return $previous;
496 }
497  
498 =head2 get_parameter
499  
500 Title : get_parameter
501 Usage : my $gap_ext = $report->get_parameter('gapext')
502 Function: Returns the value for a specific parameter used
503 when running this report
504 Returns : string
505 Args : name of parameter (string)
506  
507 =cut
508  
509 51 ▶sub get_parameter {
Subroutine get_parameter: called CC=1 SCAR=0.0
Pod documented
510 51 my ($self,$name) = @_;
511 51 return $self->{'_parameters'}->get_parameter($name);
512 }
513  
514 =head2 available_parameters
515  
516 Title : available_parameters
517 Usage : my @params = $report->available_paramters
518 Function: Returns the names of the available parameters
519 Returns : Return list of available parameters used for this report
520 Args : none
521  
522 =cut
523  
524 5 ▶sub available_parameters{
Subroutine available_parameters: called CC=1 SCAR=0.0
Pod documented
525 5 my ($self) = @_;
526 5 return $self->{'_parameters'}->available_parameters;
527 }
528  
529  
530 =head2 get_statistic
531  
532 Title : get_statistic
533 Usage : my $gap_ext = $report->get_statistic('kappa')
534 Function: Returns the value for a specific statistic available
535 from this report
536 Returns : string
537 Args : name of statistic (string)
538  
539 =cut
540  
541 70 ▶sub get_statistic{
Subroutine get_statistic: called CC=1 SCAR=0.0
Pod documented
542 70 my ($self,$key) = @_;
543 70 return $self->{'_statistics'}->get_statistic($key);
544 }
545  
546 =head2 available_statistics
547  
548 Title : available_statistics
549 Usage : my @statnames = $report->available_statistics
550 Function: Returns the names of the available statistics
551 Returns : Return list of available statistics used for this report
552 Args : none
553  
554 =cut
555  
556 5 ▶sub available_statistics{
Subroutine available_statistics: called CC=1 SCAR=0.0
Pod documented
557 5 my ($self) = @_;
558 5 return $self->{'_statistics'}->available_statistics;
559 }
560  
561 =head2 Bio::Search::Report
562  
563 Bio::Search::Result::GenericResult specific methods
564  
565 =head2 add_hit
566  
567 Title : add_hit
568 Usage : $report->add_hit($hit)
569 Function: Adds a HitI to the stored list of hits
570 Returns : Number of HitI currently stored
571 Args : Bio::Search::Hit::HitI
572  
573 =cut
574  
575 962 ▶sub add_hit {
Subroutine add_hit: called CC=4 SCAR=14.1
Pod documented
576 962 my ($self,$s) = @_;
577 962 ▶ if (ref($s) eq 'HASH' || $s->isa('Bio::Search::Hit::HitI') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $s eq 'HASH' or $s->isa('Bio::Search::Hit::HitI')) { } 962 0 962
Condition66%2/3
ref $s eq "HASH" or $s->isa("Bio::Search::Hit::HitI")
l!l&&r!l&&!r
900620
MC/DC0%0/2
ref $s eq "HASH" or $s->isa("Bio::Search::Hit::HitI")
ref $s eq "HASH" $s->isa("Bio::Search::Hit::HitI")
Truth table66%2/3
A or B
A= ref $s eq "HASH"B= $s->isa("Bio::Search::Hit::HitI")
ABresult
1X1
011
000
578 962 push @{$self->{'_hits'}}, $s;
579 }
580 else {
581 0 $self->throw("Passed in " .ref($s)." as a Hit which is not a Bio::Search::HitI.");
582 }
583
584 962 ▶ if (ref($s) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $s eq "HASH") 900 62 962
585 900 $self->{_hashes}->{$#{$self->{'_hits'}}} = 1;
586 }
587 962 return scalar @{$self->{'_hits'}};
588 }
589  
590 =head2 hit_factory
591  
592 Title : hit_factory
593 Usage : $hit->hit_factory($hit_factory)
594 Function: Get/set the factory used to build HitI objects if necessary.
595 Returns : Bio::Factory::ObjectFactoryI
596 Args : Bio::Factory::ObjectFactoryI
597  
598 =cut
599  
600 218 ▶sub hit_factory {
Subroutine hit_factory: called CC=3 SCAR=11.0
Pod documented
601 218 my $self = shift;
602 218 ▶ if (@_) { $self->{_hit_factory} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 86 132 218
603 218 ▶ return $self->{_hit_factory} || return;
Condition50%1/2
$self->{'_hit_factory'} || (return)
l!l
2180
MC/DC0%0/1
$self->{'_hit_factory'} || (return)
$self->{'_hit_factory'}
Truth table50%1/2
A
A= $self->{'_hit_factory'}
Aresult
11
00
604 }
605  
606 =head2 rewind
607  
608 Title : rewind
609 Usage : $result->rewind;
610 Function: Allow one to reset the Hit iterator to the beginning
611 Since this is an in-memory implementation
612 Returns : none
613 Args : none
614  
615 =cut
616  
617 5 ▶sub rewind{
Subroutine rewind: called CC=1 SCAR=0.0
Pod documented
618 5 my ($self) = @_;
619 5 $self->{'_hitindex'} = 0;
620 }
621  
622  
623 =head2 _nexthitindex
624  
625 Title : _nexthitindex
626 Usage : private
627  
628 =cut
629  
630 65 ▶sub _nexthitindex{
Subroutine _nexthitindex: called CC=1 SCAR=0.0
631 65 my ($self,@args) = @_;
632 65 return $self->{'_hitindex'}++;
633 }
634  
635  
636 =head2 add_parameter
637  
638 Title : add_parameter
639 Usage : $report->add_parameter('gapext', 11);
640 Function: Adds a parameter
641 Returns : none
642 Args : key - key value name for this parama
643 value - value for this parameter
644  
645 =cut
646  
647 0 ▶sub add_parameter {
Subroutine add_parameter: not called CC=1 SCAR=6.9
Pod documented
648 0 my ($self,$key,$value) = @_;
649 0 $self->{'_parameters'}->set_parameter($key => $value);
650 }
651  
652  
653 =head2 add_statistic
654  
655 Title : add_statistic
656 Usage : $report->add_statistic('lambda', 2.3);
657 Function: Adds a parameter
658 Returns : none
659 Args : key - key value name for this parama
660 value - value for this parameter
661  
662 =cut
663  
664 0 ▶sub add_statistic {
Subroutine add_statistic: not called CC=1 SCAR=6.9
Pod documented
665 0 my ($self,$key,$value) = @_;
666 0 $self->{'_statistics'}->set_statistic($key => $value);
667 0 return;
668 }
669  
670  
671 =head2 num_hits
672  
673 Title : num_hits
674 Usage : my $hitcount= $result->num_hits
675 Function: returns the number of hits for this query result
676 Returns : integer
677 Args : none
678  
679 =cut
680  
681 8 ▶sub num_hits{
Subroutine num_hits: called CC=2 SCAR=7.4
Pod documented
682 8 my ($self) = shift;
683 8 ▶ if (not defined $self->{'_hits'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_hits"}) 0 8 8
684 0 $self->throw("Can't get Hits: data not collected.");
685 }
686 8 return scalar(@{$self->{'_hits'}});
687 }
688  
689  
690 =head2 hits
691  
692 Title : hits
693 Usage : my @hits = $result->hits
694 Function: Returns the available hits for this Result
695 Returns : Array of L<Bio::Search::Hit::HitI> objects
696 Args : none
697  
698  
699 =cut
700  
701 5 ▶sub hits {
Subroutine hits: called CC=5 SCAR=16.6
Pod documented
702 5 my ($self) = shift;
703
704 5 ▶ foreach my $i (keys %{$self->{_hashes} || {}}) {
Condition50%1/2
$self->{'_hashes'} || {}
l!l
50
MC/DC0%0/1
$self->{'_hashes'} || {}
$self->{'_hashes'}
Truth table50%1/2
A
A= $self->{'_hashes'}
Aresult
11
00
705 82 ▶ my $factory = $self->hit_factory || $self->throw("Tried to get a Hit, but it was a hash ref and we have no hit factory");
Condition33%1/3
$self->hit_factory || $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
l!l&&r!l&&!r
8200
MC/DC0%0/2
$self->hit_factory || $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
$self->hit_factory $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
Truth table33%1/3
A || B
A= $self->hit_factoryB= $self->throw('Tried to get a Hit, but it was a hash ref and we have no hit factory')
ABresult
1X1
011
000
706 82 $self->{'_hits'}->[$i] = $factory->create_object(%{$self->{'_hits'}->[$i]});
707 82 delete $self->{_hashes}->{$i};
708 }
709
710 5 my @hits = ();
711 5 ▶ if (ref $self->{'_hits'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"_hits"}) 5 0 5
712 5 @hits = @{$self->{'_hits'}};
713 }
714 5 return @hits;
715 }
716  
717 =head2 algorithm_reference
718  
719 Title : algorithm_reference
720 Usage : $obj->algorithm_reference($newval)
721 Function:
722 Returns : string containing literature reference for the algorithm
723 Args : newvalue string (optional)
724 Comments: Formerly named program_reference(), which is still supported
725 for backwards compatibility.
726  
727 =cut
728  
729 38 ▶sub algorithm_reference{
Subroutine algorithm_reference: called CC=2 SCAR=6.9
Pod documented
730 38 my ($self,$value) = @_;
731 38 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 30 8 38
732 30 $self->{'algorithm_reference'} = $value;
733 }
734 38 return $self->{'algorithm_reference'};
735 }
736  
737 =head2 program_reference
738  
739 Title : program_reference
740 Usage : $obj->program_reference()
741 Function:
742 Returns : string containing literature reference for the algorithm
743 Args :
744 Comments: Deprecated - use algorithm_reference() instead.
745  
746 =cut
747  
748 3 ▶sub program_reference { shift->algorithm_reference(@_); }
Subroutine program_reference: called CC=1 SCAR=0.0
Pod documented
749  
750 =head2 rid
751  
752 Title : rid
753 Usage : $obj->rid($newval)
754 Function:
755 Returns : value of the BLAST Request ID (eg. RID: ZABJ4EA7014)
756 Args : newvalue (optional)
757 Comments: The default implementation in ResultI returns an empty string
758 rather than throwing a NotImplemented exception, since
759 the RID may not always be available and is not critical.
760 See: (1) https://www.ncbi.nlm.nih.gov/Class/MLACourse/Modules/BLAST/rid.html
761 (2) https://www.ncbi.nlm.nih.gov/staff/tao/URLAPI/new/node63.html
762 =cut
763  
764 2 ▶sub rid{
Subroutine rid: called CC=2 SCAR=7.0
Pod documented
765 2 my ($self,$value) = @_;
766 2 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 0 2
767 2 $self->{'rid'} = $value;
768 }
769 2 return $self->{'rid'};
770 }
771
772 =head2 no_hits_found
773  
774 See documentation in L<Bio::Search::Result::ResultI::no_hits_found()|Bio::Search::Result::ResultI>
775  
776 =cut
777  
778 0 ▶sub no_hits_found {
Subroutine no_hits_found: not called CC=1 SCAR=6.9
Pod documented
779 0 my $self = shift;
780  
781 # Watch the double negative!
782 # result = 0 means "yes hits were found"
783 # result = 1 means "no hits were found"
784  
785 0 return $self->{'_no_hits_found'};
786 }
787  
788  
789 =head2 set_no_hits_found
790  
791 See documentation in L<Bio::Search::Result::ResultI::set_no_hits_found()|Bio::Search::Result::ResultI>
792  
793 =cut
794  
795 0 ▶sub set_no_hits_found {
Subroutine set_no_hits_found: not called CC=1 SCAR=6.9
Pod documented
796 0 my $self = shift;
797 0 $self->{'_no_hits_found'} = 1;
798 }
799  
800  
801 =head2 to_string
802  
803 Title : to_string
804 Usage : print $blast->to_string;
805 Function: Returns a string representation for the Blast result.
806 Primarily intended for debugging purposes.
807 Example : see usage
808 Returns : A string of the form:
809 [GenericResult] <analysis_method> query=<name> <description> db=<database
810 e.g.:
811 [GenericResult] BLASTP query=YEL060C vacuolar protease B, db=PDBUNIQ
812 Args : None
813  
814 =cut
815  
816 0 ▶sub to_string {
Subroutine to_string: not called CC=1 SCAR=6.9
Pod documented
817 0 my $self = shift;
818 0 my $str = ref($self) . ", algorithm= " . $self->algorithm . ", query=" . $self->query_name . " " . $self->query_description .", db=" . $self->database_name;
819 0 return $str;
820 }
821  
822 31 1;
« Bio/SeqFeature/SimilarityPair.pm ↑ Summary Bio/LocatableSeq.pm »