bio 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/ChangeLog +954 -0
  2. data/KNOWN_ISSUES.rdoc +40 -5
  3. data/README.rdoc +36 -35
  4. data/RELEASE_NOTES.rdoc +87 -59
  5. data/bioruby.gemspec +24 -2
  6. data/doc/RELEASE_NOTES-1.4.1.rdoc +104 -0
  7. data/doc/Tutorial.rd +162 -200
  8. data/doc/Tutorial.rd.html +149 -146
  9. data/lib/bio.rb +1 -0
  10. data/lib/bio/appl/blast.rb +1 -1
  11. data/lib/bio/appl/blast/ddbj.rb +26 -34
  12. data/lib/bio/appl/blast/genomenet.rb +21 -11
  13. data/lib/bio/db/embl/sptr.rb +193 -21
  14. data/lib/bio/db/fasta.rb +1 -1
  15. data/lib/bio/db/fastq.rb +14 -0
  16. data/lib/bio/db/fastq/format_fastq.rb +2 -2
  17. data/lib/bio/db/genbank/ddbj.rb +1 -2
  18. data/lib/bio/db/genbank/format_genbank.rb +1 -1
  19. data/lib/bio/db/medline.rb +1 -0
  20. data/lib/bio/db/newick.rb +3 -1
  21. data/lib/bio/db/pdb/pdb.rb +9 -9
  22. data/lib/bio/db/pdb/residue.rb +2 -2
  23. data/lib/bio/io/ddbjrest.rb +344 -0
  24. data/lib/bio/io/ncbirest.rb +121 -1
  25. data/lib/bio/location.rb +2 -2
  26. data/lib/bio/reference.rb +3 -4
  27. data/lib/bio/shell/plugin/entry.rb +7 -3
  28. data/lib/bio/shell/plugin/ncbirest.rb +5 -1
  29. data/lib/bio/util/restriction_enzyme.rb +3 -0
  30. data/lib/bio/util/restriction_enzyme/dense_int_array.rb +195 -0
  31. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +7 -7
  32. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +57 -18
  33. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +2 -2
  34. data/lib/bio/util/restriction_enzyme/sorted_num_array.rb +219 -0
  35. data/lib/bio/version.rb +1 -1
  36. data/sample/test_restriction_enzyme_long.rb +4403 -0
  37. data/test/data/fasta/EFTU_BACSU.fasta +8 -0
  38. data/test/data/genbank/CAA35997.gp +48 -0
  39. data/test/data/genbank/SCU49845.gb +167 -0
  40. data/test/data/litdb/1717226.litdb +13 -0
  41. data/test/data/pir/CRAB_ANAPL.pir +6 -0
  42. data/test/functional/bio/appl/blast/test_remote.rb +93 -0
  43. data/test/functional/bio/appl/test_blast.rb +61 -0
  44. data/test/functional/bio/io/test_ddbjrest.rb +47 -0
  45. data/test/functional/bio/test_command.rb +3 -3
  46. data/test/unit/bio/db/embl/test_sptr.rb +6 -6
  47. data/test/unit/bio/db/embl/test_uniprot_new_part.rb +208 -0
  48. data/test/unit/bio/db/genbank/test_common.rb +274 -0
  49. data/test/unit/bio/db/genbank/test_genbank.rb +401 -0
  50. data/test/unit/bio/db/genbank/test_genpept.rb +81 -0
  51. data/test/unit/bio/db/pdb/test_pdb.rb +3287 -11
  52. data/test/unit/bio/db/test_fasta.rb +34 -12
  53. data/test/unit/bio/db/test_fastq.rb +26 -0
  54. data/test/unit/bio/db/test_litdb.rb +95 -0
  55. data/test/unit/bio/db/test_medline.rb +1 -0
  56. data/test/unit/bio/db/test_nbrf.rb +82 -0
  57. data/test/unit/bio/db/test_newick.rb +22 -4
  58. data/test/unit/bio/test_reference.rb +35 -0
  59. data/test/unit/bio/util/restriction_enzyme/test_dense_int_array.rb +201 -0
  60. data/test/unit/bio/util/restriction_enzyme/test_sorted_num_array.rb +281 -0
  61. metadata +44 -38
@@ -148,7 +148,7 @@ module Bio
148
148
  # end
149
149
  #
150
150
  def query(factory)
151
- factory.query(@entry)
151
+ factory.query(entry)
152
152
  end
153
153
  alias fasta query
154
154
  alias blast query
@@ -407,6 +407,20 @@ class Fastq
407
407
  # raw sequence data as a String object
408
408
  attr_reader :sequence_string
409
409
 
410
+ # Returns Fastq formatted string constructed from instance variables.
411
+ # The string will always be consisted of four lines without wrapping of
412
+ # the sequence and quality string, and the third-line is always only
413
+ # contains "+". This may be different from initial entry.
414
+ #
415
+ # Note that use of the method may be inefficient and may lose performance
416
+ # because new string object is created every time it is called.
417
+ # For showing an entry as-is, consider using Bio::FlatFile#entry_raw.
418
+ # For output with various options, use Bio::Sequence#output(:fastq).
419
+ #
420
+ def to_s
421
+ "@#{@definition}\n#{@sequence_string}\n+\n#{@quality_string}\n"
422
+ end
423
+
410
424
  # returns Bio::Sequence::NA
411
425
  def naseq
412
426
  unless defined? @naseq then
@@ -26,7 +26,7 @@ module Bio::Sequence::Format::Formatter
26
26
  # *Arguments*:
27
27
  # * _sequence_: Bio::Sequence object
28
28
  # * (optional) :repeat_title => (true or false) if true, repeating title in the "+" line; if not true, "+" only (default false)
29
- # * (optional) :width => _width_: (Fixnum) width to wrap sequence and quality lines; nil to prevent wrapping (default 70)
29
+ # * (optional) :width => _width_: (Fixnum) width to wrap sequence and quality lines; nil to prevent wrapping (default nil)
30
30
  # * (optional) :title => _title_: (String) completely replaces title line with the _title_ (default nil)
31
31
  # * (optional) :default_score => _score_: (Integer) default score for bases that have no valid quality scores or error probabilities; false or nil means the lowest score, true means the highest score (default nil)
32
32
  def initialize; end if false # dummy for RDoc
@@ -43,7 +43,7 @@ module Bio::Sequence::Format::Formatter
43
43
  # *Returns*:: String object
44
44
  def output
45
45
  title = @options[:title]
46
- width = @options.has_key?(:width) ? @options[:width] : 70
46
+ width = @options.has_key?(:width) ? @options[:width] : nil
47
47
  seq = @sequence.seq.to_s
48
48
  entry_id = @sequence.entry_id ||
49
49
  "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
@@ -4,8 +4,6 @@
4
4
  # Copyright:: Copyright (C) 2000-2004 Toshiaki Katayama <k@bioruby.org>
5
5
  # License:: The Ruby License
6
6
  #
7
- # $Id: ddbj.rb,v 1.9 2007/04/05 23:35:40 trevor Exp $
8
- #
9
7
 
10
8
  require 'bio/db/genbank/genbank'
11
9
 
@@ -14,6 +12,7 @@ module Bio
14
12
  class DDBJ < GenBank
15
13
 
16
14
  autoload :XML, 'bio/io/ddbjxml'
15
+ autoload :REST, 'bio/io/ddbjrest'
17
16
 
18
17
  # Nothing to do (DDBJ database format is completely same as GenBank)
19
18
 
@@ -125,7 +125,7 @@ __END_OF_REFERENCE__
125
125
 
126
126
  # formats date
127
127
  def date_format_genbank
128
- date_modified || date_created || null_date
128
+ format_date(date_modified || date_created || null_date)
129
129
  end
130
130
 
131
131
  # moleculue type
@@ -58,6 +58,7 @@ class MEDLINE < NCBIDB
58
58
  hash['medline'] = ui
59
59
  hash['abstract'] = abstract
60
60
  hash['mesh'] = mesh
61
+ hash['doi'] = doi
61
62
  hash['affiliations'] = affiliations
62
63
 
63
64
  hash.delete_if { |k, v| v.nil? or v.empty? }
@@ -343,7 +343,9 @@ module Bio
343
343
  # Returns self.
344
344
  # This method is useful after changing parser options.
345
345
  def reparse
346
- remove_instance_variable(:tree)
346
+ if defined?(@tree)
347
+ remove_instance_variable(:@tree)
348
+ end
347
349
  self.tree
348
350
  self
349
351
  end
@@ -6,7 +6,7 @@
6
6
  # Alex Gutteridge <alexg@ebi.ac.uk>
7
7
  # License:: The Ruby License
8
8
  #
9
- # $Id: pdb.rb,v 1.28 2008/04/01 10:36:44 ngoto Exp $
9
+ # $Id:$
10
10
  #
11
11
  # = About Bio::PDB
12
12
  #
@@ -339,18 +339,18 @@ module Bio
339
339
  #
340
340
  def do_parse
341
341
  return self if @parsed or !@str
342
- str = @str
342
+ str0 = @str
343
343
  each_symbol do |key, klass, ranges|
344
344
  #If we only have one range then pull that out
345
345
  #and store it in the hash
346
346
  if ranges.size <= 1 then
347
- self[key] = klass.new(str[ranges.first])
347
+ self[key] = klass.new(str0[ranges.first])
348
348
  else
349
349
  #Go through each range and add the string to an array
350
350
  #set the hash key to point to that array
351
351
  ary = []
352
352
  ranges.each do |r|
353
- ary << klass.new(str[r]) unless str[r].to_s.strip.empty?
353
+ ary << klass.new(str0[r]) unless str0[r].to_s.strip.empty?
354
354
  end
355
355
  self[key] = ary
356
356
  end
@@ -362,10 +362,10 @@ module Bio
362
362
  each_symbol do |key, klass, ranges|
363
363
  #If there's one range then grab that range
364
364
  if ranges.size <= 1 then
365
- r = ranges.first
366
- unless str[r].to_s.strip.empty?
365
+ r1 = ranges.first
366
+ unless str[r1].to_s.strip.empty?
367
367
  #and concatenate the new data onto the old
368
- v = klass.new(str[r])
368
+ v = klass.new(str[r1])
369
369
  self[key].concat(v) if self[key] != v
370
370
  end
371
371
  else
@@ -1820,14 +1820,14 @@ module Bio
1820
1820
  nil
1821
1821
  end || 'X')
1822
1822
  end
1823
- seq = Bio::Sequence::AA.new(a.to_s)
1823
+ seq = Bio::Sequence::AA.new(a.join(''))
1824
1824
  else
1825
1825
  # nucleic acid sequence
1826
1826
  a.collect! do |na|
1827
1827
  na = na.delete('^a-zA-Z')
1828
1828
  na.size == 1 ? na : 'n'
1829
1829
  end
1830
- seq = Bio::Sequence::NA.new(a.to_s)
1830
+ seq = Bio::Sequence::NA.new(a.join(''))
1831
1831
  end
1832
1832
  newHash[k] = seq
1833
1833
  end
@@ -6,7 +6,7 @@
6
6
  # Naohisa Goto <ng@bioruby.org>
7
7
  # License:: The Ruby License
8
8
  #
9
- # $Id: residue.rb,v 1.14 2007/12/18 13:48:42 ngoto Exp $
9
+ # $Id:$
10
10
  #
11
11
  # = Bio::PDB::Residue
12
12
  #
@@ -67,7 +67,7 @@ module Bio
67
67
 
68
68
  #Keyed access to atoms based on atom name e.g. ["CA"]
69
69
  def [](key)
70
- atom = @atoms.find{ |atom| key == atom.name }
70
+ @atoms.find{ |atom| key == atom.name }
71
71
  end
72
72
 
73
73
  # Updates residue id. This is a private method.
@@ -0,0 +1,344 @@
1
+ #
2
+ # = bio/io/ddbjrest.rb - DDBJ Web API for Biology (WABI) access class via REST
3
+ #
4
+ # Copyright:: Copyright (C) 2011
5
+ # Naohisa Goto <ng@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # == Description
9
+ #
10
+ # This file contains Bio::DDBJ::REST, DDBJ Web API for Biology (WABI) access
11
+ # classes via REST (Representational State Transfer) protocol.
12
+ #
13
+ # == References
14
+ #
15
+ # * http://xml.nig.ac.jp/
16
+ #
17
+
18
+ require 'bio/command'
19
+ require 'bio/db/genbank/ddbj'
20
+
21
+ module Bio
22
+ class DDBJ
23
+
24
+ # == Description
25
+ #
26
+ # The module Bio::DDBJ::REST is the namespace for the DDBJ Web API for
27
+ # Biology (WABI) via REST protocol. Under the Bio::DDBJ::REST,
28
+ # following classes are available.
29
+ #
30
+ # * Bio::DDBJ::REST::DDBJ
31
+ # * Bio::DDBJ::REST::Blast
32
+ # * Bio::DDBJ::REST::ClustalW
33
+ # * Bio::DDBJ::REST::Mafft
34
+ # * Bio::DDBJ::REST::RequestManager
35
+ #
36
+ # Following classes are NOT available, but will be written in the future.
37
+ #
38
+ # * Bio::DDBJ::REST::GetEntry
39
+ # * Bio::DDBJ::REST::ARSA
40
+ # * Bio::DDBJ::REST::VecScreen
41
+ # * Bio::DDBJ::REST::PhylogeneticTree
42
+ # * Bio::DDBJ::REST::Gib
43
+ # * Bio::DDBJ::REST::Gtop
44
+ # * Bio::DDBJ::REST::GTPS
45
+ # * Bio::DDBJ::REST::GIBV
46
+ # * Bio::DDBJ::REST::GIBIS
47
+ # * Bio::DDBJ::REST::SPS
48
+ # * Bio::DDBJ::REST::TxSearch
49
+ # * Bio::DDBJ::REST::Ensembl
50
+ # * Bio::DDBJ::REST::NCBIGenomeAnnotation
51
+ #
52
+ # Read the document of each class for details.
53
+ #
54
+ # In addition, there is a private class Bio::DDBJ::REST::WABItemplate,
55
+ # basic class for the above classes. Normal users should not use the
56
+ # WABItemplate class directly.
57
+ #
58
+ module REST
59
+
60
+ # Bio::DDBJ::REST::WABItemplate is a private class to provide common
61
+ # methods to access DDBJ Web API for Biology (WABI) services by using
62
+ # REST protocol.
63
+ #
64
+ # Normal users should not use the class directly.
65
+ #
66
+ class WABItemplate
67
+
68
+ # hostname for the WABI service
69
+ WABI_HOST = 'xml.nig.ac.jp'
70
+
71
+ # path for the WABI service
72
+ WABI_PATH = '/rest/Invoke'
73
+
74
+ private
75
+
76
+ # Creates a new object.
77
+ def initialize
78
+ @http = Bio::Command.new_http(WABI_HOST)
79
+ @service = self.class.to_s.split(/\:\:/)[-1]
80
+ end
81
+
82
+ # (private) query to the service by using POST method
83
+ def _wabi_post(method_name, param)
84
+ parameters = {
85
+ 'service' => @service,
86
+ 'method' => method_name
87
+ }
88
+ parameters.update(param)
89
+ #$stderr.puts parameters.inspect
90
+ r = Bio::Command.http_post_form(@http, WABI_PATH, parameters)
91
+ #$stderr.puts r.inspect
92
+ #$stderr.puts "-"*78
93
+ #$stderr.puts r.body
94
+ #$stderr.puts "-"*78
95
+ r.body
96
+ end
97
+
98
+ def self.define_wabi_method(array,
99
+ ruby_method_name = nil,
100
+ public_method_name = nil)
101
+ wabi_method_name = array[0]
102
+ ruby_method_name ||= wabi_method_name
103
+ public_method_name ||= wabi_method_name
104
+ arg = array[1..-1]
105
+ arguments = arg.join(', ')
106
+ parameters = "{" +
107
+ arg.collect { |x| "#{x.dump} => #{x}" }.join(", ") + "}"
108
+ module_eval "def #{ruby_method_name}(#{arguments})
109
+ param = #{parameters}
110
+ _wabi_post(#{wabi_method_name.dump}, param)
111
+ end
112
+ def self.#{public_method_name}(#{arguments})
113
+ self.new.#{public_method_name}(#{arguments})
114
+ end"
115
+ self
116
+ end
117
+ private_class_method :define_wabi_method
118
+
119
+ def self.def_wabi(array)
120
+ define_wabi_method(array)
121
+ end
122
+ private_class_method :def_wabi
123
+
124
+ def self.def_wabi_custom(array)
125
+ ruby_method_name = '_' + array[0]
126
+ define_wabi_method(array, ruby_method_name)
127
+ module_eval "private :#{ruby_method_name}"
128
+ self
129
+ end
130
+ private_class_method :def_wabi_custom
131
+
132
+ def self.def_wabi_async(array)
133
+ m = array[0]
134
+ def_wabi_custom(array)
135
+ module_eval "def #{m}(*arg)
136
+ ret = _#{m}(*arg)
137
+ if /Your +requestId +is\s*\:\s*(.+)\s*/i =~ ret.to_s then
138
+ return $1
139
+ else
140
+ raise \"unknown return value: \#\{ret.inspect\}\"
141
+ end
142
+ end"
143
+ self
144
+ end
145
+ private_class_method :def_wabi_async
146
+ end #class WABItemplate
147
+
148
+ # === Description
149
+ #
150
+ # DDBJ (DNA DataBank of Japan) entry retrieval functions.
151
+ #
152
+ # * http://xml.nig.ac.jp/wabi/Method?serviceName=DDBJ&mode=methodList&lang=en
153
+ #
154
+ # === Examples
155
+ #
156
+ # see http://xml.nig.ac.jp/wabi/Method?serviceName=DDBJ&mode=methodList&lang=en
157
+ #
158
+ class DDBJ < WABItemplate
159
+
160
+ # Number and ratio of each base such as A,T,G,C.
161
+ #
162
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=DDBJ&methodName=countBasePair&mode=methodDetail
163
+ # ---
164
+ # *Arguments*:
165
+ # * (required) _accession_: (String) accession
166
+ # *Returns*:: (String) tab-deliminated text
167
+ def countBasePair(accession); end if false #dummy
168
+ def_wabi %w( countBasePair accession )
169
+
170
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=DDBJ&methodName=get&mode=methodDetail
171
+ def get(accessionList, paramList); end if false #dummy
172
+ def_wabi %w( get accessionList paramList )
173
+
174
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=DDBJ&methodName=getAllFeatures&mode=methodDetail
175
+ def getAllFeatures(accession); end if false #dummy
176
+ def_wabi %w( getAllFeatures accession )
177
+
178
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=DDBJ&methodName=getFFEntry&mode=methodDetail
179
+ def getFFEntry(accession); end if false #dummy
180
+ def_wabi %w( getFFEntry accession )
181
+
182
+ # http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=DDBJ&methodName=getRelatedFeatures&mode=methodDetail
183
+ def getRelatedFeatures(accession, start, stop); end if false #dummy
184
+ def_wabi %w( getRelatedFeatures accession start stop )
185
+
186
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=DDBJ&methodName=getRelatedFeaturesSeq&mode=methodDetail
187
+ def getRelatedFeaturesSeq(accession, start, stop); end if false #dummy
188
+ def_wabi %w( getRelatedFeaturesSeq accession start stop )
189
+ end #class DDBJ
190
+
191
+ # === Description
192
+ #
193
+ # DDBJ (DNA DataBank of Japan) BLAST web service.
194
+ # See below for details and examples.
195
+ #
196
+ # Users normally would want to use searchParamAsync or
197
+ # searchParallelAsync with RequestManager.
198
+ #
199
+ # * http://xml.nig.ac.jp/wabi/Method?serviceName=Blast&mode=methodList&lang=en
200
+ class Blast < WABItemplate
201
+
202
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=extractPosition&mode=methodDetail
203
+ def extractPosition(result); end if false #dummy
204
+ def_wabi %w( extractPosition result )
205
+
206
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=getSupportDatabaseList&mode=methodDetail
207
+ def getSupportDatabaseList(); end if false #dummy
208
+ def_wabi %w( getSupportDatabaseList )
209
+
210
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=searchParallel&mode=methodDetail
211
+ def searchParallel(program, database, query, param); end if false #dummy
212
+ def_wabi %w( searchParallel program database query param )
213
+
214
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=searchParallelAsync&mode=methodDetail
215
+ def searchParallelAsync(program, database,
216
+ query, param); end if false #dummy
217
+ def_wabi_async %w( searchParallelAsync program database query param )
218
+
219
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=searchParam&mode=methodDetail
220
+ def searchParam(program, database, query, param); end if false #dummy
221
+ def_wabi %w( searchParam program database query param )
222
+
223
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=searchParamAsync&mode=methodDetail
224
+ def searchParamAsync(program, database,
225
+ query, param); end if false #dummy
226
+ def_wabi_async %w( searchParamAsync program database query param )
227
+
228
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=searchSimple&mode=methodDetail
229
+ def searchSimple(program, database, query); end if false #dummy
230
+ def_wabi %w( searchSimple program database query )
231
+
232
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Blast&methodName=searchSimpleAsync&mode=methodDetail
233
+ def searchSimpleAsync(program, database, query); end if false #dummy
234
+ def_wabi_async %w( searchSimpleAsync program database query )
235
+
236
+ end #class Blast
237
+
238
+ # === Description
239
+ #
240
+ # DDBJ (DNA DataBank of Japan) web service of ClustalW multiple sequence
241
+ # alignment software.
242
+ # See below for details and examples.
243
+ #
244
+ # * http://xml.nig.ac.jp/wabi/Method?serviceName=ClustalW&mode=methodList&lang=en
245
+ class ClustalW < WABItemplate
246
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=ClustalW&methodName=analyzeParam&mode=methodDetail
247
+ def analyzeParam(query, param); end if false #dummy
248
+ def_wabi %w( analyzeParam query param )
249
+
250
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=ClustalW&methodName=analyzeParamAsync&mode=methodDetail
251
+ def analyzeParamAsync(query, param); end if false #dummy
252
+ def_wabi_async %w( analyzeParamAsync query param )
253
+
254
+ # http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=ClustalW&methodName=analyzeSimple&mode=methodDetail
255
+ def analyzeSimple(query); end if false #dummy
256
+ def_wabi %w( analyzeSimple query )
257
+
258
+ # http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=ClustalW&methodName=analyzeSimpleAsync&mode=methodDetail
259
+ def analyzeSimpleAsync(query); end if false #dummy
260
+ def_wabi_async %w( analyzeSimpleAsync query )
261
+ end #lcass ClustalW
262
+
263
+ # === Description
264
+ #
265
+ # DDBJ (DNA DataBank of Japan) web service of MAFFT multiple sequence
266
+ # alignment software.
267
+ # See below for details and examples.
268
+ #
269
+ # * http://xml.nig.ac.jp/wabi/Method?serviceName=Mafft&mode=methodList&lang=en
270
+ class Mafft < WABItemplate
271
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Mafft&methodName=analyzeParam&mode=methodDetail
272
+ def analyzeParam(query, param); end if false #dummy
273
+ def_wabi %w( analyzeParam query param )
274
+
275
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Mafft&methodName=analyzeParamAsync&mode=methodDetail
276
+ def analyzeParamAsync(query, param); end if false #dummy
277
+ def_wabi_async %w( analyzeParamAsync query param )
278
+
279
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Mafft&methodName=analyzeSimple&mode=methodDetail
280
+ def analyzeSimple(query); end if false #dummy
281
+ def_wabi %w( analyzeSimple query )
282
+
283
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=Mafft&methodName=analyzeSimpleAsync&mode=methodDetail
284
+ def analyzeSimpleAsync(query); end if false #dummy
285
+ def_wabi_async %w( analyzeSimpleAsync query )
286
+ end #lcass Mafft
287
+
288
+
289
+ # === Description
290
+ #
291
+ # DDBJ (DNA DataBank of Japan) special web service to get result of
292
+ # asynchronous web service.
293
+ # See below for details and examples.
294
+ #
295
+ # * http://xml.nig.ac.jp/wabi/Method?serviceName=RequestManager&mode=methodList&lang=en
296
+ class RequestManager < WABItemplate
297
+
298
+ # see http://xml.nig.ac.jp/wabi/Method?&lang=en&serviceName=RequestManager&methodName=getAsyncResult&mode=methodDetail
299
+ def getAsyncResult(requestId); end if false #dummy
300
+ def_wabi %w( getAsyncResult requestId )
301
+
302
+ # Waits until the query is finished and the result is returnd,
303
+ # with calling getAsyncResult.
304
+ #
305
+ # This is BioRuby original method.
306
+ # ---
307
+ # *Arguments*:
308
+ # * (required) _requestID_: (String) requestId
309
+ # *Returns*:: (String) result
310
+ def wait_getAsyncResult(requestId)
311
+ sleeptime = 2
312
+ while true
313
+ result = getAsyncResult(requestId)
314
+ case result.to_s
315
+ when /The search and analysis service by WWW is very busy now/
316
+ raise result.to_s.strip + '(Alternatively, wrong options may be given.)'
317
+ when /\AYour job has not (?:been )?completed yet/
318
+ sleeptime = 2 + rand(4)
319
+ when /\AERROR:/
320
+ raise result.to_s.strip
321
+ else
322
+ return result
323
+ end #case
324
+ if $VERBOSE then
325
+ $stderr.puts "DDBJ REST: requestId: #{requestId} -- waitng #{sleeptime} sec."
326
+ end
327
+ sleep(sleeptime)
328
+ end
329
+ # will never be reached here
330
+ raise "Bug?"
331
+ end
332
+
333
+ # the same as Bio::DDBJ::REST::RequestManager#wait_getAsyncResult
334
+ def self.wait_getAsyncResult(requestId)
335
+ self.new.wait_getAsyncResult(requestId)
336
+ end
337
+
338
+ end #class RequestManager
339
+
340
+ end #module REST
341
+ end #class DDBJ
342
+ end #module Bio
343
+
344
+