Class: Bio::Blast
- Defined in:
- lib/bio/appl/blast.rb,
lib/bio/io/fastacmd.rb,
lib/bio/appl/blast/rexml.rb,
lib/bio/appl/blast/report.rb,
lib/bio/appl/bl2seq/report.rb,
lib/bio/appl/blast/format0.rb,
lib/bio/appl/blast/format8.rb,
lib/bio/appl/blast/wublast.rb,
lib/bio/appl/blast/xmlparser.rb
Overview
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
-
Bio::Blast::Report
-
Bio::Blast::Report::Hit
-
Bio::Blast::Report::Hsp
References
Defined Under Namespace
Modules: Default, WU Classes: Bl2seq, Fastacmd, Report
Instance Attribute Summary collapse
-
#blastall ⇒ Object
Full path for blastall.
-
#db ⇒ Object
Database name (-d option for blastall).
-
#filter ⇒ Object
Filter option for blastall -F (T or F).
-
#format ⇒ Object
readonly
Output report format for blastall -m .
-
#matrix ⇒ Object
Substitution matrix for blastall -M.
-
#options ⇒ Object
Options for blastall.
-
#output ⇒ Object
readonly
Returns a String containing blast execution output in as is the Bio::Blast#format.
-
#parser ⇒ Object
writeonly
to change :xmlparser, :rexml, :tab.
-
#program ⇒ Object
Program name (-p option for blastall): blastp, blastn, blastx, tblastn or tblastx.
-
#server ⇒ Object
Server to submit the BLASTs to.
Class Method Summary collapse
-
.local(program, db, option = '') ⇒ Object
- 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: * program (required): ‘blastn’, ‘blastp’, ‘blastx’, ‘tblastn’ or ‘tblastx’ * db (required): name of the local database * options: blastall options \ (see www.genome.jp/dbget-bin/show_man?blast2) Returns
-
Bio::Blast factory object.
-
.remote(program, db, option = '', server = 'genomenet') ⇒ Object
Bio::Blast.remote does exactly the same as Bio::Blast.new, but sets the remote server ‘genomenet’ as its default.
-
.reports(input, parser = nil) ⇒ Object
the method Bio::Blast.report is moved from bio/appl/blast/report.rb.
Instance Method Summary collapse
-
#initialize(program, db, opt = [], server = 'local') ⇒ Blast
constructor
Creates a Bio::Blast factory object.
-
#option ⇒ Object
Returns options of blastall.
-
#option=(str) ⇒ Object
Set options for blastall.
-
#query(query) ⇒ Object
This method submits a sequence to a BLAST factory, which performs the actual BLAST.
Constructor Details
#initialize(program, db, opt = [], server = 'local') ⇒ Blast
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
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# 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 |
Instance Attribute Details
#blastall ⇒ Object
Full path for blastall. (default: ‘blastall’).
136 137 138 |
# File 'lib/bio/appl/blast.rb', line 136 def blastall @blastall end |
#db ⇒ Object
Database name (-d option for blastall)
127 128 129 |
# File 'lib/bio/appl/blast.rb', line 127 def db @db end |
#filter ⇒ Object
Filter option for blastall -F (T or F).
142 143 144 |
# File 'lib/bio/appl/blast.rb', line 142 def filter @filter end |
#format ⇒ Object (readonly)
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].
151 152 153 |
# File 'lib/bio/appl/blast.rb', line 151 def format @format end |
#matrix ⇒ Object
Substitution matrix for blastall -M
139 140 141 |
# File 'lib/bio/appl/blast.rb', line 139 def matrix @matrix end |
#options ⇒ Object
Options for blastall
130 131 132 |
# File 'lib/bio/appl/blast.rb', line 130 def @options end |
#output ⇒ Object (readonly)
Returns a String containing blast execution output in as is the Bio::Blast#format.
145 146 147 |
# File 'lib/bio/appl/blast.rb', line 145 def output @output end |
#parser=(value) ⇒ Object (writeonly)
to change :xmlparser, :rexml, :tab
154 155 156 |
# File 'lib/bio/appl/blast.rb', line 154 def parser=(value) @parser = value end |
#program ⇒ Object
Program name (-p option for blastall): blastp, blastn, blastx, tblastn or tblastx
124 125 126 |
# File 'lib/bio/appl/blast.rb', line 124 def program @program end |
#server ⇒ Object
Server to submit the BLASTs to
133 134 135 |
# File 'lib/bio/appl/blast.rb', line 133 def server @server end |
Class Method Details
.local(program, db, option = '') ⇒ Object
This is a shortcut for Bio::Blast.new:
Bio::Blast.local(program, database, )
is equivalent to
Bio::Blast.new(program, database, , 'local')
Arguments:
-
program (required): ‘blastn’, ‘blastp’, ‘blastx’, ‘tblastn’ or ‘tblastx’
-
db (required): name of the local database
-
options: blastall options \
(see www.genome.jp/dbget-bin/show_man?blast2)
- Returns
-
Bio::Blast factory object
87 88 89 |
# File 'lib/bio/appl/blast.rb', line 87 def self.local(program, db, option = '') self.new(program, db, option, 'local') end |
.remote(program, db, option = '', server = 'genomenet') ⇒ Object
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
101 102 103 |
# File 'lib/bio/appl/blast.rb', line 101 def self.remote(program, db, option = '', server = 'genomenet') self.new(program, db, option, server) end |
.reports(input, parser = nil) ⇒ Object
the method Bio::Blast.report is moved from bio/appl/blast/report.rb. only for xml format
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# 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 |
Instance Method Details
#option ⇒ Object
Returns options of blastall
216 217 218 219 |
# File 'lib/bio/appl/blast.rb', line 216 def option # backward compatibility Bio::Command.make_command_line(@options) end |
#option=(str) ⇒ Object
Set options for blastall
222 223 224 225 |
# File 'lib/bio/appl/blast.rb', line 222 def option=(str) # backward compatibility @options = Shellwords.shellwords(str) end |
#query(query) ⇒ Object
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
211 212 213 |
# File 'lib/bio/appl/blast.rb', line 211 def query(query) return self.send("exec_#{@server}", query.to_s) end |