3 # BioPerl module for bp_remote_blast.pl
5 # Revived by Evan Weaver for bioperl-1.5.1
8 # Copyright Jason Stajich, Evan Weaver
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs after the code
18 use Bio::Tools::Run::RemoteBlast;
22 $USAGE = "remote_blast.pl [-h] [-p prog] [-d db] [-e expect] [-mod
23 Blast] [-f seqformat] -z=\"entrez query\" -v 1 -t output_format -i
26 my ($prog, $db, $expect,$method) = ( 'blastp', 'nr', '10', 'Blast');
28 my ($sequencefile,$sequenceformat,$help, $entrez, $outputformat,
29 $verbose) = (undef, 'fasta',undef, undef, undef, 1);
31 &GetOptions('prog|p=s' => \$prog,
33 'expect|e=s' => \$expect,
34 'blsmod|module|method=s' => \$method,
35 'input|i=s' => \$sequencefile,
36 'format|f=s' => \$sequenceformat,
38 'entrez|z=s' => \$entrez,
39 'output_format|t=s' => \$outputformat,
40 'verbose|v=s' => \$verbose
48 if( !defined $prog ) {
49 die($USAGE . "\n\tMust specify a valid program name ([t]blast[pxn])\n");
52 die($USAGE . "\n\tMust specify a db to search\n");
54 if( !defined $sequencefile ) {
55 die($USAGE . "\n\tMust specify an input file\n");
58 my $blastfactory = new Bio::Tools::Run::RemoteBlast ('-prog' => $prog,
61 'readmethod' => $method,
66 print "Entrez query (submission side): $entrez\n";
68 #$Bio::Tools::Run::RemoteBlast::RETRIEVALHEADER{ FORMAT_ENTREZ_QUERY} = $entrez;
69 $Bio::Tools::Run::RemoteBlast::HEADER{ ENTREZ_QUERY } = $entrez;
72 print "Don't use output format type; it doesn't work.\n";
73 $Bio::Tools::Run::RemoteBlast::RETRIEVALHEADER{ FORMAT_TYPE } = $outputformat;
76 # submit_blast can only currenly handle fasta format files so I'll
77 # preprocess outside of the module but I'd rather be sure here
80 if( $sequenceformat !~ /fasta/ ) {
82 my $seqio = new Bio::SeqIO('-format' => $sequenceformat,
83 '-file' => $sequencefile );
84 while( my $seq = $seqio->next_seq() ) {
89 $input = $sequencefile;
92 my $r = $blastfactory->submit_blast($input);
93 #my $r = $factory->submit_blast(?amino.fa?);
95 print STDERR "waiting...\n" if( $verbose > 0 );
96 while ( my @rids = $blastfactory->each_rid ) {
97 foreach my $rid ( @rids ) {
98 my $rc = $blastfactory->retrieve_blast($rid);
101 $blastfactory->remove_rid($rid);
103 print STDERR " checking $rid\n" if ( $verbose > 0 );
106 my $result = $rc->next_result();
108 my $filename = $result->query_name()."\.out";
109 $blastfactory->save_output($filename);
110 $blastfactory->remove_rid($rid);
111 print "\nQuery Name: ", $result->query_name(), "\n";
112 while ( my $hit = $result->next_hit ) {
113 next unless ( $verbose > 0);
114 print "\thit name is ", $hit->name, "\n";
115 while( my $hsp = $hit->next_hsp ) {
116 print "\t\tscore is ", $hsp->score, "\n";
121 print STDERR scalar(@rids) . " left\n";
128 # BioPerl module for bp_remote_blast.pl
130 # Cared for by Jason Stajich <jason-at-bioperl-dot-org>
132 # Copyright Jason Stajich
134 # You may distribute this module under the same terms as perl itself
136 # POD documentation - main docs before the code
140 bp_remote_blast.pl - script for submitting jobs to a remote blast server
141 (ncbi blast queue at this time)
145 % bp_remote_blast.pl -p blastp -d ecoli -e 1e-5 -i myseqs.fa
149 This module will run a remote blast on a set of sequences by
150 submitting them to the NCBI blast queue and printing the output of the
157 User feedback is an integral part of the evolution of this and other
158 Bioperl modules. Send your comments and suggestions preferably to
159 the Bioperl mailing list. Your participation is much appreciated.
161 bioperl-l@bioperl.org - General discussion
162 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
164 =head2 Reporting Bugs
166 Report bugs to the Bioperl bug tracking system to help us keep track
167 the bugs and their resolution. Bug reports can be submitted via the
170 https://github.com/bioperl/bioperl-live/issues
172 =head1 AUTHOR - Jason Stajich
174 Email jason-at-bioperl-dot-org