bio 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/ChangeLog +3421 -0
  2. data/KNOWN_ISSUES.rdoc +88 -0
  3. data/README.rdoc +252 -0
  4. data/README_DEV.rdoc +285 -0
  5. data/Rakefile +143 -0
  6. data/bin/bioruby +0 -0
  7. data/bin/br_biofetch.rb +0 -0
  8. data/bin/br_bioflat.rb +12 -1
  9. data/bin/br_biogetseq.rb +0 -0
  10. data/bin/br_pmfetch.rb +4 -3
  11. data/bioruby.gemspec +477 -0
  12. data/bioruby.gemspec.erb +117 -0
  13. data/doc/Changes-0.7.rd +7 -0
  14. data/doc/Changes-1.3.rdoc +239 -0
  15. data/doc/Tutorial.rd +296 -184
  16. data/doc/Tutorial.rd.html +1031 -0
  17. data/doc/Tutorial.rd.ja +111 -45
  18. data/doc/Tutorial.rd.ja.html +2225 -0
  19. data/doc/bioruby.css +281 -0
  20. data/extconf.rb +2 -0
  21. data/lib/bio.rb +29 -4
  22. data/lib/bio/appl/blast.rb +306 -121
  23. data/lib/bio/appl/blast/ddbj.rb +142 -0
  24. data/lib/bio/appl/blast/format0.rb +35 -25
  25. data/lib/bio/appl/blast/format8.rb +2 -2
  26. data/lib/bio/appl/blast/genomenet.rb +263 -0
  27. data/lib/bio/appl/blast/ncbioptions.rb +220 -0
  28. data/lib/bio/appl/blast/remote.rb +106 -0
  29. data/lib/bio/appl/blast/report.rb +260 -9
  30. data/lib/bio/appl/blast/rexml.rb +12 -5
  31. data/lib/bio/appl/blast/rpsblast.rb +277 -0
  32. data/lib/bio/appl/blast/wublast.rb +133 -12
  33. data/lib/bio/appl/blast/xmlparser.rb +35 -18
  34. data/lib/bio/appl/blat/report.rb +46 -5
  35. data/lib/bio/appl/emboss.rb +62 -13
  36. data/lib/bio/appl/fasta.rb +9 -11
  37. data/lib/bio/appl/genscan/report.rb +3 -3
  38. data/lib/bio/appl/hmmer.rb +1 -1
  39. data/lib/bio/appl/hmmer/report.rb +10 -10
  40. data/lib/bio/appl/paml/baseml.rb +95 -0
  41. data/lib/bio/appl/paml/baseml/report.rb +32 -0
  42. data/lib/bio/appl/paml/codeml.rb +242 -0
  43. data/lib/bio/appl/paml/codeml/rates.rb +67 -0
  44. data/lib/bio/appl/paml/codeml/report.rb +67 -0
  45. data/lib/bio/appl/paml/common.rb +348 -0
  46. data/lib/bio/appl/paml/common_report.rb +38 -0
  47. data/lib/bio/appl/paml/yn00.rb +103 -0
  48. data/lib/bio/appl/paml/yn00/report.rb +32 -0
  49. data/lib/bio/appl/psort.rb +2 -2
  50. data/lib/bio/appl/pts1.rb +5 -5
  51. data/lib/bio/appl/tmhmm/report.rb +10 -1
  52. data/lib/bio/command.rb +297 -41
  53. data/lib/bio/compat/features.rb +157 -0
  54. data/lib/bio/compat/references.rb +128 -0
  55. data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
  56. data/lib/bio/db/biosql/sequence.rb +508 -0
  57. data/lib/bio/db/embl/common.rb +28 -12
  58. data/lib/bio/db/embl/embl.rb +107 -9
  59. data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
  60. data/lib/bio/db/embl/format_embl.rb +190 -0
  61. data/lib/bio/db/embl/sptr.rb +15 -16
  62. data/lib/bio/db/fantom.rb +6 -8
  63. data/lib/bio/db/fasta.rb +10 -507
  64. data/lib/bio/db/fasta/defline.rb +532 -0
  65. data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
  66. data/lib/bio/db/fasta/format_fasta.rb +97 -0
  67. data/lib/bio/db/genbank/common.rb +25 -8
  68. data/lib/bio/db/genbank/format_genbank.rb +187 -0
  69. data/lib/bio/db/genbank/genbank.rb +36 -1
  70. data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
  71. data/lib/bio/db/gff.rb +1791 -119
  72. data/lib/bio/db/kegg/glycan.rb +2 -6
  73. data/lib/bio/db/lasergene.rb +3 -3
  74. data/lib/bio/db/medline.rb +4 -1
  75. data/lib/bio/db/newick.rb +10 -10
  76. data/lib/bio/db/pdb/chain.rb +6 -2
  77. data/lib/bio/db/pdb/pdb.rb +12 -3
  78. data/lib/bio/db/rebase.rb +7 -8
  79. data/lib/bio/db/soft.rb +3 -3
  80. data/lib/bio/feature.rb +1 -88
  81. data/lib/bio/io/biosql/biodatabase.rb +64 -0
  82. data/lib/bio/io/biosql/bioentry.rb +29 -0
  83. data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
  84. data/lib/bio/io/biosql/bioentry_path.rb +12 -0
  85. data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
  86. data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
  87. data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
  88. data/lib/bio/io/biosql/biosequence.rb +11 -0
  89. data/lib/bio/io/biosql/comment.rb +7 -0
  90. data/lib/bio/io/biosql/config/database.yml +20 -0
  91. data/lib/bio/io/biosql/dbxref.rb +13 -0
  92. data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
  93. data/lib/bio/io/biosql/location.rb +32 -0
  94. data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
  95. data/lib/bio/io/biosql/ontology.rb +10 -0
  96. data/lib/bio/io/biosql/reference.rb +9 -0
  97. data/lib/bio/io/biosql/seqfeature.rb +32 -0
  98. data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
  99. data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
  100. data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
  101. data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
  102. data/lib/bio/io/biosql/taxon.rb +12 -0
  103. data/lib/bio/io/biosql/taxon_name.rb +9 -0
  104. data/lib/bio/io/biosql/term.rb +27 -0
  105. data/lib/bio/io/biosql/term_dbxref.rb +11 -0
  106. data/lib/bio/io/biosql/term_path.rb +12 -0
  107. data/lib/bio/io/biosql/term_relationship.rb +13 -0
  108. data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
  109. data/lib/bio/io/biosql/term_synonym.rb +10 -0
  110. data/lib/bio/io/das.rb +7 -7
  111. data/lib/bio/io/ddbjxml.rb +57 -0
  112. data/lib/bio/io/ensembl.rb +2 -2
  113. data/lib/bio/io/fetch.rb +28 -14
  114. data/lib/bio/io/flatfile.rb +17 -853
  115. data/lib/bio/io/flatfile/autodetection.rb +545 -0
  116. data/lib/bio/io/flatfile/buffer.rb +237 -0
  117. data/lib/bio/io/flatfile/index.rb +17 -7
  118. data/lib/bio/io/flatfile/indexer.rb +30 -12
  119. data/lib/bio/io/flatfile/splitter.rb +297 -0
  120. data/lib/bio/io/hinv.rb +442 -0
  121. data/lib/bio/io/keggapi.rb +2 -2
  122. data/lib/bio/io/ncbirest.rb +733 -0
  123. data/lib/bio/io/pubmed.rb +34 -80
  124. data/lib/bio/io/registry.rb +2 -2
  125. data/lib/bio/io/sql.rb +178 -357
  126. data/lib/bio/io/togows.rb +458 -0
  127. data/lib/bio/location.rb +106 -11
  128. data/lib/bio/pathway.rb +120 -14
  129. data/lib/bio/reference.rb +115 -101
  130. data/lib/bio/sequence.rb +164 -183
  131. data/lib/bio/sequence/adapter.rb +108 -0
  132. data/lib/bio/sequence/common.rb +22 -45
  133. data/lib/bio/sequence/compat.rb +2 -2
  134. data/lib/bio/sequence/dblink.rb +54 -0
  135. data/lib/bio/sequence/format.rb +254 -77
  136. data/lib/bio/sequence/format_raw.rb +23 -0
  137. data/lib/bio/shell.rb +3 -1
  138. data/lib/bio/shell/core.rb +2 -2
  139. data/lib/bio/shell/plugin/entry.rb +33 -4
  140. data/lib/bio/shell/plugin/ncbirest.rb +64 -0
  141. data/lib/bio/shell/plugin/togows.rb +40 -0
  142. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/bioruby_generator.rb +0 -0
  143. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_classes.rhtml +0 -0
  144. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_log.rhtml +0 -0
  145. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_methods.rhtml +0 -0
  146. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_modules.rhtml +0 -0
  147. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_variables.rhtml +0 -0
  148. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-bg.gif +0 -0
  149. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-gem.png +0 -0
  150. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-link.gif +0 -0
  151. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.css +0 -0
  152. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.rhtml +0 -0
  153. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_controller.rb +0 -0
  154. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_helper.rb +0 -0
  155. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/commands.rhtml +0 -0
  156. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/history.rhtml +0 -0
  157. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/index.rhtml +0 -0
  158. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/spinner.gif +0 -0
  159. data/lib/bio/tree.rb +4 -2
  160. data/lib/bio/util/color_scheme.rb +2 -2
  161. data/lib/bio/util/contingency_table.rb +2 -2
  162. data/lib/bio/util/restriction_enzyme.rb +2 -2
  163. data/lib/bio/util/restriction_enzyme/single_strand.rb +6 -5
  164. data/lib/bio/version.rb +25 -0
  165. data/rdoc.zsh +8 -0
  166. data/sample/any2fasta.rb +0 -0
  167. data/sample/biofetch.rb +0 -0
  168. data/sample/dbget +0 -0
  169. data/sample/demo_sequence.rb +158 -0
  170. data/sample/enzymes.rb +0 -0
  171. data/sample/fasta2tab.rb +0 -0
  172. data/sample/fastagrep.rb +72 -0
  173. data/sample/fastasort.rb +54 -0
  174. data/sample/fsplit.rb +0 -0
  175. data/sample/gb2fasta.rb +2 -3
  176. data/sample/gb2tab.rb +0 -0
  177. data/sample/gbtab2mysql.rb +0 -0
  178. data/sample/genes2nuc.rb +0 -0
  179. data/sample/genes2pep.rb +0 -0
  180. data/sample/genes2tab.rb +0 -0
  181. data/sample/genome2rb.rb +0 -0
  182. data/sample/genome2tab.rb +0 -0
  183. data/sample/goslim.rb +0 -0
  184. data/sample/gt2fasta.rb +0 -0
  185. data/sample/na2aa.rb +34 -0
  186. data/sample/pmfetch.rb +0 -0
  187. data/sample/pmsearch.rb +0 -0
  188. data/sample/ssearch2tab.rb +0 -0
  189. data/sample/tfastx2tab.rb +0 -0
  190. data/sample/vs-genes.rb +0 -0
  191. data/setup.rb +1596 -0
  192. data/test/data/blast/blastp-multi.m7 +188 -0
  193. data/test/data/command/echoarg2.bat +1 -0
  194. data/test/data/paml/codeml/control_file.txt +30 -0
  195. data/test/data/paml/codeml/output.txt +78 -0
  196. data/test/data/paml/codeml/rates +217 -0
  197. data/test/data/rpsblast/misc.rpsblast +193 -0
  198. data/test/data/soft/GDS100_partial.soft +0 -0
  199. data/test/data/soft/GSE3457_family_partial.soft +0 -0
  200. data/test/functional/bio/appl/test_pts1.rb +115 -0
  201. data/test/functional/bio/io/test_ensembl.rb +123 -80
  202. data/test/functional/bio/io/test_togows.rb +267 -0
  203. data/test/functional/bio/sequence/test_output_embl.rb +51 -0
  204. data/test/functional/bio/test_command.rb +301 -0
  205. data/test/runner.rb +17 -1
  206. data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
  207. data/test/unit/bio/appl/blast/test_report.rb +753 -35
  208. data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
  209. data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
  210. data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
  211. data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
  212. data/test/unit/bio/appl/test_blast.rb +135 -4
  213. data/test/unit/bio/appl/test_fasta.rb +2 -2
  214. data/test/unit/bio/appl/test_pts1.rb +1 -64
  215. data/test/unit/bio/db/embl/test_common.rb +15 -15
  216. data/test/unit/bio/db/embl/test_embl.rb +4 -4
  217. data/test/unit/bio/db/embl/test_embl_rel89.rb +5 -5
  218. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
  219. data/test/unit/bio/db/embl/test_sptr.rb +38 -1
  220. data/test/unit/bio/db/pdb/test_pdb.rb +2 -2
  221. data/test/unit/bio/db/test_gff.rb +1151 -25
  222. data/test/unit/bio/db/test_medline.rb +127 -0
  223. data/test/unit/bio/db/test_nexus.rb +5 -1
  224. data/test/unit/bio/db/test_prosite.rb +4 -4
  225. data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
  226. data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
  227. data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
  228. data/test/unit/bio/io/test_ddbjxml.rb +8 -3
  229. data/test/unit/bio/io/test_fastacmd.rb +5 -5
  230. data/test/unit/bio/io/test_flatfile.rb +357 -106
  231. data/test/unit/bio/io/test_soapwsdl.rb +2 -2
  232. data/test/unit/bio/io/test_togows.rb +161 -0
  233. data/test/unit/bio/sequence/test_common.rb +210 -11
  234. data/test/unit/bio/sequence/test_compat.rb +3 -3
  235. data/test/unit/bio/sequence/test_dblink.rb +58 -0
  236. data/test/unit/bio/sequence/test_na.rb +2 -2
  237. data/test/unit/bio/test_command.rb +111 -50
  238. data/test/unit/bio/test_feature.rb +29 -1
  239. data/test/unit/bio/test_location.rb +566 -6
  240. data/test/unit/bio/test_pathway.rb +91 -65
  241. data/test/unit/bio/test_reference.rb +67 -13
  242. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +3 -3
  243. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +3 -3
  244. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +3 -3
  245. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +4 -3
  246. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +3 -3
  247. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +3 -3
  248. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +3 -3
  249. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +3 -3
  250. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +3 -3
  251. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +3 -3
  252. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +4 -4
  253. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +3 -3
  254. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +3 -3
  255. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +3 -3
  256. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +3 -3
  257. data/test/unit/bio/util/test_restriction_enzyme.rb +3 -3
  258. metadata +202 -167
  259. data/test/unit/bio/appl/blast/test_xmlparser.rb +0 -388
@@ -0,0 +1,267 @@
1
+ #
2
+ # test/functional/bio/io/test_togows.rb - Functional test for Bio::TogoWS
3
+ #
4
+ # Copyright:: Copyright (C) 2009
5
+ # Naohisa Goto <ng@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id:$
9
+ #
10
+
11
+ require 'pathname'
12
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
13
+ $:.unshift(libpath) unless $:.include?(libpath)
14
+
15
+ require 'uri'
16
+ require 'bio/version'
17
+ require 'bio/io/togows'
18
+ require 'bio/db/genbank/genbank'
19
+ require 'test/unit'
20
+
21
+ module Bio
22
+
23
+ # common tests for both instance methods and class methods
24
+ module FuncTestTogoWSRESTcommon
25
+
26
+ bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4)).cleanpath.to_s
27
+ TestData = Pathname.new(File.join(bioruby_root, 'test', 'data')).cleanpath.to_s
28
+
29
+ def test_entry
30
+ result = nil
31
+ acc = 'AF237819'
32
+ assert_nothing_raised {
33
+ result = @togows.entry('genbank', acc)
34
+ }
35
+ assert(!result.to_s.strip.empty?)
36
+ gb = Bio::GenBank.new(result)
37
+ assert(gb.accessions.include?(acc))
38
+ end
39
+
40
+ def test_entry_multi
41
+ result = nil
42
+ accs = [ 'AF237819' ,'AB302966', 'AY582120' ]
43
+ assert_nothing_raised {
44
+ result = @togows.entry('genbank', accs)
45
+ }
46
+ assert(!result.to_s.strip.empty?)
47
+ count = 0
48
+ accs.each do |x|
49
+ assert_match(Regexp.new(x), result)
50
+ count += 1
51
+ end
52
+ assert_equal(accs.size, count)
53
+
54
+ # argument is a string
55
+ accs2 = accs.join(',')
56
+ result2 = nil
57
+ assert_nothing_raised {
58
+ result2 = @togows.entry('genbank', accs2)
59
+ }
60
+ assert(result2 == result)
61
+ end
62
+
63
+ def test_entry_with_format
64
+ result = nil
65
+ acc = 'AF237819'
66
+ assert_nothing_raised {
67
+ result = @togows.entry('genbank', acc, 'fasta')
68
+ }
69
+ assert(!result.to_s.strip.empty?)
70
+ assert_match(/^\>/, result)
71
+ end
72
+
73
+ def test_entry_with_key
74
+ result = nil
75
+ assert_nothing_raised {
76
+ result = @togows.entry('pubmed', '16381885', nil, 'authors')
77
+ }
78
+ assert(!result.to_s.strip.empty?)
79
+ end
80
+
81
+ def test_entry_with_format_and_key
82
+ result = nil
83
+ assert_nothing_raised {
84
+ result = @togows.entry('pubmed', '16381885', 'json', 'authors')
85
+ }
86
+ assert(!result.to_s.strip.empty?)
87
+ end
88
+
89
+ def test_search
90
+ result = nil
91
+ assert_nothing_raised {
92
+ result = @togows.search('nuccore', 'Milnesium tardigradum')
93
+ }
94
+ assert(!result.to_s.strip.empty?)
95
+ end
96
+
97
+ def test_search_with_offset_limit
98
+ result = nil
99
+ assert_nothing_raised {
100
+ result = @togows.search('nuccore', 'Milnesium tardigradum', 2, 3)
101
+ }
102
+ assert(!result.to_s.strip.empty?)
103
+ ary = result.chomp.split(/\n/)
104
+ assert_equal(3, ary.size)
105
+ end
106
+
107
+ def test_search_with_offset_limit_format
108
+ result = nil
109
+ assert_nothing_raised {
110
+ result = @togows.search('nuccore', 'Milnesium tardigradum', 2, 3,
111
+ 'json')
112
+ }
113
+ assert(!result.to_s.strip.empty?)
114
+ end
115
+
116
+ def test_convert
117
+ data = File.read(File.join(TestData, 'blast', 'b0002.faa.m0'))
118
+ result = nil
119
+ assert_nothing_raised {
120
+ result = @togows.convert(data, 'blast', 'gff')
121
+ }
122
+ assert(!result.to_s.strip.empty?)
123
+ end
124
+
125
+ def test_retrieve
126
+ result = nil
127
+ assert_nothing_raised {
128
+ result = @togows.retrieve('AF237819')
129
+ }
130
+ assert(!result.to_s.strip.empty?)
131
+ end
132
+
133
+ def test_retrieve_1id_1db
134
+ result = nil
135
+ assert_nothing_raised {
136
+ result = @togows.retrieve('hsa:124',
137
+ :database => 'gene',
138
+ :field => 'entry_id',
139
+ :format => 'json')
140
+ }
141
+ assert(!result.to_s.strip.empty?)
142
+ end
143
+
144
+ def test_retrieve_1id_2db
145
+ result = nil
146
+ assert_nothing_raised {
147
+ result = @togows.retrieve('1.1.1.1',
148
+ :database => [ 'gene', 'enzyme' ])
149
+ }
150
+ assert(!result.to_s.strip.empty?)
151
+ end
152
+
153
+ def test_retrieve_2id_2db
154
+ result = nil
155
+ assert_nothing_raised {
156
+ result = @togows.retrieve([ '1.1.1.1', 'hsa:124' ],
157
+ :database => [ 'gene', 'enzyme' ])
158
+ }
159
+ assert(!result.to_s.strip.empty?)
160
+ end
161
+
162
+ def test_entry_database_list
163
+ result = nil
164
+ assert_nothing_raised {
165
+ result = @togows.entry_database_list
166
+ }
167
+ assert_kind_of(Array, result)
168
+ assert(!result.empty?)
169
+ end
170
+
171
+ def test_search_database_list
172
+ result = nil
173
+ assert_nothing_raised {
174
+ result = @togows.search_database_list
175
+ }
176
+ assert_kind_of(Array, result)
177
+ assert(!result.empty?)
178
+ end
179
+
180
+ end #FuncTestTogoWSRESTcommon
181
+
182
+ # functional test for Bio::TogoWS::REST
183
+ class FuncTestTogoWSREST < Test::Unit::TestCase
184
+
185
+ include FuncTestTogoWSRESTcommon
186
+
187
+ def setup
188
+ @togows = Bio::TogoWS::REST.new
189
+ end
190
+
191
+ end #class FuncTestTogoWSREST
192
+
193
+ # functional test for Bio::TogoWS::REST private methods
194
+ class FuncTestTogoWSRESTprivate < Test::Unit::TestCase
195
+
196
+ def setup
197
+ @togows = Bio::TogoWS::REST.new
198
+ end
199
+
200
+ def test_get
201
+ response = nil
202
+ acc = 'AF237819'
203
+ assert_nothing_raised {
204
+ response = @togows.instance_eval {
205
+ get('entry', 'genbank', acc, 'entry_id')
206
+ }
207
+ }
208
+ assert_kind_of(Net::HTTPResponse, response)
209
+ assert_equal("200", response.code)
210
+ result = response.body
211
+ assert(!result.to_s.strip.empty?)
212
+ end
213
+
214
+ def test_get_dir
215
+ response = nil
216
+ assert_nothing_raised {
217
+ response = @togows.instance_eval {
218
+ get_dir('search')
219
+ }
220
+ }
221
+ assert_kind_of(Net::HTTPResponse, response)
222
+ assert_equal("200", response.code)
223
+ result = response.body
224
+ assert(!result.to_s.strip.empty?)
225
+ end
226
+
227
+ def test_post_data
228
+ data = File.read(File.join(Bio::FuncTestTogoWSRESTcommon::TestData,
229
+ 'blast', 'b0002.faa.m0'))
230
+ response = nil
231
+ assert_nothing_raised {
232
+ response = @togows.instance_eval {
233
+ post_data(data, 'convert', 'blast.gff')
234
+ }
235
+ }
236
+ assert_kind_of(Net::HTTPResponse, response)
237
+ assert_equal("200", response.code)
238
+ result = response.body
239
+ assert(!result.to_s.strip.empty?)
240
+ end
241
+
242
+ def test_database_list
243
+ result = nil
244
+ assert_nothing_raised {
245
+ result = @togows.instance_eval {
246
+ database_list('entry')
247
+ }
248
+ }
249
+ assert_kind_of(Array, result)
250
+ assert(!result.empty?)
251
+ end
252
+
253
+ end #class FuncTestTogoWSRESTprivate
254
+
255
+ if false # DISABLED because of the server load and execution time
256
+
257
+ # functional test for Bio::TogoWS::REST class methods
258
+ class FuncTestTogoWSRESTclassMethod < Test::Unit::TestCase
259
+ include FuncTestTogoWSRESTcommon
260
+ def setup
261
+ @togows = Bio::TogoWS::REST
262
+ end
263
+ end #class FuncTestTogoWSRESTclassMethod
264
+
265
+ end #if false
266
+
267
+ end #module Bio
@@ -0,0 +1,51 @@
1
+ #
2
+ # test/functional/bio/sequence/test_output_embl.rb - Functional test for Bio::Sequence#output(:embl)
3
+ #
4
+ # Copyright:: Copyright (C) 2008
5
+ # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id: test_output_embl.rb,v 1.1.2.2 2008/03/28 00:56:27 ngoto Exp $
9
+ #
10
+
11
+ require 'pathname'
12
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
13
+ $:.unshift(libpath) unless $:.include?(libpath)
14
+
15
+ require 'test/unit'
16
+ require 'bio'
17
+
18
+ module Bio
19
+ class FuncTestSequenceOutputEMBL < Test::Unit::TestCase
20
+ def setup
21
+ @seq = Bio::Sequence.auto('aattaaaacgccacgcaaggcgattctaggaaatcaaaacgacacgaaatgtggggtgggtgtttgggtaggaaagacagttgtcaacatcagggatttggattgaatcaaaaaaaaagtccttagatttcataaaagctaatcacgcctcaaaactggggcctatctcttcttttttgtcgcttcctgtcggtccttctctatttcttctccaacccctcatttttgaatatttacataacaaaccgttttactttctttggtcaaaattagacccaaaattctatattagtttaagatatgtggtctgtaatttattgttgtattgatataaaaattagttataagcgattatatttttatgctcaagtaactggtgttagttaactatattccaccacgataacctgattacataaaatatgattttaatcattttagtaaaccatatcgcacgttggatgattaattttaacggtttaataacacgtgattaaattatttttagaatgattatttacaaacggaaaagctatatgtgacacaataactcgtgcagtattgttagtttgaaaagtgtatttggtttcttatatttggcctcgattttcagtttatgtgctttttacaaagttttattttcgttatctgtttaacgcgacatttgttgtatggctttaccgatttgagaataaaatcatattacctttatgtagccatgtgtggtgtaatatataataatggtccttctacgaaaaaagcagatcacaattgaaataaagggtgaaatttggtgtcccttttcttcgtcgaaataacagaactaaataaaagaaagtgttatagtatattacgtccgaagaataatccatattcctgaaatacagtcaacatattatatatttagtactttatataaagttaggaattaaatcatatgttttatcgaccatattaagtcacaactttatcataaattaatctgtaattagaattccaagttcgccaccgaatttcgtaacctaatctacatataatagataaaatatatatatgtagagtaattatgatatctatgtatgtagtcatggtatatgaattttgaaattggcaaggtaacattgacggatcgtaacccaacaaataatattaattacaaaatgggtgggcgggaatagtatacaactcataattccactcactttttgtattattaggatatgaaataagagtaatcaacatgcataataaagatgtataatttcttcatcttaaaaaacataactacatggtttaatacacaattttaccttttatcaaaaaagtatttcacaattcactcgcaaattacgaaatgatggctagtgcttcaactccaaatttcgaatattttaaatcacgatgtgtagaaccttttatttactggatactaatcactagtttattgagccaaccaattagttaaatagaacaatcaatattatagccagatattttttcctttaaaaatatttaaaagaggggccagaaaagaaccagagagggaggccatgagacattattatcactagtcaaaaacaacaaaccctccttttgctttttcatataaattattatattttattttgcaggtttcttctcttcttcttcttcttcttcttcttcttcctcttggctgctttctttcatcatccataaagtgaaagctaacgcatagagagagccatatcgtcccaaaaaaagcaaaagtccaaaaaaaaacaactccaaaacattctctcttagctctttactctttagtttctctctctctctctgcctttctctttgttgaagttcatggatgctacgaagtggactcaggtacgtaaaaagatatctctctgctatatctgtttgtttgtagcttctccccgactctcacgctctctctctctctctctctctctttgtgtatctctctactcacataaatatatacatgtgtgtgtatgcatgtttatatgtatgtatgaaaccagtagtggttatacagatagtctatatagagatatcaatatgatgtgttttaatttagactttttatatatccgtttgaaacttccgaagttctcgaatggagttaaggaagttttgttctctacaagttcaatttttcttgtcattaattataaaactctgataactaatggataaaaaaggtatgctttgttagttaccttttgttcttggtgctcaggtcttaccatttttttcctaaattttaattagtctcctttctttaattaattttatgttaacgcactgacgatttaacgttaacaaaaaaacctagattctttttcttttcaatagagcataattattacttcaatttcatttatctcacactaaaccctaatcttggcgaaattccttttatatatataaatttaattaatttttccacaatcttggcggaattcaggactcggttttgcttgttattgttctctcttttaatttgacatggttagggaatacttaaagtatgtcttaattttatagggttttcaagaaatgataaacgtaaagccaatggagcaaatgatttctagcaccaacaacaacacaccgcaacaacaaccaacattcatcgccaccaacacaaggccaaacgccaccgcatccaatggtggctccggaggaaataccaacaacacggctacgatggaaactagaaaggcgaggccacaagagaaagtaaattgtccaagatgcaactcaacaaacacaaagttctgttattacaacaactacagtctcacgcaaccaagatacttctgcaaaggttgtcgaaggtattggaccgaaggtggctctcttcgtaacgtcccagtcggaggtagctcaagaaagaacaagagatcctctacacctttagcttcaccttctaatcccaaacttccagatctaaacccaccgattcttttctcaagccaaatccctaataagtcaaataaagatctcaacttgctatctttcccggtcatgcaagatcatcatcatcatggtatgtctcatttttttcatatgcccaagatagagaacaacaatacttcatcctcaatctatgcttcatcatctcctgtctcagctcttgagcttctaagatccaatggagtctcttcaagaggcatgaacacgttcttgcctggtcaaatgatggattcaaactcagtcctgtactcatctttagggtttccaacaatgcctgattacaaacagagtaataacaacctttcattctccattgatcatcatcaagggattggacataacaccatcaacagtaaccaaagagctcaagataacaatgatgacatgaatggagcaagtagggttttgttccctttttcagacatgaaagagctttcaagcacaacccaagagaagagtcatggtaataatacatattggaatgggatgttcagtaatacaggaggatcttcatggtgaaaaaaggttaaaaagagctcatgaactatcagctttcttctctttttctgtttttttctcctattttattatagtttttactttgatgatcttttgttttttctcacatggggaactttacttaaagttgtcagaacttagtttacagattgtctttttattccttctttctggttttccttttttcctttttttatcagtctttttaaaatatgtatttcataattgggtttgatcattcatatttattagtatcaaaatagagtctatgttcatgagggagtgttaaggggtgtgagggtagaagaataagtgaatacgggggcccg')
22
+ @seq.entry_id = 'AJ224122'
23
+ @seq.sequence_version = 3
24
+ @seq.topology = 'linear'
25
+ @seq.molecule_type = 'genomic DNA'
26
+ @seq.data_class = 'STD'
27
+ @seq.division = 'PLN'
28
+ @seq.primary_accession = 'AJ224122'
29
+ @seq.secondary_accessions = []
30
+ @seq.date_created = '27-FEB-1998 (Rel. 54, Created)'
31
+ @seq.date_modified = '14-NOV-2006 (Rel. 89, Last updated, Version 6)'
32
+ @seq.definition = 'Arabidopsis thaliana DAG1 gene'
33
+ @seq.keywords = ['BBFa gene', 'transcription factor']
34
+ @seq.species = 'Arabidopsis thaliana (thale cress)'
35
+ @seq.classification = ['Eukaryota', 'Viridiplantae', 'Streptophyta', 'Embryophyta', 'Tracheophyta',
36
+ 'Spermatophyta', 'Magnoliophyta', 'eudicotyledons', 'core eudicotyledons', 'rosids',
37
+ 'eurosids II', 'Brassicales', 'Brassicaceae', 'Arabidopsis']
38
+ end
39
+
40
+ def test_output_embl
41
+ assert_nothing_raised { @seq.output(:embl) }
42
+ end
43
+
44
+ def test_output_fasta
45
+ assert_nothing_raised { @seq.output(:fasta) }
46
+ end
47
+
48
+ end #class FuncTestSequenceOutputEMBL
49
+
50
+ end #module Bio
51
+
@@ -0,0 +1,301 @@
1
+ #
2
+ # test/unit/bio/test_command.rb - Functional test for external command execution methods in Bio::Command
3
+ #
4
+ # Copyright:: Copyright (C) 2008
5
+ # Naohisa Goto <ng@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id:$
9
+ #
10
+
11
+ require 'pathname'
12
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s
13
+ $:.unshift(libpath) unless $:.include?(libpath)
14
+
15
+
16
+ require 'test/unit'
17
+ require 'tempfile'
18
+ require 'bio/command'
19
+
20
+ module Bio
21
+ class FuncTestCommandCall < Test::Unit::TestCase
22
+
23
+ def setup
24
+ case RUBY_PLATFORM
25
+ when /mswin32|bccwin32/
26
+ bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3)).cleanpath.to_s
27
+ cmd = File.expand_path(File.join(bioruby_root, 'test', 'data', 'command', 'echoarg2.bat'))
28
+ @arg = [ cmd, 'test "argument 1"', '"test" argument 2', 'arg3' ]
29
+ @expected = '"""test"" argument 2"'
30
+ else
31
+ cmd = "/bin/echo"
32
+ @arg = [ cmd, "test (echo) command" ]
33
+ @expected = "test (echo) command"
34
+ unless FileTest.executable?(cmd) then
35
+ raise "Unsupported environment: /bin/echo not found"
36
+ end
37
+ end
38
+ end
39
+
40
+ def test_call_command
41
+ ret = Bio::Command.call_command(@arg) do |io|
42
+ io.close_write
43
+ io.read
44
+ end
45
+ assert_equal(@expected, ret.to_s.strip)
46
+ end
47
+
48
+ def test_call_command_popen
49
+ ret = Bio::Command.call_command_popen(@arg) do |io|
50
+ io.close_write
51
+ io.read
52
+ end
53
+ assert_equal(@expected, ret.to_s.strip)
54
+ end
55
+
56
+ def test_call_command_fork
57
+ begin
58
+ ret = Bio::Command.call_command_fork(@arg) do |io|
59
+ io.close_write
60
+ io.read
61
+ end
62
+ rescue Errno::ENOENT, NotImplementedError
63
+ # fork() not supported
64
+ return
65
+ end
66
+ assert_equal(@expected, ret.to_s.strip)
67
+ end
68
+
69
+ def test_call_command_open3
70
+ begin
71
+ ret = Bio::Command.call_command_open3(@arg) do |pin, pout, perr|
72
+ t = Thread.start { perr.read }
73
+ begin
74
+ pin.close
75
+ output = pout.read
76
+ ensure
77
+ t.join
78
+ end
79
+ output
80
+ end
81
+ rescue NotImplementedError
82
+ # fork() not supported
83
+ return
84
+ end
85
+ assert_equal(@expected, ret.to_s.strip)
86
+ end
87
+
88
+ end #class FuncTestCommandCall
89
+
90
+ class FuncTestCommandQuery < Test::Unit::TestCase
91
+
92
+ def setup
93
+ @data = [ "987", "123", "567", "456", "345" ]
94
+ @sorted = @data.sort
95
+ case RUBY_PLATFORM
96
+ when /mswin32|bccwin32/
97
+ @sort = "sort"
98
+ @data = @data.join("\r\n") + "\r\n"
99
+ else
100
+ @sort = "/usr/bin/sort"
101
+ unless FileTest.executable?(@sort) then
102
+ raise "Unsupported environment: /usr/bin/sort not found"
103
+ end
104
+ @data = @data.join("\n") + "\n"
105
+ end
106
+ end
107
+
108
+ def test_query_command
109
+ ary = [ @sort ]
110
+ assert_equal('', Bio::Command.query_command(ary).to_s.strip)
111
+ str = Bio::Command.query_command(ary, @data).to_s
112
+ assert_equal(@sorted, str.strip.split(/\s+/))
113
+ end
114
+
115
+ def test_query_command_popen
116
+ ary = [ @sort ]
117
+ assert_equal('', Bio::Command.query_command_popen(ary).to_s.strip)
118
+ str = Bio::Command.query_command_popen(ary, @data).to_s
119
+ assert_equal(@sorted, str.strip.split(/\s+/))
120
+ end
121
+
122
+ def test_query_command_fork
123
+ ary = [ @sort ]
124
+ begin
125
+ str = Bio::Command.query_command_fork(ary).to_s
126
+ rescue Errno::ENOENT, NotImplementedError
127
+ # fork() not supported
128
+ return
129
+ end
130
+ assert_equal('', str.strip)
131
+ str = Bio::Command.query_command_fork(ary, @data).to_s
132
+ assert_equal(@sorted, str.strip.split(/\s+/))
133
+ end
134
+
135
+ def test_query_command_open3
136
+ ary = [ @sort ]
137
+ begin
138
+ str, err = Bio::Command.query_command_open3(ary)
139
+ rescue NotImplementedError
140
+ # fork() not supported
141
+ return
142
+ end
143
+ assert_equal('', str.to_s.strip)
144
+ str, err = Bio::Command.query_command_open3(ary, @data)
145
+ assert_equal(@sorted, str.to_s.strip.split(/\s+/))
146
+ end
147
+ end #class FuncTestCommandQuery
148
+
149
+ class FuncTestCommandChdir < Test::Unit::TestCase
150
+ def setup
151
+ case RUBY_PLATFORM
152
+ when /mswin32|bccwin32/
153
+ @arg = [ 'dir', '/B', '/-P' ]
154
+ else
155
+ cmd = '/bin/ls'
156
+ @arg = [ cmd ]
157
+ unless FileTest.executable?(cmd) then
158
+ raise "Unsupported environment: #{cmd} not found"
159
+ end
160
+ end
161
+ @tempfile = Tempfile.new('chdir')
162
+ @tempfile.close(false)
163
+ @filename = File.basename(@tempfile.path)
164
+ @dirname = File.dirname(@tempfile.path)
165
+ end
166
+
167
+ def teardown
168
+ @tempfile.close(true)
169
+ end
170
+
171
+ def test_call_command_chdir
172
+ str = nil
173
+ Bio::Command.call_command(@arg, { :chdir => @dirname }) do |io|
174
+ io.close_write
175
+ str = io.read
176
+ end
177
+ assert(str.index(@filename))
178
+ end
179
+
180
+ def test_call_command_popen_chdir
181
+ str = nil
182
+ Bio::Command.call_command_popen(@arg,
183
+ { :chdir => @dirname }) do |io|
184
+ io.close_write
185
+ str = io.read
186
+ end
187
+ assert(str.index(@filename))
188
+ end
189
+
190
+ def test_call_command_fork_chdir
191
+ str = nil
192
+ begin
193
+ Bio::Command.call_command_fork(@arg,
194
+ { :chdir => @dirname }) do |io|
195
+ io.close_write
196
+ str = io.read
197
+ end
198
+ rescue Errno::ENOENT, NotImplementedError
199
+ # fork() not supported
200
+ return
201
+ end
202
+ assert(str.index(@filename))
203
+ end
204
+
205
+ def test_query_command_chdir
206
+ str = Bio::Command.query_command(@arg, nil,
207
+ { :chdir => @dirname }).to_s
208
+ assert(str.index(@filename))
209
+ end
210
+
211
+ def test_query_command_popen_chdir
212
+ str = Bio::Command.query_command_popen(@arg, nil,
213
+ { :chdir => @dirname }).to_s
214
+ assert(str.index(@filename))
215
+ end
216
+
217
+ def test_query_command_fork_chdir
218
+ begin
219
+ str = Bio::Command.query_command_fork(@arg, nil,
220
+ { :chdir => @dirname }).to_s
221
+ rescue Errno::ENOENT, NotImplementedError
222
+ # fork() not supported
223
+ return
224
+ end
225
+ assert(str.index(@filename))
226
+ end
227
+ end #class FuncTestCommandChdir
228
+
229
+ class FuncTestCommandBackports < Test::Unit::TestCase
230
+ def setup
231
+ if RUBY_VERSION < "1.8.3"
232
+ @notest = true
233
+ else
234
+ @notest = false
235
+ end
236
+ end
237
+
238
+ def test_remove_entry_secure
239
+ return if @notest
240
+ begin
241
+ tempfile = Tempfile.new('removed')
242
+ tempfile.close(false)
243
+ assert(File.exist?(tempfile.path))
244
+ Bio::Command.remove_entry_secure(tempfile.path)
245
+ assert_equal(false, File.exist?(tempfile.path))
246
+ ensure
247
+ tempfile.close(true) if tempfile
248
+ end
249
+ end
250
+
251
+ def test_mktmpdir_with_block
252
+ return if @notest
253
+ tmpdirpath = nil
254
+ Bio::Command.mktmpdir('bioruby') do |path|
255
+ tmpdirpath = path
256
+ assert(File.directory?(path))
257
+ assert_nothing_raised {
258
+ File.open(File.join(path, 'test'), 'w') do |w|
259
+ w.print "This is test."
260
+ end
261
+ }
262
+ end
263
+ assert_equal(false, File.directory?(tmpdirpath))
264
+ end
265
+
266
+ def test_mktmpdir_without_block
267
+ return if @notest
268
+ path = nil
269
+ begin
270
+ assert_nothing_raised {
271
+ path = Bio::Command.mktmpdir('bioruby')
272
+ }
273
+ assert(File.directory?(path))
274
+ assert_nothing_raised {
275
+ File.open(File.join(path, 'test'), 'w') do |w|
276
+ w.print "This is test."
277
+ end
278
+ }
279
+ ensure
280
+ Bio::Command.remove_entry_secure(path) if path
281
+ end
282
+ end
283
+ end #class FuncTestCommandBackports
284
+
285
+ class FuncTestCommandNet < Test::Unit::TestCase
286
+ def test_read_uri
287
+ assert_nothing_raised {
288
+ Bio::Command.read_uri("http://bioruby.open-bio.org/")
289
+ }
290
+ end
291
+
292
+ def test_start_http
293
+ end
294
+
295
+ def test_new_http
296
+ end
297
+
298
+ def test_post_form
299
+ end
300
+ end #class FuncTestCommandNet
301
+ end #module Bio