bio 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (340) hide show
  1. data/bin/bioruby +14 -122
  2. data/bin/br_biofetch.rb +2 -2
  3. data/bin/br_bioflat.rb +2 -2
  4. data/bin/br_biogetseq.rb +2 -2
  5. data/bin/br_pmfetch.rb +3 -3
  6. data/doc/Changes-0.7.rd +77 -0
  7. data/doc/KEGG_API.rd +523 -232
  8. data/doc/KEGG_API.rd.ja +529 -207
  9. data/doc/Tutorial.rd +48 -11
  10. data/lib/bio.rb +59 -6
  11. data/lib/bio/alignment.rb +713 -103
  12. data/lib/bio/appl/bl2seq/report.rb +2 -18
  13. data/lib/bio/appl/blast.rb +108 -91
  14. data/lib/bio/appl/blast/format0.rb +33 -18
  15. data/lib/bio/appl/blast/format8.rb +6 -20
  16. data/lib/bio/appl/blast/report.rb +293 -429
  17. data/lib/bio/appl/blast/rexml.rb +8 -22
  18. data/lib/bio/appl/blast/wublast.rb +21 -12
  19. data/lib/bio/appl/blast/xmlparser.rb +180 -183
  20. data/lib/bio/appl/blat/report.rb +127 -30
  21. data/lib/bio/appl/clustalw.rb +87 -59
  22. data/lib/bio/appl/clustalw/report.rb +20 -22
  23. data/lib/bio/appl/emboss.rb +113 -20
  24. data/lib/bio/appl/fasta.rb +173 -198
  25. data/lib/bio/appl/fasta/format10.rb +244 -347
  26. data/lib/bio/appl/gcg/msf.rb +212 -0
  27. data/lib/bio/appl/gcg/seq.rb +195 -0
  28. data/lib/bio/appl/genscan/report.rb +5 -23
  29. data/lib/bio/appl/hmmer.rb +8 -45
  30. data/lib/bio/appl/hmmer/report.rb +2 -20
  31. data/lib/bio/appl/iprscan/report.rb +374 -0
  32. data/lib/bio/appl/mafft.rb +87 -50
  33. data/lib/bio/appl/mafft/report.rb +151 -44
  34. data/lib/bio/appl/muscle.rb +52 -0
  35. data/lib/bio/appl/phylip/alignment.rb +129 -0
  36. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  37. data/lib/bio/appl/probcons.rb +41 -0
  38. data/lib/bio/appl/psort.rb +89 -96
  39. data/lib/bio/appl/psort/report.rb +6 -22
  40. data/lib/bio/appl/pts1.rb +263 -0
  41. data/lib/bio/appl/sim4.rb +26 -36
  42. data/lib/bio/appl/sim4/report.rb +2 -18
  43. data/lib/bio/appl/sosui/report.rb +5 -20
  44. data/lib/bio/appl/spidey/report.rb +2 -2
  45. data/lib/bio/appl/targetp/report.rb +4 -20
  46. data/lib/bio/appl/tcoffee.rb +55 -0
  47. data/lib/bio/appl/tmhmm/report.rb +4 -20
  48. data/lib/bio/command.rb +235 -64
  49. data/lib/bio/data/aa.rb +21 -26
  50. data/lib/bio/data/codontable.rb +2 -20
  51. data/lib/bio/data/na.rb +19 -4
  52. data/lib/bio/db.rb +27 -12
  53. data/lib/bio/db/aaindex.rb +2 -20
  54. data/lib/bio/db/embl/common.rb +4 -21
  55. data/lib/bio/db/embl/embl.rb +33 -85
  56. data/lib/bio/db/embl/sptr.rb +612 -302
  57. data/lib/bio/db/embl/swissprot.rb +10 -29
  58. data/lib/bio/db/embl/trembl.rb +10 -29
  59. data/lib/bio/db/embl/uniprot.rb +10 -29
  60. data/lib/bio/db/fantom.rb +15 -20
  61. data/lib/bio/db/fasta.rb +3 -3
  62. data/lib/bio/db/genbank/common.rb +37 -46
  63. data/lib/bio/db/genbank/ddbj.rb +6 -18
  64. data/lib/bio/db/genbank/genbank.rb +47 -186
  65. data/lib/bio/db/genbank/genpept.rb +4 -17
  66. data/lib/bio/db/genbank/refseq.rb +4 -17
  67. data/lib/bio/db/gff.rb +103 -35
  68. data/lib/bio/db/go.rb +4 -20
  69. data/lib/bio/db/kegg/brite.rb +26 -36
  70. data/lib/bio/db/kegg/compound.rb +81 -85
  71. data/lib/bio/db/kegg/drug.rb +98 -0
  72. data/lib/bio/db/kegg/enzyme.rb +133 -110
  73. data/lib/bio/db/kegg/expression.rb +2 -20
  74. data/lib/bio/db/kegg/genes.rb +208 -238
  75. data/lib/bio/db/kegg/genome.rb +164 -285
  76. data/lib/bio/db/kegg/glycan.rb +114 -157
  77. data/lib/bio/db/kegg/keggtab.rb +242 -303
  78. data/lib/bio/db/kegg/kgml.rb +117 -160
  79. data/lib/bio/db/kegg/orthology.rb +112 -0
  80. data/lib/bio/db/kegg/reaction.rb +54 -69
  81. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  82. data/lib/bio/db/lasergene.rb +209 -0
  83. data/lib/bio/db/litdb.rb +3 -27
  84. data/lib/bio/db/medline.rb +228 -249
  85. data/lib/bio/db/nbrf.rb +3 -3
  86. data/lib/bio/db/newick.rb +510 -0
  87. data/lib/bio/db/nexus.rb +1854 -0
  88. data/lib/bio/db/pdb.rb +5 -17
  89. data/lib/bio/db/pdb/atom.rb +2 -18
  90. data/lib/bio/db/pdb/chain.rb +2 -18
  91. data/lib/bio/db/pdb/chemicalcomponent.rb +2 -18
  92. data/lib/bio/db/pdb/model.rb +2 -18
  93. data/lib/bio/db/pdb/pdb.rb +73 -34
  94. data/lib/bio/db/pdb/residue.rb +4 -20
  95. data/lib/bio/db/pdb/utils.rb +2 -18
  96. data/lib/bio/db/prosite.rb +403 -422
  97. data/lib/bio/db/rebase.rb +84 -40
  98. data/lib/bio/db/soft.rb +404 -0
  99. data/lib/bio/db/transfac.rb +5 -17
  100. data/lib/bio/feature.rb +106 -52
  101. data/lib/bio/io/das.rb +32 -42
  102. data/lib/bio/io/dbget.rb +2 -20
  103. data/lib/bio/io/ddbjxml.rb +77 -138
  104. data/lib/bio/io/ebisoap.rb +158 -0
  105. data/lib/bio/io/ensembl.rb +229 -0
  106. data/lib/bio/io/fastacmd.rb +89 -82
  107. data/lib/bio/io/fetch.rb +163 -96
  108. data/lib/bio/io/flatfile.rb +170 -73
  109. data/lib/bio/io/flatfile/bdb.rb +3 -16
  110. data/lib/bio/io/flatfile/index.rb +2 -2
  111. data/lib/bio/io/flatfile/indexer.rb +3 -2
  112. data/lib/bio/io/higet.rb +12 -31
  113. data/lib/bio/io/keggapi.rb +210 -269
  114. data/lib/bio/io/ncbisoap.rb +155 -0
  115. data/lib/bio/io/pubmed.rb +169 -147
  116. data/lib/bio/io/registry.rb +4 -20
  117. data/lib/bio/io/soapwsdl.rb +43 -38
  118. data/lib/bio/io/sql.rb +242 -305
  119. data/lib/bio/location.rb +407 -285
  120. data/lib/bio/map.rb +410 -0
  121. data/lib/bio/pathway.rb +558 -695
  122. data/lib/bio/reference.rb +272 -75
  123. data/lib/bio/sequence.rb +255 -13
  124. data/lib/bio/sequence/aa.rb +71 -10
  125. data/lib/bio/sequence/common.rb +187 -33
  126. data/lib/bio/sequence/compat.rb +59 -4
  127. data/lib/bio/sequence/format.rb +54 -7
  128. data/lib/bio/sequence/generic.rb +3 -3
  129. data/lib/bio/sequence/na.rb +328 -26
  130. data/lib/bio/shell.rb +11 -4
  131. data/lib/bio/shell/core.rb +221 -160
  132. data/lib/bio/shell/demo.rb +18 -15
  133. data/lib/bio/shell/interface.rb +14 -12
  134. data/lib/bio/shell/irb.rb +95 -0
  135. data/lib/bio/shell/object.rb +45 -26
  136. data/lib/bio/shell/plugin/blast.rb +42 -0
  137. data/lib/bio/shell/plugin/codon.rb +22 -14
  138. data/lib/bio/shell/plugin/das.rb +58 -0
  139. data/lib/bio/shell/plugin/emboss.rb +2 -2
  140. data/lib/bio/shell/plugin/entry.rb +22 -11
  141. data/lib/bio/shell/plugin/flatfile.rb +2 -2
  142. data/lib/bio/shell/plugin/keggapi.rb +13 -6
  143. data/lib/bio/shell/plugin/midi.rb +4 -4
  144. data/lib/bio/shell/plugin/obda.rb +2 -2
  145. data/lib/bio/shell/plugin/psort.rb +56 -0
  146. data/lib/bio/shell/plugin/seq.rb +35 -8
  147. data/lib/bio/shell/plugin/soap.rb +87 -0
  148. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/bioruby_generator.rb +29 -0
  149. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_classes.rhtml +4 -0
  150. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_log.rhtml +27 -0
  151. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_methods.rhtml +11 -0
  152. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_modules.rhtml +4 -0
  153. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_variables.rhtml +7 -0
  154. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-bg.gif +0 -0
  155. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-console.png +0 -0
  156. data/lib/bio/shell/rails/{public/images/icon.png → vendor/plugins/generators/bioruby/templates/bioruby-gem.png} +0 -0
  157. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-link.gif +0 -0
  158. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.css +369 -0
  159. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml +47 -0
  160. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_controller.rb +144 -0
  161. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_helper.rb +47 -0
  162. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/commands.rhtml +8 -0
  163. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/history.rhtml +10 -0
  164. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/index.rhtml +22 -0
  165. data/lib/bio/shell/script.rb +25 -0
  166. data/lib/bio/shell/setup.rb +109 -0
  167. data/lib/bio/shell/web.rb +70 -58
  168. data/lib/bio/tree.rb +850 -0
  169. data/lib/bio/util/color_scheme.rb +84 -107
  170. data/lib/bio/util/color_scheme/buried.rb +5 -24
  171. data/lib/bio/util/color_scheme/helix.rb +5 -24
  172. data/lib/bio/util/color_scheme/hydropathy.rb +5 -24
  173. data/lib/bio/util/color_scheme/nucleotide.rb +5 -24
  174. data/lib/bio/util/color_scheme/strand.rb +5 -24
  175. data/lib/bio/util/color_scheme/taylor.rb +5 -24
  176. data/lib/bio/util/color_scheme/turn.rb +5 -24
  177. data/lib/bio/util/color_scheme/zappo.rb +5 -24
  178. data/lib/bio/util/contingency_table.rb +70 -43
  179. data/lib/bio/util/restriction_enzyme.rb +228 -0
  180. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  181. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  182. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  183. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  184. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  185. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  186. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  187. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  188. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  189. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  190. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  191. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  192. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  193. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  194. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  195. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  196. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  197. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  198. data/lib/bio/util/restriction_enzyme/single_strand.rb +199 -0
  199. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  200. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  201. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  202. data/lib/bio/util/sirna.rb +4 -22
  203. data/sample/color_scheme_na.rb +4 -12
  204. data/sample/enzymes.rb +78 -0
  205. data/sample/goslim.rb +5 -13
  206. data/sample/psortplot_html.rb +4 -12
  207. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  208. data/test/data/embl/AB090716.embl.rel89 +63 -0
  209. data/test/data/fasta/example1.txt +75 -0
  210. data/test/data/fasta/example2.txt +21 -0
  211. data/test/data/iprscan/merged.raw +32 -0
  212. data/test/data/iprscan/merged.txt +74 -0
  213. data/test/data/soft/GDS100_partial.soft +92 -0
  214. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  215. data/test/functional/bio/io/test_ensembl.rb +103 -0
  216. data/test/functional/bio/io/test_soapwsdl.rb +5 -17
  217. data/test/unit/bio/appl/bl2seq/test_report.rb +2 -2
  218. data/test/unit/bio/appl/blast/test_report.rb +3 -16
  219. data/test/unit/bio/appl/blast/test_xmlparser.rb +4 -16
  220. data/test/unit/bio/appl/genscan/test_report.rb +3 -16
  221. data/test/unit/bio/appl/hmmer/test_report.rb +3 -16
  222. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  223. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  224. data/test/unit/bio/appl/sosui/test_report.rb +3 -16
  225. data/test/unit/bio/appl/targetp/test_report.rb +3 -16
  226. data/test/unit/bio/appl/test_blast.rb +3 -16
  227. data/test/unit/bio/appl/test_fasta.rb +4 -16
  228. data/test/unit/bio/appl/test_pts1.rb +140 -0
  229. data/test/unit/bio/appl/tmhmm/test_report.rb +3 -16
  230. data/test/unit/bio/data/test_aa.rb +4 -17
  231. data/test/unit/bio/data/test_codontable.rb +3 -16
  232. data/test/unit/bio/data/test_na.rb +3 -3
  233. data/test/unit/bio/db/embl/test_common.rb +3 -16
  234. data/test/unit/bio/db/embl/test_embl.rb +3 -16
  235. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  236. data/test/unit/bio/db/embl/test_sptr.rb +1548 -41
  237. data/test/unit/bio/db/embl/test_uniprot.rb +3 -16
  238. data/test/unit/bio/db/kegg/test_genes.rb +3 -16
  239. data/test/unit/bio/db/pdb/test_pdb.rb +7 -24
  240. data/test/unit/bio/db/test_aaindex.rb +2 -2
  241. data/test/unit/bio/db/test_fasta.rb +3 -16
  242. data/test/unit/bio/db/test_gff.rb +3 -16
  243. data/test/unit/bio/db/test_lasergene.rb +95 -0
  244. data/test/unit/bio/db/test_newick.rb +56 -0
  245. data/test/unit/bio/db/test_nexus.rb +360 -0
  246. data/test/unit/bio/db/test_prosite.rb +5 -18
  247. data/test/unit/bio/db/test_rebase.rb +11 -25
  248. data/test/unit/bio/db/test_soft.rb +138 -0
  249. data/test/unit/bio/io/test_ddbjxml.rb +5 -17
  250. data/test/unit/bio/io/test_ensembl.rb +109 -0
  251. data/test/unit/bio/io/test_fastacmd.rb +3 -16
  252. data/test/unit/bio/io/test_flatfile.rb +237 -0
  253. data/test/unit/bio/io/test_soapwsdl.rb +4 -17
  254. data/test/unit/bio/sequence/test_aa.rb +3 -3
  255. data/test/unit/bio/sequence/test_common.rb +3 -16
  256. data/test/unit/bio/sequence/test_compat.rb +3 -16
  257. data/test/unit/bio/sequence/test_na.rb +29 -3
  258. data/test/unit/bio/shell/plugin/test_seq.rb +8 -8
  259. data/test/unit/bio/test_alignment.rb +16 -27
  260. data/test/unit/bio/test_command.rb +242 -25
  261. data/test/unit/bio/test_db.rb +3 -16
  262. data/test/unit/bio/test_feature.rb +4 -16
  263. data/test/unit/bio/test_location.rb +4 -16
  264. data/test/unit/bio/test_map.rb +230 -0
  265. data/test/unit/bio/test_pathway.rb +4 -16
  266. data/test/unit/bio/test_reference.rb +2 -2
  267. data/test/unit/bio/test_sequence.rb +7 -19
  268. data/test/unit/bio/test_shell.rb +3 -16
  269. data/test/unit/bio/test_tree.rb +593 -0
  270. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  271. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  272. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  273. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +100 -0
  274. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  275. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  276. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  277. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  278. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  279. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  280. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  281. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  282. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  283. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  284. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  285. data/test/unit/bio/util/test_color_scheme.rb +6 -18
  286. data/test/unit/bio/util/test_contingency_table.rb +6 -18
  287. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  288. data/test/unit/bio/util/test_sirna.rb +3 -16
  289. metadata +228 -169
  290. data/doc/BioRuby.rd.ja +0 -225
  291. data/doc/Design.rd.ja +0 -341
  292. data/doc/TODO.rd.ja +0 -138
  293. data/lib/bio/appl/fasta/format6.rb +0 -37
  294. data/lib/bio/db/kegg/cell.rb +0 -88
  295. data/lib/bio/db/kegg/ko.rb +0 -178
  296. data/lib/bio/shell/rails/Rakefile +0 -10
  297. data/lib/bio/shell/rails/app/controllers/application.rb +0 -4
  298. data/lib/bio/shell/rails/app/controllers/shell_controller.rb +0 -94
  299. data/lib/bio/shell/rails/app/helpers/application_helper.rb +0 -3
  300. data/lib/bio/shell/rails/app/models/shell_connection.rb +0 -30
  301. data/lib/bio/shell/rails/app/views/layouts/shell.rhtml +0 -37
  302. data/lib/bio/shell/rails/app/views/shell/history.rhtml +0 -5
  303. data/lib/bio/shell/rails/app/views/shell/index.rhtml +0 -2
  304. data/lib/bio/shell/rails/app/views/shell/show.rhtml +0 -13
  305. data/lib/bio/shell/rails/config/boot.rb +0 -19
  306. data/lib/bio/shell/rails/config/database.yml +0 -85
  307. data/lib/bio/shell/rails/config/environment.rb +0 -53
  308. data/lib/bio/shell/rails/config/environments/development.rb +0 -19
  309. data/lib/bio/shell/rails/config/environments/production.rb +0 -19
  310. data/lib/bio/shell/rails/config/environments/test.rb +0 -19
  311. data/lib/bio/shell/rails/config/routes.rb +0 -19
  312. data/lib/bio/shell/rails/doc/README_FOR_APP +0 -2
  313. data/lib/bio/shell/rails/public/404.html +0 -8
  314. data/lib/bio/shell/rails/public/500.html +0 -8
  315. data/lib/bio/shell/rails/public/dispatch.cgi +0 -10
  316. data/lib/bio/shell/rails/public/dispatch.fcgi +0 -24
  317. data/lib/bio/shell/rails/public/dispatch.rb +0 -10
  318. data/lib/bio/shell/rails/public/favicon.ico +0 -0
  319. data/lib/bio/shell/rails/public/images/rails.png +0 -0
  320. data/lib/bio/shell/rails/public/index.html +0 -277
  321. data/lib/bio/shell/rails/public/javascripts/controls.js +0 -750
  322. data/lib/bio/shell/rails/public/javascripts/dragdrop.js +0 -584
  323. data/lib/bio/shell/rails/public/javascripts/effects.js +0 -854
  324. data/lib/bio/shell/rails/public/javascripts/prototype.js +0 -1785
  325. data/lib/bio/shell/rails/public/robots.txt +0 -1
  326. data/lib/bio/shell/rails/public/stylesheets/main.css +0 -187
  327. data/lib/bio/shell/rails/script/about +0 -3
  328. data/lib/bio/shell/rails/script/breakpointer +0 -3
  329. data/lib/bio/shell/rails/script/console +0 -3
  330. data/lib/bio/shell/rails/script/destroy +0 -3
  331. data/lib/bio/shell/rails/script/generate +0 -3
  332. data/lib/bio/shell/rails/script/performance/benchmarker +0 -3
  333. data/lib/bio/shell/rails/script/performance/profiler +0 -3
  334. data/lib/bio/shell/rails/script/plugin +0 -3
  335. data/lib/bio/shell/rails/script/process/reaper +0 -3
  336. data/lib/bio/shell/rails/script/process/spawner +0 -3
  337. data/lib/bio/shell/rails/script/process/spinner +0 -3
  338. data/lib/bio/shell/rails/script/runner +0 -3
  339. data/lib/bio/shell/rails/script/server +0 -42
  340. data/lib/bio/shell/rails/test/test_helper.rb +0 -28
@@ -2,25 +2,9 @@
2
2
  # = bio/appl/sim4.rb - sim4 wrapper class
3
3
  #
4
4
  # Copyright:: Copyright (C) 2004 GOTO Naohisa <ng@bioruby.org>
5
- # License:: LGPL
5
+ # License:: The Ruby License
6
6
  #
7
- #--
8
- # This library is free software; you can redistribute it and/or
9
- # modify it under the terms of the GNU Lesser General Public
10
- # License as published by the Free Software Foundation; either
11
- # version 2 of the License, or (at your option) any later version.
12
- #
13
- # This library is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- # Lesser General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU Lesser General Public
19
- # License along with this library; if not, write to the Free Software
20
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- #++
22
- #
23
- # $Id: sim4.rb,v 1.5 2005/12/18 15:58:40 k Exp $
7
+ # $Id: sim4.rb,v 1.10 2007/04/05 23:35:39 trevor Exp $
24
8
  #
25
9
  # The sim4 execution wrapper class.
26
10
  #
@@ -31,8 +15,8 @@
31
15
  # http://www.genome.org/cgi/content/abstract/8/9/967
32
16
  #
33
17
 
34
- require 'open3'
35
18
  require 'tempfile'
19
+ require 'bio/command'
36
20
 
37
21
  module Bio
38
22
 
@@ -45,14 +29,13 @@ module Bio
45
29
  # [+program+] Program name. Usually 'sim4' in UNIX.
46
30
  # [+database+] Default file name of database('seq2').
47
31
  # [+option+] Options (array of strings).
48
- def initialize(program = 'sim4', database = nil, option = [])
32
+ def initialize(program = 'sim4', database = nil, opt = [])
49
33
  @program = program
50
- @option = option
34
+ @options = opt
51
35
  @database = database #seq2
52
36
  @command = nil
53
37
  @output = nil
54
38
  @report = nil
55
- @log = nil
56
39
  end
57
40
 
58
41
  # default file name of database('seq2')
@@ -62,13 +45,27 @@ module Bio
62
45
  attr_reader :program
63
46
 
64
47
  # options
65
- attr_reader :option
48
+ attr_accessor :options
49
+
50
+ # option is deprecated. Instead, please use options.
51
+ def option
52
+ warn "option is deprecated. Please use options."
53
+ options
54
+ end
66
55
 
67
56
  # last command-line strings executed by the object
68
57
  attr_reader :command
69
58
 
59
+ #---
70
60
  # last messages of program reported to the STDERR
71
- attr_reader :log
61
+ #attr_reader :log
62
+ #+++
63
+
64
+ #log is deprecated (no replacement) and returns empty string.
65
+ def log
66
+ warn "log is deprecated (no replacement) and returns empty string."
67
+ ''
68
+ end
72
69
 
73
70
  # last result text (String)
74
71
  attr_reader :output
@@ -110,20 +107,13 @@ module Bio
110
107
  # <tt>filename1</tt> and <tt>filename2</tt> should be file name strings.
111
108
  # If <tt>filename2</tt> is not specified, using <tt>self.database</tt>.
112
109
  def exec_local(filename1, filename2 = nil)
113
- @command = [ @program, filename1, (filename2 or @database), *@option ]
110
+ @command = [ @program, filename1, (filename2 or @database), *@options ]
114
111
  @output = nil
115
- @log = nil
116
112
  @report = nil
117
- Open3.popen3(*@command) do |din, dout, derr|
118
- din.close
119
- derr.sync = true
120
- t = Thread.start { @log = derr.read }
121
- begin
122
- @output = dout.read
123
- @report = Bio::Sim4::Report.new(@output)
124
- ensure
125
- t.join
126
- end
113
+ Bio::Command.call_command(@command) do |io|
114
+ io.close_write
115
+ @output = io.read
116
+ @report = Bio::Sim4::Report.new(@output)
127
117
  end
128
118
  @report
129
119
  end
@@ -2,25 +2,9 @@
2
2
  # = bio/appl/sim4/report.rb - sim4 result parser
3
3
  #
4
4
  # Copyright:: Copyright (C) 2004 GOTO Naohisa <ng@bioruby.org>
5
- # License:: LGPL
5
+ # License:: The Ruby License
6
6
  #
7
- #--
8
- # This library is free software; you can redistribute it and/or
9
- # modify it under the terms of the GNU Lesser General Public
10
- # License as published by the Free Software Foundation; either
11
- # version 2 of the License, or (at your option) any later version.
12
- #
13
- # This library is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- # Lesser General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU Lesser General Public
19
- # License along with this library; if not, write to the Free Software
20
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- #++
22
- #
23
- # $Id: report.rb,v 1.7 2005/12/18 15:58:40 k Exp $
7
+ # $Id: report.rb,v 1.9 2007/04/05 23:35:40 trevor Exp $
24
8
  #
25
9
  # The sim4 report parser classes.
26
10
  #
@@ -1,32 +1,17 @@
1
1
  #
2
2
  # = bio/appl/sosui/report.rb - SOSUI report class
3
3
  #
4
- # Copyright:: Copyright (C) 2003 Mitsuteru C. Nakao <n@bioruby.org>
5
- # License:: LGPL
4
+ # Copyright:: Copyright (C) 2003
5
+ # Mitsuteru C. Nakao <n@bioruby.org>
6
+ # License:: The Ruby License
6
7
  #
7
- # $Id: report.rb,v 1.9 2005/12/18 15:58:41 k Exp $
8
+ # $Id: report.rb,v 1.11 2007/04/05 23:35:40 trevor Exp $
8
9
  #
9
10
  # == Example
10
11
  #
11
12
  # == References
12
- # * http://sosui.proteome.bio.tuat.ac.jp/sosui_submit.html
13
- #--
14
- #
15
- # This library is free software; you can redistribute it and/or
16
- # modify it under the terms of the GNU Lesser General Public
17
- # License as published by the Free Software Foundation; either
18
- # version 2 of the License, or (at your option) any later version.
19
- #
20
- # This library is distributed in the hope that it will be useful,
21
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
- # Lesser General Public License for more details.
24
13
  #
25
- # You should have received a copy of the GNU Lesser General Public
26
- # License along with this library; if not, write to the Free Software
27
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
- #
29
- #++
14
+ # * http://sosui.proteome.bio.tuat.ac.jp/sosui_submit.html
30
15
  #
31
16
 
32
17
 
@@ -2,9 +2,9 @@
2
2
  # = bio/appl/spidey/report.rb - SPIDEY result parser
3
3
  #
4
4
  # Copyright:: Copyright (C) 2004 GOTO Naohisa <ng@bioruby.org>
5
- # License:: Ruby's
5
+ # License:: The Ruby License
6
6
  #
7
- # $Id: report.rb,v 1.9 2006/02/22 08:46:15 ngoto Exp $
7
+ # $Id: report.rb,v 1.10 2007/04/05 23:35:40 trevor Exp $
8
8
  #
9
9
  # NCBI Spidey result parser.
10
10
  # Currently, output of default (-p 0 option) or -p 1 option are supported.
@@ -1,10 +1,11 @@
1
1
  #
2
2
  # = bio/appl/targetp/report.rb - TargetP report class
3
3
  #
4
- # Copyright:: Copyright (C) 2003 Mitsuteru C. Nakao <n@bioruby.org>
5
- # License:: LGPL
4
+ # Copyright:: Copyright (C) 2003
5
+ # Mitsuteru C. Nakao <n@bioruby.org>
6
+ # License:: The Ruby License
6
7
  #
7
- # $Id: report.rb,v 1.7 2005/12/18 15:58:41 k Exp $
8
+ # $Id: report.rb,v 1.9 2007/04/05 23:35:40 trevor Exp $
8
9
  #
9
10
  # == Description
10
11
  #
@@ -12,23 +13,6 @@
12
13
  #
13
14
  # == Example
14
15
  # == References
15
- #--
16
- #
17
- # This library is free software; you can redistribute it and/or
18
- # modify it under the terms of the GNU Lesser General Public
19
- # License as published by the Free Software Foundation; either
20
- # version 2 of the License, or (at your option) any later version.
21
- #
22
- # This library is distributed in the hope that it will be useful,
23
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25
- # Lesser General Public License for more details.
26
- #
27
- # You should have received a copy of the GNU Lesser General Public
28
- # License along with this library; if not, write to the Free Software
29
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
- #
31
- #++
32
16
  #
33
17
 
34
18
  module Bio
@@ -0,0 +1,55 @@
1
+ #
2
+ # = bio/appl/tcoffee.rb - T-Coffee application wrapper class
3
+ #
4
+ # Copyright:: Copyright (C) 2006-2007
5
+ # Jeffrey Blakeslee and John Conery University of Oregon <jeffb@uoregon.edu>
6
+ # Naohisa Goto <ng@bioruby.org>
7
+ # License:: The Ruby License
8
+ #
9
+ # $Id: tcoffee.rb,v 1.1 2007/07/16 12:25:50 ngoto Exp $
10
+ #
11
+ # Bio::Tcoffee is a wrapper class to execute T-Coffee.
12
+ #
13
+ # == References
14
+ #
15
+ # * http://www.tcoffee.org/Projects_home_page/t_coffee_home_page.html
16
+ # * Notredame, C., Higgins, D.G. and Heringa, J.
17
+ # T-Coffee: A novel method for fast and accurate multiple sequence
18
+ # alignment. J. Mol. Biol. 302: 205-217, 2000.
19
+ #
20
+
21
+
22
+ module Bio
23
+
24
+ # Bio::Tcoffee is a wrapper class to execute t-coffee.
25
+ #
26
+ # Please refer documents in bio/apple/tcoffee.rb for references.
27
+ class Tcoffee < Bio::Alignment::FactoryTemplate::FileInFileOutWithTree
28
+
29
+ # default program name
30
+ DEFAULT_PROGRAM = 't_coffee'.freeze
31
+
32
+ # default report parser
33
+ DEFAULT_PARSER = Bio::ClustalW::Report
34
+
35
+ private
36
+ # generates options specifying input filename.
37
+ # returns an array of string
38
+ def _option_input_file(fn)
39
+ [ '-infile', fn ]
40
+ end
41
+
42
+ # generates options specifying output filename.
43
+ # returns an array of string
44
+ def _option_output_file(fn)
45
+ [ '-outfile', fn ]
46
+ end
47
+
48
+ # generates options specifying output filename.
49
+ # returns an array of string
50
+ def _option_output_dndfile(fn)
51
+ [ '-newtree', fn ]
52
+ end
53
+ end #class TCoffee
54
+
55
+ end #module Bio
@@ -1,33 +1,17 @@
1
1
  #
2
2
  # = bio/appl/tmhmm/report.rb - TMHMM report class
3
3
  #
4
- # Copyright:: Copyright (C) 2003 Mitsuteru C. Nakao <n@bioruby.org>
5
- # License:: LGPL
4
+ # Copyright:: Copyright (C) 2003
5
+ # Mitsuteru C. Nakao <n@bioruby.org>
6
+ # License:: The Ruby License
6
7
  #
7
- # $Id: report.rb,v 1.6 2005/12/18 15:58:41 k Exp $
8
+ # $Id: report.rb,v 1.8 2007/04/05 23:35:40 trevor Exp $
8
9
  #
9
10
  # == Description
10
11
  #
11
12
  #
12
13
  # == Example
13
14
  # == References
14
- #--
15
- #
16
- # This library is free software; you can redistribute it and/or
17
- # modify it under the terms of the GNU Lesser General Public
18
- # License as published by the Free Software Foundation; either
19
- # version 2 of the License, or (at your option) any later version.
20
- #
21
- # This library is distributed in the hope that it will be useful,
22
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
- # Lesser General Public License for more details.
25
- #
26
- # You should have received a copy of the GNU Lesser General Public
27
- # License along with this library; if not, write to the Free Software
28
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
- #
30
- #++
31
15
  #
32
16
 
33
17
  module Bio
@@ -1,51 +1,35 @@
1
1
  #
2
2
  # = bio/command.rb - general methods for external command execution
3
3
  #
4
- # Copyright:: Copyright (C) 2003-2005
4
+ # Copyright:: Copyright (C) 2003-2006
5
5
  # Naohisa Goto <ng@bioruby.org>,
6
6
  # Toshiaki Katayama <k@bioruby.org>
7
- # License:: LGPL
7
+ # License:: The Ruby License
8
8
  #
9
- # $Id: command.rb,v 1.3 2005/11/04 17:36:00 k Exp $
10
- #
11
- #--
12
- #
13
- # This library is free software; you can redistribute it and/or
14
- # modify it under the terms of the GNU Lesser General Public
15
- # License as published by the Free Software Foundation; either
16
- # version 2 of the License, or (at your option) any later version.
17
- #
18
- # This library is distributed in the hope that it will be useful,
19
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
- # Lesser General Public License for more details.
22
- #
23
- # You should have received a copy of the GNU Lesser General Public
24
- # License along with this library; if not, write to the Free Software
25
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
- #
27
- #++
9
+ # $Id: command.rb,v 1.17 2007/04/05 23:35:39 trevor Exp $
28
10
  #
29
11
 
30
12
  require 'open3'
13
+ require 'uri'
14
+ require 'open-uri'
15
+ require 'net/http'
31
16
 
32
17
  module Bio
33
- module Command
34
18
 
35
- # = Bio::Command::Tools
19
+ # = Bio::Command
20
+ #
21
+ # Bio::Command is a collection of useful methods for execution
22
+ # of external commands or web applications.
23
+ # Any wrapper class for applications shall use this class.
36
24
  #
37
- # Bio::Command::Tools is a collection of useful methods for execution
38
- # of external commands or web applications. Any wrapper class for
39
- # applications shall include this class. Note that all methods below
40
- # are private except for some methods.
41
- module Tools
25
+ # Library internal use only. Users should not directly use it.
26
+ module Command
42
27
 
43
28
  UNSAFE_CHARS_UNIX = /[^A-Za-z0-9\_\-\.\:\,\/\@\x1b\x80-\xfe]/n
44
29
  QUOTE_CHARS_WINDOWS = /[^A-Za-z0-9\_\-\.\:\,\/\@\\]/n
45
30
  UNESCAPABLE_CHARS = /[\x00-\x08\x10-\x1a\x1c-\x1f\x7f\xff]/n
46
31
 
47
- #module_function
48
- private
32
+ module_function
49
33
 
50
34
  # Escape special characters in command line string for cmd.exe on Windows.
51
35
  def escape_shell_windows(str)
@@ -98,69 +82,256 @@ module Tools
98
82
  end
99
83
 
100
84
  # Executes the program. Automatically select popen for Windows
101
- # environment and open3 for the others.
102
- #
103
- # If block is given, yield the block with input and output IO objects.
104
- # Note that in some platform, inn and out are the same object.
105
- # Please be careful to do inn.close and out.close.
106
- def call_command_local(cmd, query = nil, &block)
85
+ # environment and fork for the others.
86
+ # A block must be given. An IO object is passed to the block.
87
+ def call_command(cmd, &block)
107
88
  case RUBY_PLATFORM
108
89
  when /mswin32|bccwin32/
109
- call_command_local_popen(cmd, query, &block)
90
+ call_command_popen(cmd, &block)
110
91
  else
111
- call_command_local_open3(cmd, query, &block)
92
+ call_command_fork(cmd, &block)
112
93
  end
113
94
  end
114
95
 
115
96
  # Executes the program via IO.popen for OS which doesn't support fork.
116
- # If block is given, yield the block with IO objects.
117
- # The two objects are the same because of limitation of IO.popen.
118
- def call_command_local_popen(cmd, query = nil)
97
+ # A block must be given. An IO object is passed to the block.
98
+ def call_command_popen(cmd)
119
99
  str = make_command_line(cmd)
120
100
  IO.popen(str, "w+") do |io|
121
- if block_given? then
122
- io.sync = true
123
- yield io, io
101
+ io.sync = true
102
+ yield io
103
+ end
104
+ end
105
+
106
+ # Executes the program via fork (by using IO.popen("-")) and exec.
107
+ # A block must be given. An IO object is passed to the block.
108
+ #
109
+ # From the view point of security, this method is recommended
110
+ # rather than call_command_popen.
111
+ def call_command_fork(cmd)
112
+ IO.popen("-", "r+") do |io|
113
+ if io then
114
+ # parent
115
+ yield io
124
116
  else
117
+ # child
118
+ begin
119
+ Kernel.exec(*cmd)
120
+ rescue Errno::ENOENT, Errno::EACCES
121
+ Process.exit!(127)
122
+ rescue Exception
123
+ end
124
+ Process.exit!(1)
125
+ end
126
+ end
127
+ end
128
+
129
+ # Executes the program via Open3.popen3
130
+ # A block must be given. IO objects are passed to the block.
131
+ #
132
+ # You would use this method only when you really need to get stderr.
133
+ def call_command_open3(cmd)
134
+ cmd = cmd.collect { |x| x.to_s }
135
+ Open3.popen3(*cmd) do |pin, pout, perr|
136
+ yield pin, pout, perr
137
+ end
138
+ end
139
+
140
+ # Executes the program with the query (String) given to the standard input,
141
+ # waits the program termination, and returns the output data printed to the
142
+ # standard output as a string.
143
+ #
144
+ # Automatically select popen for Windows environment and fork for the others.
145
+ def query_command(cmd, query = nil)
146
+ case RUBY_PLATFORM
147
+ when /mswin32|bccwin32/
148
+ query_command_popen(cmd, query)
149
+ else
150
+ query_command_fork(cmd, query)
151
+ end
152
+ end
153
+
154
+ # Executes the program with the query (String) given to the standard input,
155
+ # waits the program termination, and returns the output data printed to the
156
+ # standard output as a string.
157
+ #
158
+ # IO.popen is used for OS which doesn't support fork.
159
+ def query_command_popen(cmd, query = nil)
160
+ str = make_command_line(cmd)
161
+ IO.popen(str, "w+") do |io|
162
+ io.sync = true
163
+ io.print query if query
164
+ io.close_write
165
+ io.read
166
+ end
167
+ end
168
+
169
+ # Executes the program with the query (String) given to the standard input,
170
+ # waits the program termination, and returns the output data printed to the
171
+ # standard output as a string.
172
+ #
173
+ # Fork (by using IO.popen("-")) and exec is used to execute the program.
174
+ #
175
+ # From the view point of security, this method is recommended
176
+ # rather than query_popen.
177
+ def query_command_fork(cmd, query = nil)
178
+ IO.popen("-", "r+") do |io|
179
+ if io then
180
+ # parent
125
181
  io.sync = true
126
182
  io.print query if query
127
183
  io.close_write
128
184
  io.read
185
+ else
186
+ # child
187
+ begin
188
+ Kernel.exec(*cmd)
189
+ rescue Errno::ENOENT, Errno::EACCES
190
+ Process.exit!(127)
191
+ rescue Exception
192
+ end
193
+ Process.exit!(1)
129
194
  end
130
195
  end
131
196
  end
132
197
 
133
- # Executes the program via Open3.popen3
134
- # If block is given, yield the block with input and output IO objects.
198
+ # Executes the program via Open3.popen3 with the query (String) given
199
+ # to the stain, waits the program termination, and
200
+ # returns the data from stdout and stderr as an array of the strings.
135
201
  #
136
202
  # From the view point of security, this method is recommended
137
203
  # rather than exec_local_popen.
138
- def call_command_local_open3(cmd, query = nil)
204
+ def query_command_open3(cmd, query = nil)
205
+ errorlog = nil
139
206
  cmd = cmd.collect { |x| x.to_s }
140
207
  Open3.popen3(*cmd) do |pin, pout, perr|
141
208
  perr.sync = true
142
- t = Thread.start { @errorlog = perr.read }
143
- if block_given? then
144
- yield pin, pout
145
- else
146
- begin
147
- pin.print query if query
148
- pin.close
149
- output = pout.read
150
- ensure
151
- t.join
152
- end
153
- output
209
+ t = Thread.start { errorlog = perr.read }
210
+ begin
211
+ pin.print query if query
212
+ pin.close
213
+ output = pout.read
214
+ ensure
215
+ t.join
154
216
  end
217
+ [ output, errorlog ]
218
+ end
219
+ end
220
+
221
+ # Same as OpenURI.open_uri(uri).read.
222
+ def read_uri(uri)
223
+ OpenURI.open_uri(uri).read
224
+ end
225
+
226
+ # Same as:
227
+ # Net::HTTP.start(address, port)
228
+ # and
229
+ # it uses proxy if an environment variable (same as OpenURI.open_uri)
230
+ # is set.
231
+ #
232
+ def start_http(address, port = 80, &block)
233
+ uri = URI.parse("http://#{address}:#{port}")
234
+ # Note: URI#find_proxy is an unofficial method defined in open-uri.rb.
235
+ # If the spec of open-uri.rb would be changed, we should change below.
236
+ if proxyuri = uri.find_proxy then
237
+ raise 'Non-HTTP proxy' if proxyuri.class != URI::HTTP
238
+ http = Net::HTTP.Proxy(proxyuri.host, proxyuri.port)
239
+ else
240
+ http = Net::HTTP
155
241
  end
242
+ http.start(address, port, &block)
156
243
  end
157
244
 
158
- # Shows the latest stderr of the program execution.
159
- # Note that this method may be thread unsafe.
160
- attr_reader :errorlog
161
- public :errorlog
245
+ # Same as:
246
+ # Net::HTTP.new(address, port)
247
+ # and
248
+ # it uses proxy if an environment variable (same as OpenURI.open_uri)
249
+ # is set.
250
+ #
251
+ def new_http(address, port = 80)
252
+ uri = URI.parse("http://#{address}:#{port}")
253
+ # Note: URI#find_proxy is an unofficial method defined in open-uri.rb.
254
+ # If the spec of open-uri.rb would be changed, we should change below.
255
+ if proxyuri = uri.find_proxy then
256
+ raise 'Non-HTTP proxy' if proxyuri.class != URI::HTTP
257
+ Net::HTTP.new(address, port, proxyuri.host, proxyuri.port)
258
+ else
259
+ Net::HTTP.new(address, port)
260
+ end
261
+ end
262
+
263
+ # Same as:
264
+ # Net::HTTP.post_form(uri, params)
265
+ # and
266
+ # it uses proxy if an environment variable (same as OpenURI.open_uri)
267
+ # is set.
268
+ # In addition, +header+ can be set.
269
+ # (Note that Content-Type and Content-Length are automatically
270
+ # set by default.)
271
+ # +uri+ must be a URI object, +params+ must be a hash, and
272
+ # +header+ must be a hash.
273
+ #
274
+ def post_form(uri, params = nil, header = {})
275
+ unless uri.is_a?(URI)
276
+ uri = URI.parse(uri)
277
+ end
278
+
279
+ data = make_cgi_params(params)
280
+
281
+ hash = {
282
+ 'Content-Type' => 'application/x-www-form-urlencoded',
283
+ 'Content-Length' => data.length.to_s
284
+ }
285
+ hash.update(header)
286
+
287
+ start_http(uri.host, uri.port) do |http|
288
+ http.post(uri.path, data, hash)
289
+ end
290
+ end
291
+
292
+ def make_cgi_params(params)
293
+ data = ""
294
+ case params
295
+ when Hash
296
+ data = params.map do |key, val|
297
+ make_cgi_params_key_value(key, val)
298
+ end.join('&')
299
+ when Array
300
+ case params.first
301
+ when Hash
302
+ data = params.map do |hash|
303
+ hash.map do |key, val|
304
+ make_cgi_params_key_value(key, val)
305
+ end
306
+ end.join('&')
307
+ when Array
308
+ data = params.map do |key, val|
309
+ make_cgi_params_key_value(key, val)
310
+ end.join('&')
311
+ when String
312
+ data = params.map do |str|
313
+ URI.escape(str.strip)
314
+ end.join('&')
315
+ end
316
+ when String
317
+ data = URI.escape(params.strip)
318
+ end
319
+ return data
320
+ end
321
+
322
+ def make_cgi_params_key_value(key, value)
323
+ result = []
324
+ case value
325
+ when Array
326
+ value.each do |val|
327
+ result << [key, val].map {|x| URI.escape(x.to_s) }.join('=')
328
+ end
329
+ else
330
+ result << [key, value].map {|x| URI.escape(x.to_s) }.join('=')
331
+ end
332
+ return result
333
+ end
162
334
 
163
- end # module Tools
164
335
  end # module Command
165
336
  end # module Bio
166
337