Class: Bio::DDBJ::REST::RequestManager

Inherits:
WABItemplate show all
Defined in:
lib/bio/io/ddbjrest.rb

Overview

Description

DDBJ (DNA DataBank of Japan) special web service to get result of asynchronous web service. See below for details and examples.

Constant Summary

Constants inherited from WABItemplate

WABItemplate::WABI_HOST, WABItemplate::WABI_PATH

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.wait_getAsyncResult(requestId) ⇒ Object

the same as Bio::DDBJ::REST::RequestManager#wait_getAsyncResult



334
335
336
# File 'lib/bio/io/ddbjrest.rb', line 334

def self.wait_getAsyncResult(requestId)
  self.new.wait_getAsyncResult(requestId)
end

Instance Method Details

#getAsyncResult(requestId) ⇒ Object



299
# File 'lib/bio/io/ddbjrest.rb', line 299

def getAsyncResult(requestId); end

#wait_getAsyncResult(requestId) ⇒ Object

Waits until the query is finished and the result is returnd, with calling getAsyncResult.

This is BioRuby original method.


Arguments:

  • (required) requestID: (String) requestId

Returns

(String) result



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/bio/io/ddbjrest.rb', line 310

def wait_getAsyncResult(requestId)
  sleeptime = 2
  while true
    result = getAsyncResult(requestId)
    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 /\AYour job has not (?:been )?completed yet/
      sleeptime = 2 + rand(4)
    when /\AERROR:/
      raise result.to_s.strip
    else
      return result
    end #case
    if $VERBOSE then
      $stderr.puts "DDBJ REST: requestId: #{requestId} -- waitng #{sleeptime} sec."
    end
    sleep(sleeptime)
  end
  # will never be reached here
  raise "Bug?"
end