[Bioperl-l] Output of a BLAST parse to text file
Frank Schwach
fs5 at sanger.ac.uk
Mon Apr 11 14:31:27 UTC 2011
Hi Tiago,
In the terminal where you run your script (let's say it's called
my_blast_parse.pl), you can run it like so:
my_blast_parse.pl [PARAMETERS] > my_outfile.txt
The ">" will redirect the output to a file calles my_outfile.txt.
To make the output tab-delimited, you will want to play with the print
statement in the script. try this for a start (the "\t" inserts tabs):
print
$result->query_name."\t".$hit->name."\t".$hsp->length('total')."\t".
$hsp->percent_identity, "\n";
Good luck!
Frank
On Sun, 2011-04-10 at 15:56 -0700, T.Hori wrote:
> Hi Guys,
>
> I am really new to BioPerl, so this may be a stuoid question. Let's
> say I use the example from the BioPerl.org:
>
> use strict;
> use Bio::SearchIO;
> my $in = new Bio::SearchIO(-format => 'blast',
> -file => 'report.bls');
> while( my $result = $in->next_result ) {
> ## $result is a Bio::Search::Result::ResultI compliant object
> while( my $hit = $result->next_hit ) {
> ## $hit is a Bio::Search::Hit::HitI compliant object
> while( my $hsp = $hit->next_hsp ) {
> ## $hsp is a Bio::Search::HSP::HSPI compliant object
> if( $hsp->length('total') > 50 ) {
> if ( $hsp->percent_identity >= 75 ) {
> print "Query=", $result->query_name,
> " Hit=", $hit->name,
> " Length=", $hsp->length('total'),
> " Percent_id=", $hsp->percent_identity, "\n";
> }
> }
> }
> }
> }
>
> That gives me several hits as results on the standard output. I am
> starting to learn BioPerl for what I think is a dauting task. I have a
> colletion of 20K ESTs and I have to find the best Human hit for
> everyone of those sequences. So I am starting by learning how to parse
> BLAST results. I was wondering how I would go about having the output
> of the parse go to tab-delimeted text file instead of the standard
> output.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Tiago
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
More information about the Bioperl-l
mailing list