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   211 use strict;
  27         44  
  27         792  
140              
141 27     27   8611 use Bio::Search::GenericStatistics;
  27         55  
  27         671  
142 27     27   8677 use Bio::Tools::Run::GenericParameters;
  27         63  
  27         741  
143              
144             # bug #1420
145             #use overload
146             # '""' => \&to_string;
147              
148 27     27   135 use base qw(Bio::Root::Root Bio::Search::Result::ResultI);
  27         41  
  27         10290  
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 1200 my($class,@args) = @_;
177              
178 242         1004 my $self = $class->SUPER::new(@args);
179              
180 242         702 $self->{'_hits'} = [];
181 242         547 $self->{'_hitindex'} = 0;
182 242         1811 $self->{'_statistics'} = Bio::Search::GenericStatistics->new();
183 242         1710 $self->{'_parameters'} = Bio::Tools::Run::GenericParameters->new();
184              
185 242         2359 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     1313 $algo_r ||= $prog_ref;
208 242 100       1083 defined $algo && $self->algorithm($algo);
209 242 100       952 defined $algo_v && $self->algorithm_version($algo_v);
210 242 100       815 defined $algo_r && $self->algorithm_reference($algo_r);
211              
212 242 100       658 defined $rid && $self->rid($rid);
213              
214 242 100       1034 defined $qname && $self->query_name($qname);
215 242 100       804 defined $qacc && $self->query_accession($qacc);
216 242 100       825 defined $qdesc && $self->query_description($qdesc);
217 242 100       852 defined $qlen && $self->query_length($qlen);
218 242 50       595 defined $qgi && $self->query_gi($qgi);
219 242 100       805 defined $dbname && $self->database_name($dbname);
220 242 100       699 defined $dblet && $self->database_letters($dblet);
221 242 100       725 defined $dbent && $self->database_entries($dbent);
222              
223 242 50       569 defined $hit_factory && $self->hit_factory($hit_factory);
224            
225 242 100       597 if( defined $params ) {
226 93 50       481 if( ref($params) !~ /hash/i ) {
227 0         0 $self->throw("Must specify a hash reference with the parameter '-parameters");
228             }
229 93         183 while( my ($key,$value) = each %{$params} ) {
  616         1586  
230 523         999 $self->{'_parameters'}->set_parameter($key => $value);
231             # $self->add_parameter($key,$value);
232             }
233             }
234 242 100       629 if( defined $stats ) {
235 93 50       374 if( ref($stats) !~ /hash/i ) {
236 0         0 $self->throw("Must specify a hash reference with the parameter '-statistics");
237             }
238 93         176 while( my ($key,$value) = each %{$stats} ) {
  2467         4845  
239 2374         3572 $self->{'_statistics'}->set_statistic($key => $value);
240             # $self->add_statistic($key,$value);
241             }
242             }
243              
244 242 100       612 if( defined $hits ) {
245 84 50       470 $self->throw("Must define arrayref of Hits when initializing a $class\n") unless ref($hits) =~ /array/i;
246              
247 84         217 foreach my $s ( @$hits ) {
248 4681         5566 $self->add_hit($s);
249             }
250             }
251 242         1035 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 13719 my ($self,$value) = @_;
266 369         713 my $previous = $self->{'_algorithm'};
267 369 100 66     1204 if( defined $value || ! defined $previous ) {
268 242 50       572 $value = $previous = '' unless defined $value;
269 242         569 $self->{'_algorithm'} = $value;
270             }
271 369         957 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 362 my ($self,$value) = @_;
286 186         338 my $previous = $self->{'_algorithm_version'};
287 186 100 66     703 if( defined $value || ! defined $previous ) {
288 136 50       373 $value = $previous = '' unless defined $value;
289 136         284 $self->{'_algorithm_version'} = $value;
290             }
291              
292 186         493 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 11628 my ($self,@args) = @_;
313 1198         2074 my $index = $self->_nexthitindex;
314 1198 50       1320 return if $index > scalar @{$self->{'_hits'}};
  1198         2289  
315            
316 1198         1668 my $hit = $self->{'_hits'}->[$index];
317 1198 100       1981 if (ref($hit) eq 'HASH') {
318 1175   33     2069 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         1303 $hit = $factory->create_object(%{$hit});
  1175         5252  
320 1175         3964 $self->{'_hits'}->[$index] = $hit;
321 1175         2718 delete $self->{_hashes}->{$index};
322             }
323 1198         2660 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 3799 my ($self,$value) = @_;
339 391         720 my $previous = $self->{'_queryname'};
340 391 100 100     1459 if( defined $value || ! defined $previous ) {
341 238 100       521 $value = $previous = '' unless defined $value;
342 238         566 $self->{'_queryname'} = $value;
343             }
344 391         1672 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 436 my ($self,$value) = @_;
359 193         425 my $previous = $self->{'_queryacc'};
360 193 100 100     691 if( defined $value || ! defined $previous ) {
361 176 100       434 $value = $previous = '' unless defined $value;
362 176         415 $self->{'_queryacc'} = $value;
363             }
364 193         383 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 25 my ($self,$value) = @_;
380 8 50       21 if( defined $value ) {
381 0         0 $self->{'_query_gi'} = $value;
382             } else {
383 8 50       23 $self->{'_query_gi'} = $self->query_name =~ m{^gi\|(\d+)} ? $1 : '';
384             }
385 8         36 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 816 my ($self,$value) = @_;
401 261         510 my $previous = $self->{'_querylength'};
402 261 100 100     895 if( defined $value || ! defined $previous ) {
403 149 100       324 $value = $previous = 0 unless defined $value;
404 149         358 $self->{'_querylength'} = $value;
405             }
406 261         657 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 509 my ($self,$value) = @_;
422 233         643 my $previous = $self->{'_querydesc'};
423 233 100 100     828 if( defined $value || ! defined $previous ) {
424 205 100       482 $value = $previous = '' unless defined $value;
425 205         618 $self->{'_querydesc'} = $value;
426             }
427 233         517 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 306 my ($self,$value) = @_;
444 140         263 my $previous = $self->{'_dbname'};
445 140 100 66     458 if( defined $value || ! defined $previous ) {
446 105 50       237 $value = $previous = '' unless defined $value;
447 105         227 $self->{'_dbname'} = $value;
448             }
449 140         354 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 242 my ($self,$value) = @_;
467 126         226 my $previous = $self->{'_dbletters'};
468 126 100 100     436 if( defined $value || ! defined $previous ) {
469 99 100       232 $value = $previous = '' unless defined $value;
470 99         199 $self->{'_dbletters'} = $value;
471             }
472 126         240 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 288 my ($self,$value) = @_;
489 124         249 my $previous = $self->{'_dbentries'};
490 124 100 100     439 if( defined $value || ! defined $previous ) {
491 99 100       212 $value = $previous = '' unless defined $value;
492 99         236 $self->{'_dbentries'} = $value;
493             }
494 124         312 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 161 my ($self,$name) = @_;
510 76         217 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 21 my ($self) = @_;
525 7         38 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 574 my ($self,$key) = @_;
542 305         803 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 21 my ($self) = @_;
557 7         37 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 5672 my ($self,$s) = @_;
576 4743 50 66     8134 if (ref($s) eq 'HASH' || $s->isa('Bio::Search::Hit::HitI') ) {
577 4743         4408 push @{$self->{'_hits'}}, $s;
  4743         6526  
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       6695 if (ref($s) eq 'HASH') {
584 4680         4505 $self->{_hashes}->{$#{$self->{'_hits'}}} = 1;
  4680         8716  
585             }
586 4743         4927 return scalar @{$self->{'_hits'}};
  4743         6883  
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 1830 my $self = shift;
601 1437 100       2323 if (@_) { $self->{_hit_factory} = shift }
  180         381  
602 1437   50     3413 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 13 my ($self) = @_;
618 5         15 $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   1579 my ($self,@args) = @_;
631 1198         1964 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 2097 my ($self) = shift;
682 32 50       117 if (not defined $self->{'_hits'}) {
683 0         0 $self->throw("Can't get Hits: data not collected.");
684             }
685 32         46 return scalar(@{$self->{'_hits'}});
  32         183  
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 13 my ($self) = shift;
702            
703 5 50       12 foreach my $i (keys %{$self->{_hashes} || {}}) {
  5         51  
704 82   33     223 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         115 $self->{'_hits'}->[$i] = $factory->create_object(%{$self->{'_hits'}->[$i]});
  82         547  
706 82         410 delete $self->{_hashes}->{$i};
707             }
708            
709 5         32 my @hits = ();
710 5 50       25 if (ref $self->{'_hits'}) {
711 5         15 @hits = @{$self->{'_hits'}};
  5         37  
712             }
713 5         39 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 301 my ($self,$value) = @_;
730 109 100       250 if( defined $value) {
731 69         184 $self->{'algorithm_reference'} = $value;
732             }
733 109         395 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 20 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 28 my ($self,$value) = @_;
765 14 100       36 if( defined $value) {
766 9         15 $self->{'rid'} = $value;
767             }
768 14         37 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;