File Coverage

Bio/Search/Result/GenericResult.pm
Criterion Covered Total %
statement 168 185 90.8
branch 83 98 84.6
condition 31 41 75.6
subroutine 29 34 85.2
pod 29 29 100.0
total 340 387 87.8


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Search::Result::GenericResult
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Jason Stajich
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.
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
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 27     27   99 use strict;
  27         32  
  27         690  
140              
141 27     27   8998 use Bio::Search::GenericStatistics;
  27         46  
  27         591  
142 27     27   9580 use Bio::Tools::Run::GenericParameters;
  27         42  
  27         692  
143              
144             # bug #1420
145             #use overload
146             # '""' => \&to_string;
147              
148 27     27   103 use base qw(Bio::Root::Root Bio::Search::Result::ResultI);
  27         24  
  27         11195  
149              
150             =head2 new
151              
152             Title : new
153             Usage : my $obj = Bio::Search::Result::GenericResult->new();
154             Function: Builds a new Bio::Search::Result::GenericResult object
155             Returns : Bio::Search::Result::GenericResult
156             Args : -query_name => Name of query Sequence
157             -query_accession => Query accession number (if available)
158             -query_description => Description of query sequence
159             -query_length => Length of query sequence
160             -database_name => Name of database
161             -database_letters => Number of residues in database
162             -database_entries => Number of entries in database
163             -hits => array ref of Bio::Search::Hit::HitI objects
164             -parameters => hash ref of search parameters (key => value)
165             -statistics => hash ref of search statistics (key => value)
166             -algorithm => program name (blastx)
167             -algorithm_version => version of the algorithm (2.1.2)
168             -algorithm_reference => literature reference string for this algorithm
169             -rid => value of the BLAST Request ID (eg. RID: ZABJ4EA7014)
170             -hit_factory => Bio::Factory::ObjectFactoryI capable of making
171             Bio::Search::Hit::HitI objects
172              
173             =cut
174              
175             sub new {
176 242     242 1 1047 my($class,@args) = @_;
177              
178 242         948 my $self = $class->SUPER::new(@args);
179              
180 242         576 $self->{'_hits'} = [];
181 242         424 $self->{'_hitindex'} = 0;
182 242         1772 $self->{'_statistics'} = Bio::Search::GenericStatistics->new();
183 242         1704 $self->{'_parameters'} = Bio::Tools::Run::GenericParameters->new();
184              
185 242         1982 my ($qname,$qacc,$qdesc,$qlen, $qgi,
186             $dbname,$dblet,$dbent,$params,
187             $stats, $hits, $algo, $algo_v,
188             $prog_ref, $algo_r, $rid, $hit_factory) = $self->_rearrange([qw(QUERY_NAME
189             QUERY_ACCESSION
190             QUERY_DESCRIPTION
191             QUERY_LENGTH
192             QUERY_GI
193             DATABASE_NAME
194             DATABASE_LETTERS
195             DATABASE_ENTRIES
196             PARAMETERS
197             STATISTICS
198             HITS
199             ALGORITHM
200             ALGORITHM_VERSION
201             PROGRAM_REFERENCE
202             ALGORITHM_REFERENCE
203             RID
204             HIT_FACTORY
205             )],@args);
206              
207 242   66     1372 $algo_r ||= $prog_ref;
208 242 100       968 defined $algo && $self->algorithm($algo);
209 242 100       841 defined $algo_v && $self->algorithm_version($algo_v);
210 242 100       739 defined $algo_r && $self->algorithm_reference($algo_r);
211              
212 242 100       480 defined $rid && $self->rid($rid);
213              
214 242 100       820 defined $qname && $self->query_name($qname);
215 242 100       693 defined $qacc && $self->query_accession($qacc);
216 242 100       819 defined $qdesc && $self->query_description($qdesc);
217 242 100       847 defined $qlen && $self->query_length($qlen);
218 242 50       462 defined $qgi && $self->query_gi($qgi);
219 242 100       672 defined $dbname && $self->database_name($dbname);
220 242 100       670 defined $dblet && $self->database_letters($dblet);
221 242 100       696 defined $dbent && $self->database_entries($dbent);
222              
223 242 50       464 defined $hit_factory && $self->hit_factory($hit_factory);
224            
225 242 100       499 if( defined $params ) {
226 93 50       505 if( ref($params) !~ /hash/i ) {
227 0         0 $self->throw("Must specify a hash reference with the parameter '-parameters");
228             }
229 93         154 while( my ($key,$value) = each %{$params} ) {
  616         1393  
230 523         904 $self->{'_parameters'}->set_parameter($key => $value);
231             # $self->add_parameter($key,$value);
232             }
233             }
234 242 100       579 if( defined $stats ) {
235 93 50       338 if( ref($stats) !~ /hash/i ) {
236 0         0 $self->throw("Must specify a hash reference with the parameter '-statistics");
237             }
238 93         122 while( my ($key,$value) = each %{$stats} ) {
  2467         4074  
239 2374         2813 $self->{'_statistics'}->set_statistic($key => $value);
240             # $self->add_statistic($key,$value);
241             }
242             }
243              
244 242 100       548 if( defined $hits ) {
245 84 50       425 $self->throw("Must define arrayref of Hits when initializing a $class\n") unless ref($hits) =~ /array/i;
246              
247 84         172 foreach my $s ( @$hits ) {
248 4681         4188 $self->add_hit($s);
249             }
250             }
251 242         924 return $self;
252             }
253              
254             =head2 algorithm
255              
256             Title : algorithm
257             Usage : my $r_type = $hsp->algorithm
258             Function: Obtain the name of the algorithm used to obtain the Result
259             Returns : string (e.g., BLASTP)
260             Args : [optional] scalar string to set value
261              
262             =cut
263              
264             sub algorithm{
265 369     369 1 9748 my ($self,$value) = @_;
266 369         613 my $previous = $self->{'_algorithm'};
267 369 100 66     1271 if( defined $value || ! defined $previous ) {
268 242 50       479 $value = $previous = '' unless defined $value;
269 242         448 $self->{'_algorithm'} = $value;
270             }
271 369         765 return $previous;
272             }
273              
274             =head2 algorithm_version
275              
276             Title : algorithm_version
277             Usage : my $r_version = $hsp->algorithm_version
278             Function: Obtain the version of the algorithm used to obtain the Result
279             Returns : string (e.g., 2.1.2)
280             Args : [optional] scalar string to set algorithm version value
281              
282             =cut
283              
284             sub algorithm_version{
285 186     186 1 284 my ($self,$value) = @_;
286 186         287 my $previous = $self->{'_algorithm_version'};
287 186 100 66     689 if( defined $value || ! defined $previous ) {
288 136 50       253 $value = $previous = '' unless defined $value;
289 136         248 $self->{'_algorithm_version'} = $value;
290             }
291              
292 186         362 return $previous;
293             }
294              
295             =head2 Bio::Search::Result::ResultI interface methods
296              
297             Bio::Search::Result::ResultI implementation
298              
299             =head2 next_hit
300              
301             Title : next_hit
302             Usage : while( $hit = $result->next_hit()) { ... }
303             Function: Returns the next available Hit object, representing potential
304             matches between the query and various entities from the database.
305             Returns : a Bio::Search::Hit::HitI object or undef if there are no more.
306             Args : none
307              
308              
309             =cut
310              
311             sub next_hit {
312 1198     1198 1 9577 my ($self,@args) = @_;
313 1198         1669 my $index = $self->_nexthitindex;
314 1198 50       954 return if $index > scalar @{$self->{'_hits'}};
  1198         2066  
315            
316 1198         1274 my $hit = $self->{'_hits'}->[$index];
317 1198 100       1834 if (ref($hit) eq 'HASH') {
318 1175   33     1673 my $factory = $self->hit_factory || $self->throw("Tried to get a Hit, but it was a hash ref and we have no hit factory");
319 1175         1031 $hit = $factory->create_object(%{$hit});
  1175         5056  
320 1175         1763 $self->{'_hits'}->[$index] = $hit;
321 1175         3405 delete $self->{_hashes}->{$index};
322             }
323 1198         2129 return $hit;
324             }
325              
326             =head2 query_name
327              
328             Title : query_name
329             Usage : $id = $result->query_name();
330             Function: Get the string identifier of the query used by the
331             algorithm that performed the search.
332             Returns : a string.
333             Args : [optional] new string value for query name
334              
335             =cut
336              
337             sub query_name {
338 391     391 1 578 my ($self,$value) = @_;
339 391         576 my $previous = $self->{'_queryname'};
340 391 100 100     1394 if( defined $value || ! defined $previous ) {
341 238 100       549 $value = $previous = '' unless defined $value;
342 238         527 $self->{'_queryname'} = $value;
343             }
344 391         1450 return $previous;
345             }
346              
347             =head2 query_accession
348              
349             Title : query_accession
350             Usage : $id = $result->query_accession();
351             Function: Get the accession (if available) for the query sequence
352             Returns : a string
353             Args : [optional] new string value for accession
354              
355             =cut
356              
357             sub query_accession {
358 193     193 1 270 my ($self,$value) = @_;
359 193         290 my $previous = $self->{'_queryacc'};
360 193 100 100     656 if( defined $value || ! defined $previous ) {
361 176 100       419 $value = $previous = '' unless defined $value;
362 176         360 $self->{'_queryacc'} = $value;
363             }
364 193         283 return $previous;
365             }
366              
367             =head2 query_gi
368              
369             Title : query_gi
370             Usage : $acc = $hit->query_gi();
371             Function: Retrieve the NCBI Unique ID (aka the GI #),
372             if available, for the query
373             Returns : a scalar string (empty string if not set)
374             Args : none
375              
376             =cut
377              
378             sub query_gi {
379 8     8 1 19 my ($self,$value) = @_;
380 8 50       25 if( defined $value ) {
381 0         0 $self->{'_query_gi'} = $value;
382             } else {
383 8 50       20 $self->{'_query_gi'} = $self->query_name =~ m{^gi\|(\d+)} ? $1 : '';
384             }
385 8         32 return $self->{'_query_gi'};
386             }
387              
388             =head2 query_length
389              
390             Title : query_length
391             Usage : $id = $result->query_length();
392             Function: Get the length of the query sequence
393             used in the search.
394             Returns : a number
395             Args : [optional] new integer value for query length
396              
397             =cut
398              
399             sub query_length {
400 261     261 1 595 my ($self,$value) = @_;
401 261         642 my $previous = $self->{'_querylength'};
402 261 100 100     938 if( defined $value || ! defined $previous ) {
403 149 100       311 $value = $previous = 0 unless defined $value;
404 149         270 $self->{'_querylength'} = $value;
405             }
406 261         526 return $previous;
407             }
408              
409             =head2 query_description
410              
411             Title : query_description
412             Usage : $id = $result->query_description();
413             Function: Get the description of the query sequence
414             used in the search.
415             Returns : a string
416             Args : [optional] new string for the query description
417              
418             =cut
419              
420             sub query_description {
421 233     233 1 357 my ($self,$value) = @_;
422 233         552 my $previous = $self->{'_querydesc'};
423 233 100 100     784 if( defined $value || ! defined $previous ) {
424 205 100       463 $value = $previous = '' unless defined $value;
425 205         425 $self->{'_querydesc'} = $value;
426             }
427 233         417 return $previous;
428             }
429              
430              
431             =head2 database_name
432              
433             Title : database_name
434             Usage : $name = $result->database_name()
435             Function: Used to obtain the name of the database that the query was searched
436             against by the algorithm.
437             Returns : a scalar string
438             Args : [optional] new string for the db name
439              
440             =cut
441              
442             sub database_name {
443 140     140 1 204 my ($self,$value) = @_;
444 140         217 my $previous = $self->{'_dbname'};
445 140 100 66     475 if( defined $value || ! defined $previous ) {
446 105 50       234 $value = $previous = '' unless defined $value;
447 105         208 $self->{'_dbname'} = $value;
448             }
449 140         282 return $previous;
450             }
451              
452             =head2 database_letters
453              
454             Title : database_letters
455             Usage : $size = $result->database_letters()
456             Function: Used to obtain the size of database that was searched against.
457             Returns : a scalar integer (units specific to algorithm, but probably the
458             total number of residues in the database, if available) or undef if
459             the information was not available to the Processor object.
460             Args : [optional] new scalar integer for number of letters in db
461              
462              
463             =cut
464              
465             sub database_letters {
466 126     126 1 177 my ($self,$value) = @_;
467 126         185 my $previous = $self->{'_dbletters'};
468 126 100 100     461 if( defined $value || ! defined $previous ) {
469 99 100       231 $value = $previous = '' unless defined $value;
470 99         165 $self->{'_dbletters'} = $value;
471             }
472 126         202 return $previous;
473             }
474              
475             =head2 database_entries
476              
477             Title : database_entries
478             Usage : $num_entries = $result->database_entries()
479             Function: Used to obtain the number of entries contained in the database.
480             Returns : a scalar integer representing the number of entities in the database
481             or undef if the information was not available.
482             Args : [optional] new integer for the number of sequence entries in the db
483              
484              
485             =cut
486              
487             sub database_entries {
488 124     124 1 175 my ($self,$value) = @_;
489 124         175 my $previous = $self->{'_dbentries'};
490 124 100 100     456 if( defined $value || ! defined $previous ) {
491 99 100       203 $value = $previous = '' unless defined $value;
492 99         197 $self->{'_dbentries'} = $value;
493             }
494 124         192 return $previous;
495             }
496              
497             =head2 get_parameter
498              
499             Title : get_parameter
500             Usage : my $gap_ext = $report->get_parameter('gapext')
501             Function: Returns the value for a specific parameter used
502             when running this report
503             Returns : string
504             Args : name of parameter (string)
505              
506             =cut
507              
508             sub get_parameter {
509 76     76 1 100 my ($self,$name) = @_;
510 76         185 return $self->{'_parameters'}->get_parameter($name);
511             }
512              
513             =head2 available_parameters
514              
515             Title : available_parameters
516             Usage : my @params = $report->available_paramters
517             Function: Returns the names of the available parameters
518             Returns : Return list of available parameters used for this report
519             Args : none
520              
521             =cut
522              
523             sub available_parameters{
524 7     7 1 11 my ($self) = @_;
525 7         31 return $self->{'_parameters'}->available_parameters;
526             }
527              
528              
529             =head2 get_statistic
530              
531             Title : get_statistic
532             Usage : my $gap_ext = $report->get_statistic('kappa')
533             Function: Returns the value for a specific statistic available
534             from this report
535             Returns : string
536             Args : name of statistic (string)
537              
538             =cut
539              
540             sub get_statistic{
541 305     305 1 410 my ($self,$key) = @_;
542 305         709 return $self->{'_statistics'}->get_statistic($key);
543             }
544              
545             =head2 available_statistics
546              
547             Title : available_statistics
548             Usage : my @statnames = $report->available_statistics
549             Function: Returns the names of the available statistics
550             Returns : Return list of available statistics used for this report
551             Args : none
552              
553             =cut
554              
555             sub available_statistics{
556 7     7 1 11 my ($self) = @_;
557 7         25 return $self->{'_statistics'}->available_statistics;
558             }
559              
560             =head2 Bio::Search::Report
561              
562             Bio::Search::Result::GenericResult specific methods
563              
564             =head2 add_hit
565              
566             Title : add_hit
567             Usage : $report->add_hit($hit)
568             Function: Adds a HitI to the stored list of hits
569             Returns : Number of HitI currently stored
570             Args : Bio::Search::Hit::HitI
571              
572             =cut
573              
574             sub add_hit {
575 4743     4743 1 3431 my ($self,$s) = @_;
576 4743 50 66     7221 if (ref($s) eq 'HASH' || $s->isa('Bio::Search::Hit::HitI') ) {
577 4743         2738 push @{$self->{'_hits'}}, $s;
  4743         4251  
578             }
579             else {
580 0         0 $self->throw("Passed in " .ref($s)." as a Hit which is not a Bio::Search::HitI.");
581             }
582            
583 4743 100       5558 if (ref($s) eq 'HASH') {
584 4680         2882 $self->{_hashes}->{$#{$self->{'_hits'}}} = 1;
  4680         7135  
585             }
586 4743         3174 return scalar @{$self->{'_hits'}};
  4743         5392  
587             }
588              
589             =head2 hit_factory
590              
591             Title : hit_factory
592             Usage : $hit->hit_factory($hit_factory)
593             Function: Get/set the factory used to build HitI objects if necessary.
594             Returns : Bio::Factory::ObjectFactoryI
595             Args : Bio::Factory::ObjectFactoryI
596              
597             =cut
598              
599             sub hit_factory {
600 1437     1437 1 1098 my $self = shift;
601 1437 100       2413 if (@_) { $self->{_hit_factory} = shift }
  180         333  
602 1437   50     3218 return $self->{_hit_factory} || return;
603             }
604              
605             =head2 rewind
606              
607             Title : rewind
608             Usage : $result->rewind;
609             Function: Allow one to reset the Hit iterator to the beginning
610             Since this is an in-memory implementation
611             Returns : none
612             Args : none
613              
614             =cut
615              
616             sub rewind{
617 5     5 1 11 my ($self) = @_;
618 5         13 $self->{'_hitindex'} = 0;
619             }
620              
621              
622             =head2 _nexthitindex
623              
624             Title : _nexthitindex
625             Usage : private
626              
627             =cut
628              
629             sub _nexthitindex{
630 1198     1198   1079 my ($self,@args) = @_;
631 1198         1445 return $self->{'_hitindex'}++;
632             }
633              
634              
635             =head2 add_parameter
636              
637             Title : add_parameter
638             Usage : $report->add_parameter('gapext', 11);
639             Function: Adds a parameter
640             Returns : none
641             Args : key - key value name for this parama
642             value - value for this parameter
643              
644             =cut
645              
646             sub add_parameter {
647 0     0 1 0 my ($self,$key,$value) = @_;
648 0         0 $self->{'_parameters'}->set_parameter($key => $value);
649             }
650              
651              
652             =head2 add_statistic
653              
654             Title : add_statistic
655             Usage : $report->add_statistic('lambda', 2.3);
656             Function: Adds a parameter
657             Returns : none
658             Args : key - key value name for this parama
659             value - value for this parameter
660              
661             =cut
662              
663             sub add_statistic {
664 0     0 1 0 my ($self,$key,$value) = @_;
665 0         0 $self->{'_statistics'}->set_statistic($key => $value);
666 0         0 return;
667             }
668              
669              
670             =head2 num_hits
671              
672             Title : num_hits
673             Usage : my $hitcount= $result->num_hits
674             Function: returns the number of hits for this query result
675             Returns : integer
676             Args : none
677              
678             =cut
679              
680             sub num_hits{
681 32     32 1 2204 my ($self) = shift;
682 32 50       116 if (not defined $self->{'_hits'}) {
683 0         0 $self->throw("Can't get Hits: data not collected.");
684             }
685 32         40 return scalar(@{$self->{'_hits'}});
  32         155  
686             }
687              
688              
689             =head2 hits
690              
691             Title : hits
692             Usage : my @hits = $result->hits
693             Function: Returns the available hits for this Result
694             Returns : Array of L objects
695             Args : none
696              
697              
698             =cut
699              
700             sub hits {
701 5     5 1 12 my ($self) = shift;
702            
703 5 50       6 foreach my $i (keys %{$self->{_hashes} || {}}) {
  5         35  
704 82   33     117 my $factory = $self->hit_factory || $self->throw("Tried to get a Hit, but it was a hash ref and we have no hit factory");
705 82         72 $self->{'_hits'}->[$i] = $factory->create_object(%{$self->{'_hits'}->[$i]});
  82         412  
706 82         300 delete $self->{_hashes}->{$i};
707             }
708            
709 5         16 my @hits = ();
710 5 50       17 if (ref $self->{'_hits'}) {
711 5         6 @hits = @{$self->{'_hits'}};
  5         17  
712             }
713 5         19 return @hits;
714             }
715              
716             =head2 algorithm_reference
717              
718             Title : algorithm_reference
719             Usage : $obj->algorithm_reference($newval)
720             Function:
721             Returns : string containing literature reference for the algorithm
722             Args : newvalue string (optional)
723             Comments: Formerly named program_reference(), which is still supported
724             for backwards compatibility.
725              
726             =cut
727              
728             sub algorithm_reference{
729 109     109 1 187 my ($self,$value) = @_;
730 109 100       253 if( defined $value) {
731 69         182 $self->{'algorithm_reference'} = $value;
732             }
733 109         354 return $self->{'algorithm_reference'};
734             }
735              
736             =head2 program_reference
737              
738             Title : program_reference
739             Usage : $obj->program_reference()
740             Function:
741             Returns : string containing literature reference for the algorithm
742             Args :
743             Comments: Deprecated - use algorithm_reference() instead.
744              
745             =cut
746              
747 5     5 1 18 sub program_reference { shift->algorithm_reference(@_); }
748              
749             =head2 rid
750              
751             Title : rid
752             Usage : $obj->rid($newval)
753             Function:
754             Returns : value of the BLAST Request ID (eg. RID: ZABJ4EA7014)
755             Args : newvalue (optional)
756             Comments: The default implementation in ResultI returns an empty string
757             rather than throwing a NotImplemented exception, since
758             the RID may not always be available and is not critical.
759             See: (1) https://www.ncbi.nlm.nih.gov/Class/MLACourse/Modules/BLAST/rid.html
760             (2) https://www.ncbi.nlm.nih.gov/staff/tao/URLAPI/new/node63.html
761             =cut
762              
763             sub rid{
764 14     14 1 27 my ($self,$value) = @_;
765 14 100       34 if( defined $value) {
766 9         18 $self->{'rid'} = $value;
767             }
768 14         39 return $self->{'rid'};
769             }
770            
771             =head2 no_hits_found
772              
773             See documentation in L
774              
775             =cut
776              
777             sub no_hits_found {
778 0     0 1   my $self = shift;
779              
780             # Watch the double negative!
781             # result = 0 means "yes hits were found"
782             # result = 1 means "no hits were found"
783              
784 0           return $self->{'_no_hits_found'};
785             }
786              
787              
788             =head2 set_no_hits_found
789              
790             See documentation in L
791              
792             =cut
793              
794             sub set_no_hits_found {
795 0     0 1   my $self = shift;
796 0           $self->{'_no_hits_found'} = 1;
797             }
798              
799              
800             =head2 to_string
801              
802             Title : to_string
803             Usage : print $blast->to_string;
804             Function: Returns a string representation for the Blast result.
805             Primarily intended for debugging purposes.
806             Example : see usage
807             Returns : A string of the form:
808             [GenericResult] query= db=
809             e.g.:
810             [GenericResult] BLASTP query=YEL060C vacuolar protease B, db=PDBUNIQ
811             Args : None
812              
813             =cut
814              
815             sub to_string {
816 0     0 1   my $self = shift;
817 0           my $str = ref($self) . ", algorithm= " . $self->algorithm . ", query=" . $self->query_name . " " . $self->query_description .", db=" . $self->database_name;
818 0           return $str;
819             }
820              
821             1;