Class Bio::Blast
In: lib/bio/appl/bl2seq/report.rb  (CVS)
lib/bio/appl/blast.rb  (CVS)
lib/bio/appl/blast/format0.rb  (CVS)
lib/bio/appl/blast/format8.rb  (CVS)
lib/bio/appl/blast/report.rb  (CVS)
lib/bio/appl/blast/rexml.rb  (CVS)
lib/bio/appl/blast/wublast.rb  (CVS)
lib/bio/appl/blast/xmlparser.rb  (CVS)
lib/bio/io/fastacmd.rb  (CVS)
Parent: Object

Description

The Bio::Blast class contains methods for running local or remote BLAST searches, as well as for parsing of the output of such BLASTs (i.e. the BLAST reports). For more information on similarity searches and the BLAST program, see www.ncbi.nlm.nih.gov/Education/BLASTinfo/similarity.html.

Usage

  require 'bio'

  # To run an actual BLAST analysis:
  #   1. create a BLAST factory
  remote_blast_factory = Bio::Blast.remote('blastp', 'SWISS',
                                           '-e 0.0001', 'genomenet')
  #or:
  local_blast_factory = Bio::Blast.local('blastn','/path/to/db')

  #   2. run the actual BLAST by querying the factory
  report = remote_blast_factory.query(sequence_text)

  # Then, to parse the report, see Bio::Blast::Report

Available databases for Bio::Blast.remote

 ----------+-------+---------------------------------------------------
  program  | query | db (supported in GenomeNet)
 ----------+-------+---------------------------------------------------
  blastp   | AA    | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd,
 ----------+-------+ pir, prf, pdbstr
  blastx   | NA    |
 ----------+-------+---------------------------------------------------
  blastn   | NA    | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss,
 ----------+-------+ htgs, dbsts, embl-nonst, embnonst-upd, epd,
  tblastn  | AA    | genes-nt, genome, vgenes.nuc
 ----------+-------+---------------------------------------------------

See also

References

Methods

local   new   option   option=   query   remote   reports  

Classes and Modules

Class Bio::Blast::Bl2seq
Class Bio::Blast::Fastacmd
Class Bio::Blast::Report

Attributes

blastall  [RW]  Full path for blastall. (default: ‘blastall’).
db  [RW]  Database name (_-d_ option for blastall)
filter  [RW]  Filter option for blastall -F (T or F).
format  [R]  Output report format for blastall -m

0, pairwise; 1; 2; 3; 4; 5; 6; 7, XML Blast outpu;, 8, tabular; 9, tabular with comment lines; 10, ASN text; 11, ASN binery [intege].

matrix  [RW]  Substitution matrix for blastall -M
options  [RW]  Options for blastall
output  [R]  Returns a String containing blast execution output in as is the Bio::Blast#format.
parser  [W] 
program  [RW]  Program name (_-p_ option for blastall): blastp, blastn, blastx, tblastn or tblastx
server  [RW]  Server to submit the BLASTs to

Public Class methods

This is a shortcut for Bio::Blast.new:

 Bio::Blast.local(program, database, options)

is equivalent to

 Bio::Blast.new(program, database, options, 'local')

Arguments:

Returns:Bio::Blast factory object

[Source]

# File lib/bio/appl/blast.rb, line 87
    def self.local(program, db, option = '')
      self.new(program, db, option, 'local')
    end

Creates a Bio::Blast factory object.

To run any BLAST searches, a factory has to be created that describes a certain BLAST pipeline: the program to use, the database to search, any options and the server to use. E.g.

  blast_factory = Bio::Blast.new('blastn','dbsts', '-e 0.0001 -r 4', 'genomenet')

Arguments:

  • program (required): ‘blastn’, ‘blastp’, ‘blastx’, ‘tblastn’ or ‘tblastx‘
  • db (required): name of the (local or remote) database
  • options: blastall options # (see www.genome.jp/dbget-bin/show_man?blast2)
  • server: server to use (e.g. ‘genomenet’; DEFAULT = ‘local’)
Returns:Bio::Blast factory object

[Source]

# File lib/bio/appl/blast.rb, line 173
    def initialize(program, db, opt = [], server = 'local')
      @program  = program
      @db       = db
      @server   = server

      @blastall = 'blastall'
      @matrix   = nil
      @filter   = nil

      @output   = ''
      @parser   = nil

      begin
        a = opt.to_ary
      rescue NameError #NoMethodError
        # backward compatibility
        a = Shellwords.shellwords(opt)
      end
      unless a.find { |x| /\A\-m/ =~ x.to_s } then
        if defined?(XMLParser) or defined?(REXML)
          @format = 7
        else
          @format = 8
        end
      end
      @options = [ *a ]
    end

Bio::Blast.remote does exactly the same as Bio::Blast.new, but sets the remote server ‘genomenet’ as its default.


Arguments:

  • program (required): ‘blastn’, ‘blastp’, ‘blastx’, ‘tblastn’ or ‘tblastx‘
  • db (required): name of the remote database
  • options: blastall options # (see www.genome.jp/dbget-bin/show_man?blast2)
  • server: server to use (DEFAULT = ‘genomenet’)
Returns:Bio::Blast factory object

[Source]

# File lib/bio/appl/blast.rb, line 101
    def self.remote(program, db, option = '', server = 'genomenet')
      self.new(program, db, option, server)
    end

the method Bio::Blast.report is moved from bio/appl/blast/report.rb. only for xml format

[Source]

# File lib/bio/appl/blast.rb, line 107
    def self.reports(input, parser = nil)
      ary = []
      input.each("</BlastOutput>\n") do |xml|
        xml.sub!(/[^<]*(<?)/, '\1') # skip before <?xml> tag
        next if xml.empty?          # skip trailing no hits
        if block_given?
          yield Report.new(xml, parser)
        else
          ary << Report.new(xml, parser)
        end
      end
      return ary
    end

Public Instance methods

Returns options of blastall

[Source]

# File lib/bio/appl/blast.rb, line 216
    def option
      # backward compatibility
      Bio::Command.make_command_line(@options)
    end

Set options for blastall

[Source]

# File lib/bio/appl/blast.rb, line 222
    def option=(str)
      # backward compatibility
      @options = Shellwords.shellwords(str)
    end

This method submits a sequence to a BLAST factory, which performs the actual BLAST.

  fasta_sequences = Bio::FlatFile.open(Bio::FastaFormat, 'my_sequences.fa')
  report = blast_factory.query(fasta_sequences)

Arguments:

  • query (required): single- or multiple-FASTA formatted sequence(s)
Returns:a Bio::Blast::Report object

[Source]

# File lib/bio/appl/blast.rb, line 211
    def query(query)
      return self.send("exec_#{@server}", query.to_s)
    end

[Validate]