File Coverage

Bio/SearchIO/SearchResultEventBuilder.pm
Criterion Covered Total %
statement 172 197 87.3
branch 59 90 65.5
condition 53 98 54.0
subroutine 21 22 95.4
pod 16 16 100.0
total 321 423 75.8


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::SearchIO::SearchResultEventBuilder
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::SearchIO::SearchResultEventBuilder - Event Handler for SearchIO events.
17              
18             =head1 SYNOPSIS
19              
20             # Do not use this object directly, this object is part of the SearchIO
21             # event based parsing system.
22              
23             =head1 DESCRIPTION
24              
25             This object handles Search Events generated by the SearchIO classes
26             and build appropriate Bio::Search::* objects from them.
27              
28             =head1 FEEDBACK
29              
30             =head2 Mailing Lists
31              
32             User feedback is an integral part of the evolution of this and other
33             Bioperl modules. Send your comments and suggestions preferably to
34             the Bioperl mailing list. Your participation is much appreciated.
35              
36             bioperl-l@bioperl.org - General discussion
37             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
38              
39             =head2 Support
40              
41             Please direct usage questions or support issues to the mailing list:
42              
43             I
44              
45             rather than to the module maintainer directly. Many experienced and
46             reponsive experts will be able look at the problem and quickly
47             address it. Please include a thorough description of the problem
48             with code and data examples if at all possible.
49              
50             =head2 Reporting Bugs
51              
52             Report bugs to the Bioperl bug tracking system to help us keep track
53             of the bugs and their resolution. Bug reports can be submitted via the
54             web:
55              
56             https://github.com/bioperl/bioperl-live/issues
57              
58             =head1 AUTHOR - Jason Stajich
59              
60             Email jason-at-bioperl.org
61              
62             =head1 CONTRIBUTORS
63              
64             Sendu Bala, bix@sendu.me.uk
65              
66             =head1 APPENDIX
67              
68             The rest of the documentation details each of the object methods.
69             Internal methods are usually preceded with a _
70              
71             =cut
72              
73              
74             # Let the code begin...
75              
76              
77             package Bio::SearchIO::SearchResultEventBuilder;
78              
79 30     30   198 use strict;
  30         55  
  30         761  
80              
81 30     30   7229 use Bio::Factory::ObjectFactory;
  30         85  
  30         943  
82              
83 30     30   255 use base qw(Bio::Root::Root Bio::SearchIO::EventHandlerI);
  30         54  
  30         8766  
84              
85 30         69395 use vars qw($DEFAULT_INCLUSION_THRESHOLD
86             $MAX_HSP_OVERLAP
87 30     30   192 );
  30         54  
88              
89             # e-value threshold for inclusion in the PSI-BLAST score matrix model (blastpgp)
90             # NOTE: Executing `blastpgp -` incorrectly reports that the default is 0.005.
91             # (version 2.2.2 [Jan-08-2002])
92             $DEFAULT_INCLUSION_THRESHOLD = 0.001;
93              
94             $MAX_HSP_OVERLAP = 2; # Used when tiling multiple HSPs.
95              
96             =head2 new
97              
98             Title : new
99             Usage : my $obj = Bio::SearchIO::SearchResultEventBuilder->new();
100             Function: Builds a new Bio::SearchIO::SearchResultEventBuilder object
101             Returns : Bio::SearchIO::SearchResultEventBuilder
102             Args : -hsp_factory => Bio::Factory::ObjectFactoryI
103             -hit_factory => Bio::Factory::ObjectFactoryI
104             -result_factory => Bio::Factory::ObjectFactoryI
105             -inclusion_threshold => e-value threshold for inclusion in the
106             PSI-BLAST score matrix model (blastpgp)
107             -signif => float or scientific notation number to be used
108             as a P- or Expect value cutoff
109             -score => integer or scientific notation number to be used
110             as a blast score value cutoff
111             -bits => integer or scientific notation number to be used
112             as a bit score value cutoff
113             -hit_filter => reference to a function to be used for
114             filtering hits based on arbitrary criteria.
115              
116             See L for more information
117              
118             =cut
119              
120             sub new {
121 293     293 1 935 my ($class,@args) = @_;
122 293         1047 my $self = $class->SUPER::new(@args);
123 293         1273 my ($resultF, $hitF, $hspF) =
124             $self->_rearrange([qw(RESULT_FACTORY
125             HIT_FACTORY
126             HSP_FACTORY)],@args);
127 293         1111 $self->_init_parse_params(@args);
128              
129 293   33     2074 $self->register_factory('result', $resultF ||
130             Bio::Factory::ObjectFactory->new(
131             -type => 'Bio::Search::Result::GenericResult',
132             -interface => 'Bio::Search::Result::ResultI'));
133              
134 293   33     1394 $self->register_factory('hit', $hitF ||
135             Bio::Factory::ObjectFactory->new(
136             -type => 'Bio::Search::Hit::GenericHit',
137             -interface => 'Bio::Search::Hit::HitI'));
138              
139 293   33     1472 $self->register_factory('hsp', $hspF ||
140             Bio::Factory::ObjectFactory->new(
141             -type => 'Bio::Search::HSP::GenericHSP',
142             -interface => 'Bio::Search::HSP::HSPI'));
143              
144 293         1642 return $self;
145             }
146              
147             # Initializes parameters used during parsing of reports.
148             sub _init_parse_params {
149              
150 385     385   920 my ($self, @args) = @_;
151             # -FILT_FUNC has been replaced by -HIT_FILTER.
152             # Leaving -FILT_FUNC in place for backward compatibility
153 385         1282 my($ithresh, $signif, $score, $bits, $hit_filter, $filt_func) =
154             $self->_rearrange([qw(INCLUSION_THRESHOLD SIGNIF SCORE BITS
155             HIT_FILTER FILT_FUNC
156             )], @args);
157              
158 385 50       1685 $self->inclusion_threshold( defined($ithresh) ? $ithresh : $DEFAULT_INCLUSION_THRESHOLD);
159 385   66     1235 my $hit_filt = $hit_filter || $filt_func;
160 385 100       823 defined $hit_filter && $self->hit_filter($hit_filt);
161 385 100       779 defined $signif && $self->max_significance($signif);
162 385 100       729 defined $score && $self->min_score($score);
163 385 100       970 defined $bits && $self->min_bits($bits);
164             }
165              
166             =head2 will_handle
167              
168             Title : will_handle
169             Usage : if( $handler->will_handle($event_type) ) { ... }
170             Function: Tests if this event builder knows how to process a specific event
171             Returns : boolean
172             Args : event type name
173              
174             =cut
175              
176             sub will_handle{
177 20958     20958 1 27616 my ($self,$type) = @_;
178             # these are the events we recognize
179 20958   66     66961 return ( $type eq 'hsp' || $type eq 'hit' || $type eq 'result' );
180             }
181              
182             =head2 SAX methods
183              
184             =cut
185              
186             =head2 start_result
187              
188             Title : start_result
189             Usage : $handler->start_result($resulttype)
190             Function: Begins a result event cycle
191             Returns : none
192             Args : Type of Report
193              
194             =cut
195              
196             sub start_result {
197 173     173 1 600 my ($self,$type) = @_;
198 173         412 $self->{'_resulttype'} = $type;
199 173         442 $self->{'_hits'} = [];
200 173         380 $self->{'_hsps'} = [];
201 173         372 $self->{'_hitcount'} = 0;
202 173         344 return;
203             }
204              
205             =head2 end_result
206              
207             Title : end_result
208             Usage : my @results = $parser->end_result
209             Function: Finishes a result handler cycle
210             Returns : A Bio::Search::Result::ResultI
211             Args : none
212              
213             =cut
214              
215             # this is overridden by IteratedSearchResultEventBuilder
216             # so keep that in mind when debugging
217              
218             sub end_result {
219 180     180 1 570 my ($self,$type,$data) = @_;
220              
221 180 50 33     693 if( defined $data->{'runid'} &&
222             $data->{'runid'} !~ /^\s+$/ ) {
223              
224 0 0       0 if( $data->{'runid'} !~ /^lcl\|/) {
225 0         0 $data->{"RESULT-query_name"} = $data->{'runid'};
226             } else {
227             ($data->{"RESULT-query_name"},
228             $data->{"RESULT-query_description"}) =
229 0         0 split(/\s+/,$data->{"RESULT-query_description"},2);
230             }
231              
232 0 0       0 if( my @a = split(/\|/,$data->{'RESULT-query_name'}) ) {
233 0         0 my $acc = pop @a ; # this is for accession |1234|gb|AAABB1.1|AAABB1
234             # this is for |123|gb|ABC1.1|
235 0 0 0     0 $acc = pop @a if( ! defined $acc || $acc =~ /^\s+$/);
236 0         0 $data->{"RESULT-query_accession"}= $acc;
237             }
238 0         0 delete $data->{'runid'};
239             }
240 1581         2163 my %args = map { my $v = $data->{$_}; s/RESULT//; ($_ => $v); }
  1581         2865  
  1581         3562  
241 180         358 grep { /^RESULT/ } keys %{$data};
  4400         6727  
  180         1015  
242              
243             $args{'-algorithm'} = uc( $args{'-algorithm_name'}
244 180   66     1160 || $data->{'RESULT-algorithm_name'}
245             || $type);
246             ($self->isa('Bio::SearchIO::IteratedSearchResultEventBuilder')) ?
247             ( $args{'-iterations'} = $self->{'_iterations'} )
248 180 100       1684 : ( $args{'-hits'} = $self->{'_hits'} );
249              
250 180         528 my $result = $self->factory('result')->create_object(%args);
251 180         1042 $result->hit_factory($self->factory('hit'));
252              
253             ($self->isa('Bio::SearchIO::IteratedSearchResultEventBuilder')) ?
254             ( $self->{'_iterations'} = [] )
255 180 100       1080 : ( $self->{'_hits'} = [] );
256              
257 180         1128 return $result;
258             }
259              
260             =head2 start_hsp
261              
262             Title : start_hsp
263             Usage : $handler->start_hsp($name,$data)
264             Function: Begins processing a HSP event
265             Returns : none
266             Args : type of element
267             associated data (hashref)
268              
269             =cut
270              
271             sub start_hsp {
272 7792     7792 1 18645 my ($self,@args) = @_;
273 7792         14737 return;
274             }
275              
276             =head2 end_hsp
277              
278             Title : end_hsp
279             Usage : $handler->end_hsp()
280             Function: Finish processing a HSP event
281             Returns : none
282             Args : type of event and associated hashref
283              
284              
285             =cut
286              
287             sub end_hsp {
288 7792     7792 1 14586 my ($self,$type,$data) = @_;
289              
290 7792 50 33     16041 if( defined $data->{'runid'} &&
291             $data->{'runid'} !~ /^\s+$/ ) {
292              
293 0 0       0 if( $data->{'runid'} !~ /^lcl\|/) {
294 0         0 $data->{"RESULT-query_name"}= $data->{'runid'};
295             } else {
296             ($data->{"RESULT-query_name"},
297             $data->{"RESULT-query_description"}) =
298 0         0 split(/\s+/,$data->{"RESULT-query_description"},2);
299             }
300              
301 0 0       0 if( my @a = split(/\|/,$data->{'RESULT-query_name'}) ) {
302 0         0 my $acc = pop @a ; # this is for accession |1234|gb|AAABB1.1|AAABB1
303             # this is for |123|gb|ABC1.1|
304 0 0 0     0 $acc = pop @a if( ! defined $acc || $acc =~ /^\s+$/);
305 0         0 $data->{"RESULT-query_accession"}= $acc;
306             }
307 0         0 delete $data->{'runid'};
308             }
309              
310             # this code is to deal with the fact that Blast XML data
311             # always has start < end and one has to infer strandedness
312             # from the frame which is a problem for the Search::HSP object
313             # which expect to be able to infer strand from the order of
314             # of the begin/end of the query and hit coordinates
315 7792 50 33     18196 if( defined $data->{'HSP-query_frame'} && # this is here to protect from undefs
      66        
316             (( $data->{'HSP-query_frame'} < 0 &&
317             $data->{'HSP-query_start'} < $data->{'HSP-query_end'} ) ||
318             $data->{'HSP-query_frame'} > 0 &&
319             ( $data->{'HSP-query_start'} > $data->{'HSP-query_end'} ) )
320             )
321             {
322             # swap
323             ($data->{'HSP-query_start'},
324             $data->{'HSP-query_end'}) = ($data->{'HSP-query_end'},
325 0         0 $data->{'HSP-query_start'});
326             }
327 7792 50 33     21199 if( defined $data->{'HSP-hit_frame'} && # this is here to protect from undefs
      66        
328             ((defined $data->{'HSP-hit_frame'} && $data->{'HSP-hit_frame'} < 0 &&
329             $data->{'HSP-hit_start'} < $data->{'HSP-hit_end'} ) ||
330             defined $data->{'HSP-hit_frame'} && $data->{'HSP-hit_frame'} > 0 &&
331             ( $data->{'HSP-hit_start'} > $data->{'HSP-hit_end'} ) )
332             )
333             {
334             # swap
335             ($data->{'HSP-hit_start'},
336             $data->{'HSP-hit_end'}) = ($data->{'HSP-hit_end'},
337 0         0 $data->{'HSP-hit_start'});
338             }
339 7792   100     26494 $data->{'HSP-query_frame'} ||= 0;
340 7792   100     22340 $data->{'HSP-hit_frame'} ||= 0;
341             # handle Blast 2.1.2 which did not support data member: hsp_align-len
342 7792   100     25840 $data->{'HSP-query_length'} ||= $data->{'RESULT-query_length'};
343 7792   100     23498 $data->{'HSP-hit_length'} ||= $data->{'HIT-length'};
344              
345             # If undefined lengths, calculate from alignment without gaps and separators
346 7792 100       13391 if (not defined $data->{'HSP-query_length'}) {
347 971 100       1729 if (my $hsp_qry_seq = $data->{'HSP-query_seq'}) {
348 126         1205 $hsp_qry_seq =~ s/[-\.]//g;
349 126         239 $data->{'HSP-query_length'} = length $hsp_qry_seq;
350             }
351             else {
352 845         1093 $data->{'HSP-query_length'} = 0;
353             }
354             }
355 7792 100       12527 if (not defined $data->{'HSP-hit_length'}) {
356 5678 100       9255 if (my $hsp_hit_seq = $data->{'HSP-hit_seq'}) {
357 131         886 $hsp_hit_seq =~ s/[-\.]//g;
358 131         290 $data->{'HSP-hit_length'} = length $hsp_hit_seq;
359             }
360             else {
361 5547         7163 $data->{'HSP-hit_length'} = 0;
362             }
363             }
364 7792   100     24556 $data->{'HSP-hsp_length'} ||= length ($data->{'HSP-homology_seq'} || '');
      100        
365              
366 131716         148040 my %args = map { my $v = $data->{$_}; s/HSP//; ($_ => $v) }
  131716         220853  
  131716         254316  
367 7792         8894 grep { /^HSP/ } keys %{$data};
  219628         344070  
  7792         42803  
368              
369             $args{'-algorithm'} = uc( $args{'-algorithm_name'} ||
370 7792   100     50129 $data->{'RESULT-algorithm_name'} || $type);
371             # copy this over from result
372 7792         14684 $args{'-query_name'} = $data->{'RESULT-query_name'};
373 7792         10541 $args{'-hit_name'} = $data->{'HIT-name'};
374 7792 50       8435 my ($rank) = scalar @{$self->{'_hsps'} || []} + 1;
  7792         18755  
375 7792         11700 $args{'-rank'} = $rank;
376              
377 7792         11474 $args{'-hit_desc'} = $data->{'HIT-description'};
378 7792         10648 $args{'-query_desc'} = $data->{'RESULT-query_description'};
379              
380 7792         11427 my $bits = $args{'-bits'};
381 7792         10077 my $hsp = \%args;
382 7792         9046 push @{$self->{'_hsps'}}, $hsp;
  7792         14429  
383              
384 7792         18277 return $hsp;
385             }
386              
387             =head2 start_hit
388              
389             Title : start_hit
390             Usage : $handler->start_hit()
391             Function: Starts a Hit event cycle
392             Returns : none
393             Args : type of event and associated hashref
394              
395             =cut
396              
397             sub start_hit{
398 8391     8391 1 21033 my ($self,$type) = @_;
399 8391         14400 $self->{'_hsps'} = [];
400 8391         14508 return;
401             }
402              
403             =head2 end_hit
404              
405             Title : end_hit
406             Usage : $handler->end_hit()
407             Function: Ends a Hit event cycle
408             Returns : Bio::Search::Hit::HitI object
409             Args : type of event and associated hashref
410              
411             =cut
412              
413             sub end_hit{
414 8391     8391 1 13285 my ($self,$type,$data) = @_;
415              
416             # Skip process unless there is HSP data or Hit Significance (e.g. a bl2seq with no similarity
417             # gives a hit with the subject, but shows a "no hits found" message instead
418             # of the alignment data and don't have a significance value).
419             # This way, we avoid false positives
420 8391         9299 my @hsp_data = grep { /^HSP/ } keys %{$data};
  142509         210252  
  8391         28383  
421 8391 50 66     28571 return unless (scalar @hsp_data > 0 or exists $data->{'HIT-significance'});
422              
423 8391         10256 my %args = map { my $v = $data->{$_}; s/HIT//; ($_ => $v); } grep { /^HIT/ } keys %{$data};
  34943         43596  
  34943         59428  
  34943         73299  
  142509         200708  
  8391         20408  
424              
425             # I hate special cases, but this is here because NCBI BLAST XML
426             # doesn't play nice and is undergoing mutation -jason
427 8391 50 33     36538 if(exists $args{'-name'} && $args{'-name'} =~ /BL_ORD_ID/ ) {
428 0         0 ($args{'-name'}, $args{'-description'}) = split(/\s+/,$args{'-description'},2);
429             }
430             $args{'-algorithm'} = uc( $args{'-algorithm_name'} ||
431 8391   100     31188 $data->{'RESULT-algorithm_name'} || $type);
432 8391         13036 $args{'-hsps'} = $self->{'_hsps'};
433 8391         13344 $args{'-query_len'} = $data->{'RESULT-query_length'};
434 8391         16220 $args{'-rank'} = $self->{'_hitcount'} + 1;
435 8391 100       15499 unless( defined $args{'-significance'} ) {
436 979 50 33     3181 if( defined $args{'-hsps'} &&
437             $args{'-hsps'}->[0] ) {
438             # use pvalue if present (WU-BLAST), otherwise evalue (NCBI BLAST)
439 979   100     3221 $args{'-significance'} = $args{'-hsps'}->[0]->{'-pvalue'} || $args{'-hsps'}->[0]->{'-evalue'};
440             }
441             }
442 8391         10343 my $hit = \%args;
443 8391         15887 $hit->{'-hsp_factory'} = $self->factory('hsp');
444 8391         19092 $self->_add_hit($hit);
445 8391         13850 $self->{'_hsps'} = [];
446 8391         19288 return $hit;
447             }
448              
449             # Title : _add_hit (private function for internal use only)
450             # Purpose : Applies hit filtering and store it if it passes filtering.
451             # Argument: Bio::Search::Hit::HitI object
452              
453             sub _add_hit {
454 5945     5945   8337 my ($self, $hit) = @_;
455 5945         7400 my $hit_signif = $hit->{-significance};
456              
457             # Test significance using custom function (if supplied)
458 5945         6300 my $add_hit = 1;
459              
460 5945         7480 my $hit_filter = $self->{'_hit_filter'};
461 5945 100       8171 if($hit_filter) {
462             # since &hit_filter is out of our control and would expect a HitI object,
463             # we're forced to make one for it
464 2         6 $hit = $self->factory('hit')->create_object(%{$hit});
  2         13  
465 2 100       10 $add_hit = 0 unless &$hit_filter($hit);
466             }
467             else {
468 5943 100       10684 if($self->{'_confirm_significance'}) {
469 55 100       229 $add_hit = 0 unless $hit_signif <= $self->{'_max_significance'};
470             }
471 5943 100       10851 if($self->{'_confirm_score'}) {
472 1215   33     2555 my $hit_score = $hit->{-score} || $hit->{-hsps}->[0]->{-score};
473 1215 100       4525 $add_hit = 0 unless $hit_score >= $self->{'_min_score'};
474             }
475 5943 100       9962 if($self->{'_confirm_bits'}) {
476 2   50     24 my $hit_bits = $hit->{-bits} || $hit->{-hsps}->[0]->{-bits} || 0;
477 2 50       8 $add_hit = 0 unless $hit_bits >= $self->{'_min_bits'};
478             }
479             }
480              
481 5945 100       9935 $add_hit && push @{$self->{'_hits'}}, $hit;;
  4681         7794  
482 5945         6647 $self->{'_hitcount'} = scalar @{$self->{'_hits'}};
  5945         9220  
483             }
484              
485             =head2 Factory methods
486              
487             =cut
488              
489             =head2 register_factory
490              
491             Title : register_factory
492             Usage : $handler->register_factory('TYPE',$factory);
493             Function: Register a specific factory for a object type class
494             Returns : none
495             Args : string representing the class and
496             Bio::Factory::ObjectFactoryI
497              
498             See L for more information
499              
500             =cut
501              
502             sub register_factory{
503 1502     1502 1 2683 my ($self, $type,$f) = @_;
504 1502 50 33     7712 if( ! defined $f || ! ref($f) ||
      33        
505             ! $f->isa('Bio::Factory::ObjectFactoryI') ) {
506 0         0 $self->throw("Cannot set factory to value $f".ref($f)."\n");
507             }
508 1502         4419 $self->{'_factories'}->{lc($type)} = $f;
509             }
510              
511             =head2 factory
512              
513             Title : factory
514             Usage : my $f = $handler->factory('TYPE');
515             Function: Retrieves the associated factory for requested 'TYPE'
516             Returns : a Bio::Factory::ObjectFactoryI
517             Throws : Bio::Root::BadParameter if none registered for the supplied type
518             Args : name of factory class to retrieve
519              
520             See L for more information
521              
522             =cut
523              
524             sub factory{
525 8943     8943 1 14116 my ($self,$type) = @_;
526 8943   33     29018 return $self->{'_factories'}->{lc($type)} ||
527             $self->throw(-class=>'Bio::Root::BadParameter',
528             -text=>"No factory registered for $type");
529             }
530              
531             =head2 inclusion_threshold
532              
533             See L.
534              
535             =cut
536              
537             sub inclusion_threshold {
538 487     487 1 801 my $self = shift;
539 487 100       1318 return $self->{'_inclusion_threshold'} = shift if @_;
540 102         251 return $self->{'_inclusion_threshold'};
541             }
542              
543             =head2 max_significance
544              
545             Usage : $obj->max_significance();
546             Purpose : Set/Get the P or Expect value used as significance screening cutoff.
547             This is the value of the -signif parameter supplied to new().
548             Hits with P or E-value at HIT level above this are skipped.
549             Returns : Scientific notation number with this format: 1.0e-05.
550             Argument : Number (sci notation, float, integer) (when setting)
551             Throws : Bio::Root::BadParameter exception if the supplied argument is
552             : not a valid number.
553             Comments : Screening of significant hits uses the data provided on the
554             : description line. For NCBI BLAST1 and WU-BLAST, this data
555             : is P-value. for NCBI BLAST2 it is an Expect value.
556              
557             =cut
558              
559             sub max_significance {
560 5     5 1 11 my $self = shift;
561 5 50       13 if (@_) {
562 5         9 my $sig = shift;
563 5 50 33     53 if( $sig =~ /[^\d.e-]/ or $sig <= 0) {
564 0         0 $self->throw(-class => 'Bio::Root::BadParameter',
565             -text => "Invalid significance value: $sig\n"
566             . "Must be a number greater than zero.",
567             -value => $sig);
568             }
569 5         13 $self->{'_confirm_significance'} = 1;
570 5         11 $self->{'_max_significance'} = $sig;
571             }
572 5         29 sprintf "%.1e", $self->{'_max_significance'};
573             }
574              
575              
576             =head2 signif
577              
578             Synonym for L
579              
580             =cut
581              
582 0     0 1 0 sub signif { shift->max_significance }
583              
584             =head2 min_score
585              
586             Usage : $obj->min_score();
587             Purpose : Gets the Blast score used as screening cutoff.
588             This is the value of the -score parameter supplied to new().
589             Hits with scores at HIT level below this are skipped.
590             Returns : Integer (or undef if not set)
591             Argument : Integer (when setting)
592             Throws : Bio::Root::BadParameter exception if the supplied argument is
593             : not a valid number.
594             Comments : Screening of significant hits uses the data provided on the
595             : description line.
596              
597             =cut
598              
599             sub min_score {
600 5     5 1 6 my $self = shift;
601 5 50       15 if (@_) {
602 5         8 my $score = shift;
603 5 50 33     28 if( $score =~ /[^\de+]/ or $score <= 0) {
604 0         0 $self->throw(-class => 'Bio::Root::BadParameter',
605             -text => "Invalid score value: $score\n"
606             . "Must be an integer greater than zero.",
607             -value => $score);
608             }
609 5         11 $self->{'_confirm_score'} = 1;
610 5         11 $self->{'_min_score'} = $score;
611             }
612 5         10 return $self->{'_min_score'};
613             }
614              
615             =head2 min_bits
616              
617             Usage : $obj->min_bits();
618             Purpose : Gets the Blast bit score used as screening cutoff.
619             This is the value of the -bits parameter supplied to new().
620             Hits with bits score at HIT level below this are skipped.
621             Returns : Integer (or undef if not set)
622             Argument : Integer (when setting)
623             Throws : Bio::Root::BadParameter exception if the supplied argument is
624             : not a valid number.
625             Comments : Screening of significant hits uses the data provided on the
626             : description line.
627              
628             =cut
629              
630             sub min_bits {
631 5     5 1 10 my $self = shift;
632 5 50       14 if (@_) {
633 5         9 my $bits = shift;
634 5 50 33     26 if( $bits =~ /[^\de+]/ or $bits <= 0) {
635 0         0 $self->throw(-class => 'Bio::Root::BadParameter',
636             -text => "Invalid bits value: $bits\n"
637             . "Must be an integer greater than zero.",
638             -value => $bits);
639             }
640 5         11 $self->{'_confirm_bits'} = 1;
641 5         12 $self->{'_min_bits'} = $bits;
642             }
643 5         12 return $self->{'_min_bits'};
644             }
645              
646             =head2 hit_filter
647              
648             Usage : $obj->hit_filter();
649             Purpose : Set/Get a function reference used for filtering out hits.
650             This is the value of the -hit_filter parameter supplied to new().
651             Hits that fail to pass the filter at HIT level are skipped.
652             Returns : Function ref (or undef if not set)
653             Argument : Function ref (when setting)
654             Throws : Bio::Root::BadParameter exception if the supplied argument is
655             : not a function reference.
656              
657             =cut
658              
659             sub hit_filter {
660 5     5 1 8 my $self = shift;
661 5 50       13 if (@_) {
662 5         8 my $func = shift;
663 5 50       14 if(not ref $func eq 'CODE') {
664 0         0 $self->throw(-class => 'Bio::Root::BadParameter',
665             -text => "Not a function reference: $func\n"
666             . "The -hit_filter parameter must be function reference.",
667             -value => $func);
668             }
669 5         12 $self->{'_hit_filter'} = $func;
670             }
671 5         8 return $self->{'_hit_filter'};
672             }
673              
674             1;