++ed by:
17 non-PAUSE users
Author image Christopher Fields
and 1 contributors


Bio::Tools::Run::RemoteBlast - Object for remote execution of the NCBI Blast via HTTP


  #Remote-blast "factory object" creation and blast-parameter initialization

  use Bio::Tools::Run::RemoteBlast;
  use strict;
  my $prog = 'blastp';
  my $db   = 'swissprot';
  my $e_val= '1e-10';

  my @params = ( '-prog' => $prog,
         '-data' => $db,
         '-expect' => $e_val,
         '-readmethod' => 'SearchIO' );

  my $factory = Bio::Tools::Run::RemoteBlast->new(@params);

  #change a query paramter
  $Bio::Tools::Run::RemoteBlast::HEADER{'ENTREZ_QUERY'} = 'Homo sapiens [ORGN]';

  #change a retrieval parameter
  $Bio::Tools::Run::RemoteBlast::RETRIEVALHEADER{'DESCRIPTIONS'} = 1000;

  #remove a parameter
  delete $Bio::Tools::Run::RemoteBlast::HEADER{'FILTER'};

  #$v is just to turn on and off the messages
  my $v = 1;

  my $str = Bio::SeqIO->new(-file=>'amino.fa' , -format => 'fasta' );

  while (my $input = $str->next_seq()){
    #Blast a sequence against a database:

    #Alternatively, you could  pass in a file with many
    #sequences rather than loop through sequence one at a time
    #Remove the loop starting 'while (my $input = $str->next_seq())'
    #and swap the two lines below for an example of that.
    my $r = $factory->submit_blast($input);
    #my $r = $factory->submit_blast('amino.fa');

    print STDERR "waiting..." if( $v > 0 );
    while ( my @rids = $factory->each_rid ) {
      foreach my $rid ( @rids ) {
        my $rc = $factory->retrieve_blast($rid);
        if( !ref($rc) ) {
          if( $rc < 0 ) {
          print STDERR "." if ( $v > 0 );
          sleep 5;
        } else {
          my $result = $rc->next_result();
          #save the output
          my $filename = $result->query_name()."\.out";
          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";

  # This example shows how to change a CGI parameter:
  $Bio::Tools::Run::RemoteBlast::HEADER{'MATRIX_NAME'} = 'BLOSUM45';
  $Bio::Tools::Run::RemoteBlast::HEADER{'GAPCOSTS'} = '15 2';

  # And this is how to delete a CGI parameter:
  delete $Bio::Tools::Run::RemoteBlast::HEADER{'FILTER'};


Class for remote execution of the NCBI Blast via HTTP.

For a description of the many CGI parameters see: http://www.ncbi.nlm.nih.gov/BLAST/Doc/urlapi.html

Various additional options and input formats are available.


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:



Please do NOT contact Jason directly about this module. Please post to the bioperl mailing list (FEEDBACK). If you would like to be the official maintainer of this module, please volunteer on the list and we will make it official in this POD.

First written by Jason Stajich, many others have helped keep it running.


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Title   : retrieve_parameter
 Usage   : my $db = $self->retrieve_parameter
 Function: Get/Set the named parameter for the retrieve_blast operation.
 Returns : string
 Args    : $name : name of GET parameter
         $val : optional value to set the parameter to


 Title   : submit_parameter
 Usage   : my $db = $self->submit_parameter
 Function: Get/Set the named parameter for the submit_blast operation.
 Returns : string
 Args    : $name : name of PUT parameter
    $val : optional value to set the parameter to
 Title   : header
 Usage   : my $header = $self->header
 Function: Get HTTP header for blast query
 Returns : string
 Args    : none


 Title   : readmethod
 Usage   : my $readmethod = $self->readmethod
 Function: Get/Set the method to read the blast report
 Returns : string
 Args    : string [ blast, blasttable, xml ]


 Title   : program
 Usage   : my $prog = $self->program
 Function: Get/Set the program to run. Retained for backwards-compatibility.
 Returns : string
 Args    : string [ blastp, blastn, blastx, tblastn, tblastx ]


 Title   : database
 Usage   : my $db = $self->database
 Function: Get/Set the database to search. Retained for backwards-compatibility.
 Returns : string
 Args    : string [ swissprot, nr, nt, etc... ]


 Title   : expect
 Usage   : my $expect = $self->expect
 Function: Get/Set the E value cutoff. Retained for backwards-compatibility.
 Returns : string
 Args    : string [ '1e-4' ]


 Title   : ua
 Usage   : my $ua = $self->ua or
 Function: Get/Set a LWP::UserAgent for use
 Returns : reference to LWP::UserAgent Object
 Args    : none
 Comments: Will create a UserAgent if none has been requested before.


 Title   : proxy
 Usage   : $httpproxy = $db->proxy('http')  or
           $db->proxy(['http','ftp'], 'http://myproxy' )
 Function: Get/Set a proxy for use of proxy
 Returns : a string indicating the proxy
 Args    : $protocol : an array ref of the protocol(s) to set/get
           $proxyurl : url of the proxy to use for the specified protocol


 Title   : submit_blast
 Usage   : $self->submit_blast([$seq1,$seq2]);
 Function: Submit blast jobs to ncbi blast queue on sequence(s)
 Returns : Blast report object as defined by $self->readmethod
 Args    : input can be:
           * sequence object
           * array ref of sequence objects
           * filename of file containing fasta formatted sequences


 Title   : retrieve_blast
 Usage   : my $blastreport = $blastfactory->retrieve_blast($rid);
 Function: Attempts to retrieve a blast report from remote blast queue
 Returns : -1 on error,
           0 on 'job not finished',
           Bio::SearchIO object
 Args    : Remote Blast ID (RID)


 Title   : saveoutput
 Usage   : my $saveoutput = $self->save_output($filename)
 Function: Method to save the blast report
 Returns : 1 (throws error otherwise)
 Args    : string [rid, filename]


 Title   : set_url_base
 Usage   : $self->set_url_base($url)
 Function: Method to override the default NCBI BLAST database
 Returns : None
 Args    : string (database url like
 NOTE    : This is highly experimental; we cannot maintain support on
           databases other than the default NCBI database at this time


 Title   : get_url_base
 Usage   : my $url = $self->set_url_base
 Function: Get the current URL for BLAST database searching
 Returns : string (URL used for remote blast searches)
 Args    : None