class Bio::Fasta
Attributes
db[RW]
format[R]
ktup[RW]
matrix[RW]
options[RW]
output[R]
Returns a String containing fasta execution output in as is format.
program[RW]
server[RW]
Public Class Methods
local(program, db, option = '')
click to toggle source
Returns a FASTA factory object (Bio::Fasta) to run FASTA search on local computer.
# File lib/bio/appl/fasta.rb, line 80 def self.local(program, db, option = '') self.new(program, db, option, 'local') end
new(program, db, opt = [], server = 'local')
click to toggle source
Returns a FASTA factory object (Bio::Fasta).
# File lib/bio/appl/fasta.rb, line 23 def initialize(program, db, opt = [], server = 'local') @format = 10 @program = program @db = db @server = server @ktup = nil @matrix = nil @output = '' begin a = opt.to_ary rescue NameError #NoMethodError # backward compatibility a = Shellwords.shellwords(opt) end @options = [ '-Q', '-H', '-m', @format.to_s, *a ] # need -a ? end
parser(parser)
click to toggle source
OBSOLETE. Does nothing and shows warning messages.
Historically, selecting parser to use ('format6' or 'format10' were expected, but only 'format10' was available as a working parser).
# File lib/bio/appl/fasta.rb, line 74 def self.parser(parser) warn 'Bio::Fasta.parser is obsoleted and will soon be removed.' end
remote(program, db, option = '', server = 'genomenet')
click to toggle source
Returns a FASTA factory object (Bio::Fasta) to execute FASTA search on remote server.
For the develpper, you can add server 'hoge' by adding exec_hoge(query) method.
# File lib/bio/appl/fasta.rb, line 90 def self.remote(program, db, option = '', server = 'genomenet') self.new(program, db, option, server) end
Public Instance Methods
format=(num)
click to toggle source
Accessors for the -m option.
# File lib/bio/appl/fasta.rb, line 59 def format=(num) @format = num.to_i if i = @options.index('-m') then @options[i+1, 1] = @format.to_s else @options << '-m' << @format.to_s end end
option()
click to toggle source
# File lib/bio/appl/fasta.rb, line 48 def option # backward compatibility Bio::Command.make_command_line(@options) end
option=(str)
click to toggle source
# File lib/bio/appl/fasta.rb, line 53 def option=(str) # backward compatibility @options = Shellwords.shellwords(str) end
query(query)
click to toggle source
Execute FASTA search and returns Report object (Bio::Fasta::Report).
# File lib/bio/appl/fasta.rb, line 95 def query(query) return self.send("exec_#{@server}", query.to_s) end
Private Instance Methods
exec_genomenet(query)
click to toggle source
Available databases for ::remote(@program, @db, option, 'genomenet')¶ ↑
See fasta.genome.jp/ideas/ideas.html#fasta for more details.
----------+-------+--------------------------------------------------- @program | query | @db (supported in GenomeNet) ----------+-------+--------------------------------------------------- fasta | AA | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd, | | pir, prf, pdbstr +-------+--------------------------------------------------- | NA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, | | htgs, dbsts, embl-nonst, embnonst-upd, epd, | | genes-nt, genome, vgenes.nuc ----------+-------+--------------------------------------------------- tfasta | AA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss, | | htgs, dbsts, embl-nonst, embnonst-upd, | | genes-nt, genome, vgenes.nuc ----------+-------+---------------------------------------------------
# File lib/bio/appl/fasta.rb, line 141 def exec_genomenet(query) host = "fasta.genome.jp" #path = "/sit-bin/nph-fasta" path = "/sit-bin/fasta" # 2005.08.12 form = { 'style' => 'raw', 'prog' => @program, 'dbname' => @db, 'sequence' => query, 'other_param' => Bio::Command.make_command_line_unix(@options), 'ktup_value' => @ktup, 'matrix' => @matrix, } form.keys.each do |k| form.delete(k) unless form[k] end report = nil begin http = Bio::Command.new_http(host) http.open_timeout = 3000 http.read_timeout = 6000 result = Bio::Command.http_post_form(http, path, form) # workaround 2006.8.1 - fixed for new batch queuing system case result.code when "302" result_location = result.header['location'] result_uri = URI.parse(result_location) result_path = result_uri.path done = false until done result = http.get(result_path) if result.body[/Your job ID is/] sleep 15 else done = true end end end @output = result.body.to_s # workaround 2005.08.12 re = %r{<A HREF="http://#{host}(/tmp/[^"]+)">Show all result</A>}i # " if path = @output[re, 1] result = http.get(path) @output = result.body txt = @output.to_s.split(/\<pre\>/)[1] raise 'cannot understand response' unless txt txt.sub!(/\<\/pre\>.*\z/m, '') txt.sub!(/.*^((T?FASTA|SSEARCH) (searches|compares))/m, '\1') txt.sub!(/^\<form method\=\"POST\" name\=\"clust_check\"\>.*\n/, '') txt.sub!(/^\<select +name\=\"allch\".+\r?\n/i, '') # 2009.11.26 txt.gsub!(/\<input[^\>]+value\=\"[^\"]*\"[^\>]*\>/i, '') txt.gsub!(/\<(a|form|select|input|option|img)\s+[^\>]+\>/i, '') txt.gsub!(/\<\/(a|form|select|input|option|img)\>/i, '') txt.gsub!(/\<\;/, '<') txt.gsub!(/\>\;/, '>') # 2009.11.26 @output = txt report = parse_result(@output.dup) else raise 'cannot understand response' end end return report end
exec_local(query)
click to toggle source
# File lib/bio/appl/fasta.rb, line 108 def exec_local(query) cmd = [ @program, *@options ] cmd.concat([ '@', @db ]) cmd.push(@ktup) if @ktup report = nil @output = Bio::Command.query_command(cmd, query) report = parse_result(@output) return report end
parse_result(data)
click to toggle source
# File lib/bio/appl/fasta.rb, line 103 def parse_result(data) Report.new(data) end