[Bioperl-l] filtering output from HTMLResultWriter
Charles Hauser
chauser at duke.edu
Wed Jul 30 12:58:05 EDT 2003
Thanks Jason for the tip on passing in functions.
One follow up question.
I'd like to not write out any $result where either result_filter or
hsp_filter returned 0.
Setting a variable (fail) within the subs has not worked (not visible to
script?).
Suggestions?
C
while( my $result = $in->next_result ) {
$writer->filter('result'=> \&result_filter );
while( my $hit = $result->next_hit ) {
while( my $hsp = $hit->next_hsp ) {
$writer->filter('hsp'=> \&hsp_filter );
my $out = new Bio::SearchIO(-writer => $writer);
$out->write_result($result); <---ONLY IF ALL FILTERS PASSED;
}
}
}
sub result_filter {
my $result = shift;
return 0 if $result->num_hits =='0';
return 1;
}
sub hsp_filter {
my $hsp = shift;
return 0 if $hsp->length < $MinLen || $hsp->percent_identity <
$MinPID;
return 1;
}
More information about the Bioperl-l
mailing list