[Bioperl-l] Remote Blast and Report
Smithies, Russell
Russell.Smithies at agresearch.co.nz
Sun Mar 1 23:06:22 UTC 2009
Works fine for me using the code below.
Took about 30 seconds to return a result.
==============================================
#!perl -w
use Bio::Tools::Run::RemoteBlast;
use Bio::SearchIO;
use Data::Dumper;
#Here i set the parameters for blast
$prog = "tblastx";
$db = "nr";
$e_val = "1e-10";
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 balst.
$infile = 'infile.fasta';
$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";
$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";
}
}
}
}
}
=================================================================
> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Ocar Campos
> Sent: Friday, 27 February 2009 9:29 a.m.
> To: Scott Markel
> Cc: Bioperl Mailing List.
> Subject: Re: [Bioperl-l] Remote Blast and Report
>
> Hello,
>
> I was reading the documentation, and I tried some new code, but when
> retrieving I get an error, this is the error: Can't call method "query_name"
> on an undefined value at ./aer2.pl line 44, <GEN4> line 185. I'm working
> with only one sequence first, but then I am suppose to work with more than
> 50 sequences. Here is my code, that looks quite much as the one in the
> documentation and some examples I found. Any idea or help that you could
> give me please?
>
> use Bio::Tools::Run::RemoteBlast;
> use Bio::SearchIO;
>
> #Here i set the parameters for blast
> $prog = "tblastx";
> $db = "nr";
> $e_val = "1e-10";
> $remoteBlast = Bio::Tools::Run::RemoteBlast->new(-prog => $prog,
> -data => $db,
> -expect => $e_val
> -readmethod => 'txt'
> );
>
> #Select the file and make the balst.
> $infile = infile.fasta';
> $r = $remoteBlast->submit_blast($infile);
>
> #Here i was suppose to get the blast report.
> while (@reqIDs = $remoteBlast->each_rid )
> {
> print STDERR join(" ", "\nINFO RIDs: ", @reqIDs), "\n";
>
> foreach $reqID (@reqIDs)
> {
> $rc = $remoteBlast->retrieve_blast($reqID); #With this I should get the
> report.
> if( !ref($rc) )
> {
> if( $rc < 0 ) { #If there's no hits.
> $remoteBlast->remove_rid($rid);
> }
> print STDERR "." if ( $v > 0 );
> sleep 5;
> }
> else
> {
> $result = $rc->next_result();
> $filename = $result->query_name()."\.out"; #this should save the
> report, but here i get error.
> $remoteBlast->save_output($filename);
> $remoteBlast->remove_rid($rid);
> print "\nQuery Name: ", $result->query_name(), "\n";
> while ( $hit = $result->next_hit )
> {
> next unless ( $v > 0);
> print "\thit name is ", $hit->name, "\n";
> while( $hsp = $hit->next_hsp )
> {
> print "\t\tscore is ", $hsp->score, "\n";
> }
> }
> }
>
>
> }
>
> }
>
>
> 2009/2/25 Scott Markel <SMarkel at accelrys.com>
>
> > O'car,
> >
> > There's a polling mechanism you need to use. See the example in the
> > Bio::Tools::Run::RemoteBlast module. Start looking around line 60.
> >
> > Scott
> >
> > Scott Markel, Ph.D.
> > Principal Bioinformatics Architect email: smarkel at accelrys.com
> > Accelrys (SciTegic R&D) mobile: +1 858 205 3653
> > 10188 Telesis Court, Suite 100 voice: +1 858 799 5603
> > San Diego, CA 92121 fax: +1 858 799 5222
> > USA web: http://www.accelrys.com
> >
> > http://www.linkedin.com/in/smarkel
> > Vice President, Board of Directors:
> > International Society for Computational Biology
> > Co-chair: ISCB Publications Committee
> > Associate Editor: PLoS Computational Biology
> > Editorial Board: Briefings in Bioinformatics
> >
> >
> > > -----Original Message-----
> > > From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> > > bounces at lists.open-bio.org] On Behalf Of Ocar Campos
> > > Sent: Wednesday, 25 February 2009 4:04 PM
> > > To: Bioperl Mailing List.
> > > Subject: [Bioperl-l] Remote Blast and Report
> > >
> > > Hello:
> > >
> > > I'm working in a script to remote blast a file with some sequences, I
> > > already got the part of sending the query to blast, but I do not get the
> > > idea of how retrieve a txt report, I mean, like the one you get by
> > running
> > > a
> > > blast via web and you can read in a plane text editor.
> > >
> > > This is what I've done so far:
> > >
> > >
> > > use Bio::Tools::Run::RemoteBlast;
> > > use Bio::SearchIO;
> > >
> > > $prog = "tblastx";
> > > $db = "nr";
> > > $e_val = "1e-10";
> > > $remoteBlast = Bio::Tools::Run::RemoteBlast->new(-prog => $prog,
> > > -data => $db,
> > > -expect => $e_val
> > > -readmethod => 'Blast');
> > >
> > > #I select the file to make que query and do the blast.
> > > $infile = 'file.input.fasta';
> > > $r = $remoteBlast->submit_blast($infile);
> > >
> > > #this should be the report i get.
> > > $outfile = 'got.output';
> > >
> > > further than this I've tried some things but none of them work, anybody
> > > who
> > > could give an idea of how retrieving the plane text reports please?
> > >
> > > Cheers.
> > >
> > > O'car
> > > _______________________________________________
> > > Bioperl-l mailing list
> > > Bioperl-l at lists.open-bio.org
> > > http://lists.open-bio.org/mailman/listinfo/bioperl-l
> >
>
>
>
> --
> ...the pain is momentary, the glory is forever...
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================
More information about the Bioperl-l
mailing list