[Bioperl-l] SearchIO newbie question

Andrew Walsh walsh at cenix-bioscience.com
Tue May 24 11:07:00 EDT 2005


Hello Melodee,

I think what you want to do is to use one of the 
Bio::SearchIO::Writer::* modules.

This is a link to the HowTo describing how to use these:

http://bioperl.org/HOWTOs/SearchIO/outputting.html


Basically, you want to create a Bio::SearchIO::Writer::TextResultWriter 
object and use this to set the 'writer' attribute in the constructor for 
Bio::SearchIO.

Here is an example:

my $writer = new Bio::SearchIO::Writer::TextResultWriter();
my $out = new Bio::SearchIO(-writer => $writer,
           		    -file   => ">your_file.txt");

while ( my $blast = $in->next_result() )
     $out->write_result($blast);
}

That should do the trick.

Andrew

Melodee Patterson wrote:
> Hello,
> 
> I have written a number of perl and bioperl scripts to parse large phage BLASTx files, and now my boss wants me to remove some bacterial contaminations before I run my reports. I know how to use Bio::SearchIO to bring in the blast reports, and I know how to find the reports that I don't want using regular expressions, but what I can't figure out is how to write the good BLAST reports out to a file just as they are. I don't want to parse them at all, since my other scripts are expecting them as full BLAST reports and I'd rather not rewrite them.
> 
> If I can do this:
> 
> use Bio::SeqIO;
> $in = Bio::SeqIO->new('-file' => "AIZX_test.fas",
>                       '-format' => 'Fasta');
> $out = Bio::SeqIO->new('-file' => ">AIZX_test_out.txt",
>                       '-format' => 'Fasta');
> while ( my $seq = $in->next_seq() ) {$out->write_seq($seq); }
> 
> 
> why can't I do this:
> 
> use Bio::SearchIO;
> $in = Bio::SearchIO->new('-file' => "BLASTx_test.txt",
>                       '-format' => 'blast');
> $out = Bio::SearchIO->new('-file' => ">BLASTx_test_out.txt",
>                        '-format' => 'blast');
> while ( my $blast = $in->next_result() ) {$out->write_result($blast); }
> 
> Thanks - I appreciate any help I can get!
> 
> Melodee
> Lucigen Corp.
> 608-831-9011
> mpatterson at lucigen.com
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
> 


-- 
------------------------------------------------------------------
Andrew Walsh, M.Sc.
Bioinformatics Software Engineer
IT Unit
Cenix BioScience GmbH
Tatzberg 47
01307 Dresden
Germany
Tel. +49-351-4173 137
Fax  +49-351-4173 109

public key: http://www.cenix-bioscience.com/public_keys/walsh.gpg
------------------------------------------------------------------



More information about the Bioperl-l mailing list