[Bioperl-l] problem with Bio::SearchIO::Writer

lidaof lidaof at gmail.com
Thu Jan 11 20:24:04 EST 2007


Hi Dave,

Thank you for the patience on my problem
and now i have some understanding on that issue
Thank you!
my last mail alse have "  bcc bioperl-l at lists.open-bio.org"
and i have joined in this great list:)

Li

On 1/12/07, David Messina <dmessina at wustl.edu> wrote:
>
> Hi Li,
>
> Please reply also to the list so that the whole thread can be archived.
>
>
> I dug a little deeper into the Bio::SearchIO::Writer::TextResultWriter
> documentation and found (in the description section) that you can pass a
> subroutine to do your filtering. So your code can be shortened to:
>
>
> #!/usr/bin/perl -w
>
> use strict;
> use warnings;
> use Bio::SearchIO;
> use Bio::SearchIO::Writer::TextResultWriter;
>
> my $usage = "
> signifablast - filter blast reports for significance and write out a new
> report
>
> Usage: signifablast <file of blast report(s)>
> ";
> @ARGV == 1 or die $usage;
>
> # create a SearchIO object for reading in the file of blast report(s)
> my $in = Bio::SearchIO->new( -format => 'blast', -file => "$ARGV[0]" );
>
> # create a TextResultWriter object
> my $writer = Bio::SearchIO::Writer::TextResultWriter->new(
>     -filters => { 'HIT' => \&hit_filter } );
>
> # create a SearchIO object to store our filtered hits and write them to
> 'out'
> my $out = Bio::SearchIO->new( -writer => $writer, -file => '>out' );
>
> # write out our new (text) blast report
> $out->write_result($in->next_result);
>
>
>
> # E-value filter
> sub hit_filter {
>     my $hit = shift;
>
>     # set E value cutoff
>     my $e = 1e-10;
>
>     # &hit_filter must return true to keep the hit and false to discard
> the hit
>     return $hit->significance < $e;
> }
>
>
>
>
>
>
> Dave
>
>
>
>
>
>  On Jan 11, 2007, at 6:50 AM, lidaof wrote:
>
> Hi,Dave and Chris,
>
> sorry for disturbing again
> in the code i paste below:
>
> #!/usr/bin/perl -w
>
> use strict;
> use warnings;
> use Bio::SearchIO;
> #use Bio::SearchIO::Writer::TextResultWriter;
>
> my $in = new Bio::SearchIO (-format => 'blast', -file => "$ARGV[0]");
>
> $cutoff = 1e-10;
> open OP,">out";
> while(my $result = $in->next_result){
> my $resultname = $result->query_name();
> while(my $hit = $result->next_hit){
> my $name = $hit->name();
> my $e = $hit->significance();
> if($e < $cutoff){
> print OP "$resultname\t$name\t$e\n";
> next;
> }
> }
> }
>
> i use a filehandle "OP" for file output
> i want to use  Bio::SearchIO::Writer::TextResultWriter but actually i
> didn't use it
> that is the place you are not sure in your last mail
> and i will spend some time on reading the website of bioperl and this
> mailing list
>
> Thanks for your kindness:)
>
> Li
>
>
>
>



-- 
Li


More information about the Bioperl-l mailing list