[Bioperl-l] How to get Remote BLAST results in a single out

José Luis Lavín jluis.lavin at unavarra.es
Wed Nov 16 18:31:46 UTC 2011


Thank you for your answer Jason,

While answering you I figured out how to do it...sometimes you need other
people's point of view to see the light.

As you pointed out:

"what is complicaticated is the file name right now is based on the query
name."

that's what I expected that could have an easy fix, the issue about the
dependency between the outfile name and the query name, this is why I
couldn't figure out how to change the name of the output .

While reading the code to answer you, I came across the solution.

I was persistent on doing it this way because I need to run BLAST remotely
on my CGI, that's why I didn't pay attention to all the other options you
suggested. Thank you all for your sugestions anyway.

;)

Best wishes

JL


El 16 de noviembre de 2011 18:03, Jason Stajich <jason at bioperl.org>escribió:

> the answer to your question is to move the line that opens a file to
> outside the loop. what is complicaticated is the file name right now is
> based on the query name. so you need to think how you want to name the
> file. Since this isn't obvious to you, then I think we are suggesting you
> probably need to understand programming more, and it might just be easier
> to use the tools as we have suggested rather than teaching you to modify
> what is just an example code.  our suggestions are based on the way we'd
> solve the problem so maybe you have other reasons for the direction you
> want to take.
>
> I also think it is not efficient or logical to run
> remote blast through the web protocol simply to write it back out with
> bioperl since that has to parse it in and then write it out -- why not just
> run the program that generates the output directly from NCBI. Or run BLAST
> locally for likely more efficient running.
>
>  Finally the bioperl writer may not 100% reproduce the blast output so if
> you are planning on further parsing the output that comes out from this
> script, it really doesn't seem like a good idea to launder it through
> bioperl parser first.
>
>
>
> 2011/11/14 José Luis Lavín <jluis.lavin at unavarra.es>
>
>> Thank you very much for your answers, but due to them, I'm afraid I didn't
>> explained myself good enough.
>>
>>  I'm not looking for another tool to perform a BLAST task. I was just
>> wondering if there was a way to simply change the way the module writes
>> the
>> outputs, so that I can get multiple searches in a single report file
>> instead of having a report for each BLAST search.
>>
>> Maybe there's some issue I ignore, that makes you recommend the use of
>> other tools instead of the Bioperl Remote BLAST module...it would be
>> appreciated if you let me know about that (NCBI server problems with
>> web-services or so)...
>>
>> Thank you for your answers anyway
>>
>> Best wishes
>>
>> 2011/11/14 Fields, Christopher J <cjfields at illinois.edu>
>>
>> > Re: a BLAST+ equivalent for blastcl3, I believe there is an option for
>> the
>> > various 'blast*' indicating the search is to use a remote database.  I
>> > haven't used it, though...
>> >
>> > chris
>> >
>> > On Nov 14, 2011, at 8:07 AM, Jason Stajich wrote:
>> >
>> > > Please keep this on list discussions
>> > >
>> > > Sent from my iPhone-please excuse typos
>> > >
>> > > --
>> > > Jason Stajich
>> > >
>> > > Begin forwarded message:
>> > >
>> > >> From: José Luis Lavín <jluis.lavin at unavarra.es>
>> > >> Date: November 14, 2011 8:04:25 AM EST
>> > >> To: Jason Stajich <jason.stajich at gmail.com>
>> > >> Subject: Re: [Bioperl-l] Fwd: How to get Remote BLAST results in a
>> > single out
>> > >>
>> > >> Hello Jason,
>> > >>
>> > >> As answering your question:
>> > >>
>> > >> " If you want to do this within this code I guess the question is
>> what
>> > format you want the data in - a BLAST report or something more like a
>> > table?"
>> > >>
>> > >> A concatenation of BLAST (default format) reports should be OK,
>> since I
>> > have a script to parse that kind of results. Anyway formats 1 or 2 will
>> > also do the trick.
>> > >> I'll be happy to get assistance  on how to change the OUTFILE from "a
>> > query a report" to "all queries in the same report", because I don't
>> seem
>> > to be able to do it myself after reading the module documentation.
>> > >>
>> > >> Thanks in advance
>> > >>
>> > >> El 14 de noviembre de 2011 12:59, Jason Stajich <
>> > jason.stajich at gmail.com> escribió:
>> > >> if you want to do a bunch of BLASTs remotely on the cmdline you
>> should
>> > also just use the NCBI's blastcl3 tool (not sure if there is a BLAST+
>> > equivalent). This might be faster to do and easier since you need to
>> learn
>> > the programming part too.
>> > >>
>> > >> If you want to do this within this code I guess the question is what
>> > format you want the data in - a BLAST report or something more like a
>> table?
>> > >>
>> > >> On Nov 14, 2011, at 6:14 AM, José Luis Lavín wrote:
>> > >>
>> > >>> Hello everybody,
>> > >>>
>> > >>> I've been using  "Bio::Tools::Run::RemoteBlast" for a time and it
>> has
>> > >>> worked fine for me. Now I need to perform a multiple BLAST search,
>> but
>> > this
>> > >>> time I'd just like to get all the BLAST results in a single out file
>> > >>> instead of having each sequence's report written individually. I've
>> > read
>> > >>> the documentation of the module, but due to my short
>> > >>> experience/understanding on complex modules as this one seems to be
>> I
>> > can't
>> > >>> figure out where to change the script to achieve my previously
>> > mentioned
>> > >>> aim.
>> > >>> Here I post the script I've been using (it's basically the one
>> posted
>> > on
>> > >>> the module cookbook).
>> > >>>
>> > >>> #!/c:/Perl -w
>> > >>> use Bio::Tools::Run::RemoteBlast;
>> > >>> use Bio::SearchIO;
>> > >>> use Data::Dumper;
>> > >>>
>> > >>> #Here i set the parameters for blast
>> > >>> print "Enter your BLAST choice (blastn, blastp, blastx, tblastn,
>> > >>> tblastx):\n";
>> > >>> my $blst = <STDIN>;
>> > >>> my $prog = "$blst";
>> > >>> print "Enter a database to search (nr, refseq_protein, swissprot,
>> pat,
>> > pdb,
>> > >>> env_nr):\n";
>> > >>> my $dtb = <STDIN>;
>> > >>> $db = "$dtb";
>> > >>> print "Enter your cutt off score (1e-n):\n";
>> > >>> my $cut = <STDIN>;
>> > >>> my $e_val = "$cut";
>> > >>>
>> > >>> my @params = ( '-prog' => $prog,
>> > >>>        '-data' => $db,
>> > >>>        '-expect' => $e_val,
>> > >>>        '-readmethod' => 'SearchIO' );
>> > >>>
>> > >>> my $remoteBlast = Bio::Tools::Run::RemoteBlast->new(@params);
>> > >>>
>> > >>>
>> > >>> #Select the file and make the blast.
>> > >>> print "Enter your FASTA file:\n";
>> > >>> chomp(my $infile = <STDIN>);
>> > >>> my $r = $remoteBlast->submit_blast($infile);
>> > >>> my $v = 1;
>> > >>>
>> > >>>   print STDERR "waiting..." if( $v > 0 );  ########  WAIT FOR THE
>> > RESULTS
>> > >>> TO RETURN!!!!!
>> > >>>   while ( my @rids = $remoteBlast->each_rid ) {
>> > >>>     foreach my $rid ( @rids ) {
>> > >>>       my $rc = $remoteBlast->retrieve_blast($rid);
>> > >>>       if( !ref($rc) ) {
>> > >>>         if( $rc < 0 ) {
>> > >>>           $remoteBlast->remove_rid($rid);
>> > >>>         }
>> > >>>         print STDERR "." if ( $v > 0 );
>> > >>>         sleep 5;
>> > >>>       } else {
>> > >>>         my $result = $rc->next_result();
>> > >>>         #save the output
>> > >>>         my $filename =
>> > >>> $result->query_name()."\.out";##################open SALIDA,
>> > >>> '>>'."$^T"."Report"."\.out";
>> > >>>         $remoteBlast->save_output($filename);#############
>> > >>>         $remoteBlast->remove_rid($rid);
>> > >>>         print "\nQuery Name: ", $result->query_name(), "\n";
>> > >>>         while ( my $hit = $result->next_hit ) {
>> > >>>           next unless ( $v > 0);
>> > >>>           print "\thit name is ", $hit->name, "\n";
>> > >>>           while( my $hsp = $hit->next_hsp ) {
>> > >>>             print "\t\tscore is ", $hsp->score, "\n";
>> > >>>           }
>> > >>>         }
>> > >>>       }
>> > >>>     }
>> > >>>   }
>> > >>>
>> > >>>
>> > >>> May any of you please explain me how to solve my question?
>> > >>>
>> > >>> Thanks in advence
>> > >>>
>> > >>> With best wishes
>> > >>>
>> > >>> --
>> > >>> --
>> > >>> Dr. José Luis Lavín Trueba
>> > >>>
>> > >>> Dpto. de Producción Agraria
>> > >>> Grupo de Genética y Microbiología
>> > >>> Universidad Pública de Navarra
>> > >>> 31006 Pamplona
>> > >>> Navarra
>> > >>> SPAIN
>> > >>>
>> > >>>
>> > >>>
>> > >>> --
>> > >>> --
>> > >>> Dr. José Luis Lavín Trueba
>> > >>>
>> > >>> Dpto. de Producción Agraria
>> > >>> Grupo de Genética y Microbiología
>> > >>> Universidad Pública de Navarra
>> > >>> 31006 Pamplona
>> > >>> Navarra
>> > >>> SPAIN
>> > >>>
>> > >>> _______________________________________________
>> > >>> Bioperl-l mailing list
>> > >>> Bioperl-l at lists.open-bio.org
>> > >>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>> > >>
>> > >>
>> > >> _______________________________________________
>> > >> Bioperl-l mailing list
>> > >> Bioperl-l at lists.open-bio.org
>> > >> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>> > >>
>> > >>
>> > >>
>> > >> --
>> > >> --
>> > >> Dr. José Luis Lavín Trueba
>> > >>
>> > >> Dpto. de Producción Agraria
>> > >> Grupo de Genética y Microbiología
>> > >> Universidad Pública de Navarra
>> > >> 31006 Pamplona
>> > >> Navarra
>> > >> SPAIN
>> > >
>> > > _______________________________________________
>> > > Bioperl-l mailing list
>> > > Bioperl-l at lists.open-bio.org
>> > > http://lists.open-bio.org/mailman/listinfo/bioperl-l
>> >
>> >
>> > _______________________________________________
>> > Bioperl-l mailing list
>> > Bioperl-l at lists.open-bio.org
>> > http://lists.open-bio.org/mailman/listinfo/bioperl-l
>> >
>>
>>
>>
>> --
>> --
>> Dr. José Luis Lavín Trueba
>>
>> Dpto. de Producción Agraria
>> Grupo de Genética y Microbiología
>> Universidad Pública de Navarra
>> 31006 Pamplona
>> Navarra
>> SPAIN
>>
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>
>
>


-- 
-- 
Dr. José Luis Lavín Trueba

Dpto. de Producción Agraria
Grupo de Genética y Microbiología
Universidad Pública de Navarra
31006 Pamplona
Navarra
SPAIN




More information about the Bioperl-l mailing list