Module: Bio::Blast::Remote::DDBJ

Extended by:
Information
Defined in:
lib/bio/appl/blast/ddbj.rb

Overview

Remote BLAST factory using DDBJ Web API for Biology (xml.nig.ac.jp/).

Defined Under Namespace

Modules: Information

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Information

#database_description, #databases, #nucleotide_databases, #protein_databases, #reset

Class Method Details

.new(program, db, options = []) ⇒ Object

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

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


26
27
28
# File 'lib/bio/appl/blast/ddbj.rb', line 26

def self.new(program, db, options = [])
  Bio::Blast.new(program, db, options, 'ddbj')
end

Instance Method Details

#exec_ddbj(query) ⇒ Object

executes BLAST and returns result as a string


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/bio/appl/blast/ddbj.rb', line 95

def exec_ddbj(query)
  options = make_command_line_options
  opt = Bio::Blast::NCBIOptions.new(options)

  # SOAP objects are cached
  @ddbj_remote_blast ||= Bio::DDBJ::XML::Blast.new
  #@ddbj_request_manager ||= Bio::DDBJ::XML::RequestManager.new
  # always use REST version to prevent warning messages
  @ddbj_request_manager ||= Bio::DDBJ::XML::RequestManager::REST.new

  program = opt.delete('-p')
  db = opt.delete('-d')
  optstr = Bio::Command.make_command_line_unix(opt.options)

  # using searchParamAsync 
  qid = @ddbj_remote_blast.searchParamAsync(program, db, query, optstr)
  @output = qid

  sleeptime = 2
  flag = true
  while flag
    if $VERBOSE then
      $stderr.puts "DDBJ BLAST: ID: #{qid} -- waitng #{sleeptime} sec."
    end
    sleep(sleeptime)

    result = @ddbj_request_manager.getAsyncResult(qid)
    case result.to_s
    when /The search and analysis service by WWW is very busy now/
      raise result.to_s.strip + '(Alternatively, wrong options may be given.)'
    when /Your job has not completed yet/
      sleeptime = 5
    else
      flag = false
    end
  end while flag

  @output = result
  return @output
end