module Bio::Blast::Remote::Genomenet

Description

The Bio::Blast::Remote::GenomeNet class contains methods for running remote BLAST searches on GenomeNet (blast.genome.jp/).

Usage

require 'bio'

# To run an actual BLAST analysis:
#   1. create a BLAST factory
blast_factory = Bio::Blast.remote('blastp', 'nr-aa',
                                  '-e 0.0001', 'genomenet')
#or:
blast_factory = Bio::Blast::Remote.genomenet('blastp', 'nr-aa',
                                             '-e 0.0001')

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

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

Available databases for Bio::Blast::Remote::GenomeNet

Up-to-date available databases can be obtained by using Bio::Blast::Remote::GenomeNet.databases(program). Short descriptions of databases

----------+-------+---------------------------------------------------
 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
----------+-------+---------------------------------------------------

BLAST options

Options are basically the same as those of the blastall command in NCBI BLAST. See www.genome.jp/tools-bin/show_man?blast2

See also

References

Constants

Host

Public Class Methods

new(program, db, options = []) click to toggle source

Creates a remote BLAST factory using GenomeNet. Returns Bio::Blast object.

Note for future improvement: In the future, it might return Bio::Blast::Remote::GenomeNet or other object.

   # File lib/bio/appl/blast/genomenet.rb
87 def self.new(program, db, options = [])
88   Bio::Blast.new(program, db, options, 'genomenet')
89 end

Private Instance Methods

exec_genomenet(query) click to toggle source

executes BLAST and returns result as a string

    # File lib/bio/appl/blast/genomenet.rb
160 def exec_genomenet(query)
161   host = Host
162   #host = "blast.genome.jp"
163   #path = "/sit-bin/nph-blast"
164   #path = "/sit-bin/blast" #2005.08.12
165   path = "/tools-bin/blast" #2012.01.12
166 
167   options = make_command_line_options
168   opt = Bio::Blast::NCBIOptions.new(options)
169 
170   program = opt.delete('-p')
171   db = opt.delete('-d')
172 
173   # When database name starts with mine-aa or mine-nt,
174   # space-separated list of KEGG organism codes can be given.
175   # For example, "mine-aa eco bsu hsa".
176   if /\A(mine-(aa|nt))\s+/ =~ db.to_s then
177     db = $1
178     myspecies = {}
179     myspecies["myspecies-#{$2}"] = $'
180   end
181 
182   matrix = opt.delete('-M') || 'blosum62'
183   filter = opt.delete('-F') || 'T'
184 
185   opt_v = opt.delete('-v') || 500 # default value for GenomeNet
186   opt_b = opt.delete('-b') || 250 # default value for GenomeNet
187 
188   # format, not for form parameters, but included in option string
189   opt_m = opt.get('-m') || '7' # default of BioRuby GenomeNet factory
190   opt.set('-m', opt_m)
191 
192   optstr = Bio::Command.make_command_line_unix(opt.options)
193 
194   form = {
195     'style'          => 'raw',
196     'prog'           => program,
197     'dbname'         => db,
198     'sequence'       => query,
199     'other_param'    => optstr,
200     'matrix'         => matrix,
201     'filter'         => filter,
202     'V_value'        => opt_v, 
203     'B_value'        => opt_b, 
204     'alignment_view' => 0,
205   }
206 
207   form.merge!(myspecies) if myspecies
208 
209   form.keys.each do |k|
210     form.delete(k) unless form[k]
211   end
212 
213   begin
214     http = Bio::Command.new_https(host)
215     http.open_timeout = 300
216     http.read_timeout = 600
217     result = Bio::Command.http_post_form(http, path, form)
218     @output = result.body
219 
220     # workaround 2008.8.13
221     if result.code == '302' then
222       newuri = URI.parse(result['location'])
223       newpath = newuri.path
224       result = http.get(newpath)
225       @output = result.body
226       # waiting for BLAST finished
227       while /Your job ID is/ =~ @output and
228           /Your result will be displayed here\.?\<br\>/i =~ @output
229         if /This page will be reloaded automatically in\s*((\d+)\s*min\.)?\s*((\d+)\s*sec\.)?/ =~ @output then
230           reloadtime = $2.to_i * 60 + $4.to_i
231           reloadtime = 300 if reloadtime > 300
232           reloadtime = 1 if reloadtime < 1
233         else
234           reloadtime = 5
235         end
236         if $VERBOSE then
237           $stderr.puts "waiting #{reloadtime} sec to reload #{newuri.to_s}"
238         end
239         sleep(reloadtime)
240         result = http.get(newpath)
241         @output = result.body
242       end
243     end
244 
245     # workaround 2005.08.12 + 2011.01.27 + 2011.7.22
246     if /\<A +HREF=\"(https?\:\/\/[\-\.a-z0-9]+\.genome\.jp)?(\/tmp\/[^\"]+)\"\>Show all result\<\/A\>/i =~ @output.to_s then
247       all_prefix = $1
248       all_path = $2
249       all_prefix = "https://#{Host}" if all_prefix.to_s.empty?
250       all_uri = all_prefix + all_path
251       @output = Bio::Command.read_uri(all_uri)
252       case all_path
253       when /\.txt\z/
254         ; # don't touch the data
255       else
256         txt = @output.to_s.split(/\<pre\>/)[1]
257         raise 'cannot understand response' unless txt
258         txt.sub!(/\<\/pre\>.*\z/m, '')
259         txt.sub!(/.*^ \-{20,}\s*/m, '')
260         @output = txt
261       end
262     else
263       raise 'cannot understand response'
264     end
265   end
266 
267   # for -m 0 (NCBI BLAST default) output, html tags are removed.
268   if opt_m.to_i == 0 then
269     #@output_bak = @output
270     txt = @output.sub!(/^\<select .*/, '')
271     #txt.gsub!(/^\s*\<img +src\=\"\/Fig\/arrow\_top\.gif\"\>.+$\r?\n/, '')
272     txt.gsub!(/^.+\<\/form\>$/, '')
273     #txt.gsub!(/^\<form *method\=\"POST\" name\=\"clust\_check\"\>.+$\r?\n/, '')
274     txt.gsub!(/\<a href\=\"\/tmp[^\"]\>\&uarr\;\&nbsp\;Top\<\/a\>/, '')
275     txt.gsub!(/\<[^\>\<]+\>/m, '')
276     txt.gsub!(/\&gt\;/, '>')
277     txt.gsub!(/\&lt\;/, '<')
278     @output = txt
279   end
280 
281   return @output
282 end