lib/bio/appl/blast/genomenet.rb in bio-1.4.2 vs lib/bio/appl/blast/genomenet.rb in bio-1.4.3
- old
+ new
@@ -5,18 +5,16 @@
# Copyright:: Copyright (C) 2002,2003 Toshiaki Katayama <k@bioruby.org>
# Copyright:: Copyright (C) 2006 Jan Aerts <jan.aerts@bbsrc.ac.uk>
# Copyright:: Copyright (C) 2008 Naohisa Goto <ng@bioruby.org>
# License:: The Ruby License
#
-# $Id:$
#
require 'net/http'
require 'uri'
require 'bio/command'
require 'shellwords'
-require 'bio/appl/blast/remote'
module Bio::Blast::Remote
# == Description
#
@@ -56,10 +54,15 @@
# 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 http://www.genome.jp/tools-bin/show_man?blast2
+ #
# == See also
#
# * Bio::Blast
# * Bio::Blast::Report
# * Bio::Blast::Report::Hit
@@ -156,11 +159,12 @@
# executes BLAST and returns result as a string
def exec_genomenet(query)
host = Host
#host = "blast.genome.jp"
#path = "/sit-bin/nph-blast"
- path = "/sit-bin/blast" #2005.08.12
+ #path = "/sit-bin/blast" #2005.08.12
+ path = "/tools-bin/blast" #2012.01.12
options = make_command_line_options
opt = Bio::Blast::NCBIOptions.new(options)
program = opt.delete('-p')
@@ -219,13 +223,13 @@
newpath = newuri.path
result = http.get(newpath)
@output = result.body
# waiting for BLAST finished
while /Your job ID is/ =~ @output and
- /Your result will be displayed here\<br\>/ =~ @output
- if /This page will be reloaded automatically in\s*((\d+)\s*min\.)?\s*(\d+)\s*sec\./ =~ @output then
- reloadtime = $2.to_i * 60 + $3.to_i
+ /Your result will be displayed here\.?\<br\>/i =~ @output
+ if /This page will be reloaded automatically in\s*((\d+)\s*min\.)?\s*((\d+)\s*sec\.)?/ =~ @output then
+ reloadtime = $2.to_i * 60 + $4.to_i
reloadtime = 300 if reloadtime > 300
reloadtime = 1 if reloadtime < 1
else
reloadtime = 5
end
@@ -236,29 +240,42 @@
result = http.get(newpath)
@output = result.body
end
end
- # workaround 2005.08.12 + 2011.01.27
- if /\<A +HREF=\"(http\:\/\/[\-\.a-z0-9]+\.genome\.jp(\/tmp\/[^\"]+))\"\>Show all result\<\/A\>/i =~ @output.to_s then
- @output = Bio::Command.read_uri($1)
- txt = @output.to_s.split(/\<pre\>/)[1]
- raise 'cannot understand response' unless txt
- txt.sub!(/\<\/pre\>.*\z/m, '')
- txt.sub!(/.*^ \-{20,}\s*/m, '')
- @output = txt.gsub(/\<\;/, '<')
+ # workaround 2005.08.12 + 2011.01.27 + 2011.7.22
+ if /\<A +HREF=\"(http\:\/\/[\-\.a-z0-9]+\.genome\.jp)?(\/tmp\/[^\"]+)\"\>Show all result\<\/A\>/i =~ @output.to_s then
+ all_prefix = $1
+ all_path = $2
+ all_prefix = "http://#{Host}" if all_prefix.to_s.empty?
+ all_uri = all_prefix + all_path
+ @output = Bio::Command.read_uri(all_uri)
+ case all_path
+ when /\.txt\z/
+ ; # don't touch the data
+ else
+ txt = @output.to_s.split(/\<pre\>/)[1]
+ raise 'cannot understand response' unless txt
+ txt.sub!(/\<\/pre\>.*\z/m, '')
+ txt.sub!(/.*^ \-{20,}\s*/m, '')
+ @output = txt
+ end
else
raise 'cannot understand response'
end
end
# for -m 0 (NCBI BLAST default) output, html tags are removed.
if opt_m.to_i == 0 then
#@output_bak = @output
- txt = @output.gsub(/^\s*\<img +src\=\"\/Fig\/arrow\_top\.gif\"\>.+$\r?\n/, '')
+ txt = @output.sub!(/^\<select .*/, '')
+ #txt.gsub!(/^\s*\<img +src\=\"\/Fig\/arrow\_top\.gif\"\>.+$\r?\n/, '')
txt.gsub!(/^.+\<\/form\>$/, '')
- txt.gsub!(/^\<form *method\=\"POST\" name\=\"clust\_check\"\>.+$\r?\n/, '')
+ #txt.gsub!(/^\<form *method\=\"POST\" name\=\"clust\_check\"\>.+$\r?\n/, '')
+ txt.gsub!(/\<a href\=\"\/tmp[^\"]\>\&uarr\;\ \;Top\<\/a\>/, '')
txt.gsub!(/\<[^\>\<]+\>/m, '')
+ txt.gsub!(/\>\;/, '>')
+ txt.gsub!(/\<\;/, '<')
@output = txt
end
return @output
end