bio 1.0.0 → 1.1.0

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 (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
@@ -1,23 +1,10 @@
1
1
  #
2
2
  # test/unit/bio/test_db.rb - Unit test for Bio::DB
3
3
  #
4
- # Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
4
+ # Copyright:: Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
5
+ # License:: The Ruby License
5
6
  #
6
- # This library is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU Lesser General Public
8
- # License as published by the Free Software Foundation; either
9
- # version 2 of the License, or (at your option) any later version.
10
- #
11
- # This library is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with this library; if not, write to the Free Software
18
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- #
20
- # $Id: test_db.rb,v 1.2 2005/11/23 11:44:12 nakao Exp $
7
+ # $Id: test_db.rb,v 1.4 2007/04/05 23:35:42 trevor Exp $
21
8
  #
22
9
 
23
10
  require 'pathname'
@@ -1,23 +1,11 @@
1
1
  #
2
2
  # test/unit/bio/test_feature.rb - Unit test for Features/Feature classes
3
3
  #
4
- # Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
4
+ # Copyright:: Copyright (C) 2005
5
+ # Mitsuteru Nakao <n@bioruby.org>
6
+ # License:: The Ruby License
5
7
  #
6
- # This library is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU Lesser General Public
8
- # License as published by the Free Software Foundation; either
9
- # version 2 of the License, or (at your option) any later version.
10
- #
11
- # This library is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with this library; if not, write to the Free Software
18
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- #
20
- # $Id: test_feature.rb,v 1.2 2005/11/23 11:47:12 nakao Exp $
8
+ # $Id: test_feature.rb,v 1.5 2007/04/05 23:35:42 trevor Exp $
21
9
  #
22
10
 
23
11
  require 'pathname'
@@ -1,23 +1,11 @@
1
1
  #
2
2
  # test/unit/bio/test_location.rb - Unit test for Bio::Location
3
3
  #
4
- # Copyright (C) 2004 Moses Hohman <mmhohman@northwestern.edu>
4
+ # Copyright:: Copyright (C) 2004
5
+ # Moses Hohman <mmhohman@northwestern.edu>
6
+ # License:: The Ruby License
5
7
  #
6
- # This library is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU Lesser General Public
8
- # License as published by the Free Software Foundation; either
9
- # version 2 of the License, or (at your option) any later version.
10
- #
11
- # This library is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with this library; if not, write to the Free Software
18
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- #
20
- # $Id: test_location.rb,v 1.2 2005/09/24 03:12:55 nakao Exp $
8
+ # $Id: test_location.rb,v 1.4 2007/04/05 23:35:42 trevor Exp $
21
9
  #
22
10
 
23
11
  require 'pathname'
@@ -0,0 +1,230 @@
1
+ #
2
+ # = test/unit/bio/test_map.rb - Unit test for Bio::Map
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id:
9
+
10
+ require 'pathname'
11
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s
12
+ $:.unshift(libpath) unless $:.include?(libpath)
13
+
14
+ require 'test/unit'
15
+ require 'bio/map'
16
+
17
+ module Bio
18
+ class TestMapSimple < Test::Unit::TestCase
19
+ def setup
20
+ @marker1 = Bio::Map::Marker.new('marker1')
21
+ @marker2 = Bio::Map::Marker.new('marker2')
22
+ @map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 500, 'some_unit')
23
+ end
24
+
25
+ def test_attributes
26
+ assert_equal("marker1", @marker1.name)
27
+ assert_equal("marker2", @marker2.name)
28
+ assert_equal([], @marker1.mappings_as_marker)
29
+ assert_equal([], @marker2.mappings_as_marker)
30
+ assert_equal("map1", @map1.name)
31
+ assert_equal("some_unit", @map1.units)
32
+ assert_equal("some_type", @map1.type)
33
+ assert_equal([], @map1.mappings_as_map)
34
+ end
35
+ end
36
+
37
+ class TestMapping < Test::Unit::TestCase
38
+ def setup
39
+ @marker1 = Bio::Map::Marker.new('marker1')
40
+ @marker2 = Bio::Map::Marker.new('marker2')
41
+ @marker3 = Bio::Map::Marker.new('marker3')
42
+ @map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 'some_unit')
43
+ @map2 = Bio::Map::SimpleMap.new('map2', 'some_other_type', 'some_other_unit')
44
+ end
45
+
46
+ def test_add_mapping_as_map
47
+ @map1.add_mapping_as_map(@marker2, '5')
48
+ assert_equal(1, @map1.mappings_as_map.length)
49
+ assert_equal(1, @marker2.mappings_as_marker.length)
50
+ assert_equal(0, @marker1.mappings_as_marker.length)
51
+ assert_kind_of(Bio::Locations, @map1.mappings_as_map[0].location)
52
+ assert_kind_of(Bio::Locations, @marker2.mappings_as_marker[0].location)
53
+ end
54
+
55
+ def test_add_mapping_as_marker
56
+ @marker1.add_mapping_as_marker(@map1, '5')
57
+ assert_equal(1, @map1.mappings_as_map.length, 'Mapping as map')
58
+ assert_equal(1, @marker1.mappings_as_marker.length, 'Mapping as marker')
59
+ assert_kind_of(Bio::Locations, @map1.mappings_as_map[0].location)
60
+ assert_kind_of(Bio::Locations, @marker1.mappings_as_marker[0].location)
61
+ end
62
+
63
+ def test_mapped_to?
64
+ @marker1.add_mapping_as_marker(@map1, '5')
65
+ assert_equal(true, @marker1.mapped_to?(@map1))
66
+ assert_equal(false, @marker3.mapped_to?(@map1))
67
+ end
68
+
69
+ def test_contains_marker?
70
+ @marker1.add_mapping_as_marker(@map1, '5')
71
+ assert_equal(true, @map1.contains_marker?(@marker1))
72
+ assert_equal(false, @map1.contains_marker?(@marker3))
73
+ end
74
+
75
+ def test_mappings_as_map_each
76
+ @map1.add_mapping_as_map(@marker1, '5')
77
+ @marker2.add_mapping_as_marker(@map1, '7')
78
+ mappings = 0
79
+ @map1.mappings_as_map.each do |mapping|
80
+ mappings += 1
81
+ end
82
+ assert_equal(2, mappings)
83
+ end
84
+
85
+ def test_mappings_as_marker_each
86
+ @map1.add_mapping_as_map(@marker1, '5')
87
+ @marker1.add_mapping_as_marker(@map1, '7')
88
+ mappings = 0
89
+ @marker1.mappings_as_marker.each do |mapping|
90
+ mappings += 1
91
+ end
92
+ assert_equal(2, mappings)
93
+
94
+ end
95
+
96
+ def test_multiple_mappings_between_same_marker_and_map
97
+ @map1.add_mapping_as_map(@marker1, '5')
98
+ @map1.add_mapping_as_map(@marker1, '37')
99
+ @marker1.add_mapping_as_marker(@map1, '53')
100
+ assert_equal(3, @marker1.mappings_as_marker.length)
101
+
102
+ @marker1.add_mapping_as_marker(@map1, '53') # This mapping should _not_ be added, because it's already defined.
103
+ assert_equal(3, @marker1.mappings_as_marker.length)
104
+
105
+ @map1.add_mapping_as_map(@marker1, '53')
106
+ assert_equal(3, @marker1.mappings_as_marker.length)
107
+ end
108
+
109
+ def test_positions_on
110
+ @map1.add_mapping_as_map(@marker1, '5')
111
+ assert_equal(1, @marker1.mappings_as_marker.length)
112
+ assert_equal('5', @marker1.positions_on(@map1).collect{|p| p.first.from.to_s}.join(',')) # FIXME: Test is not correct (uses Location.first)
113
+ @map1.add_mapping_as_map(@marker1, '37')
114
+ assert_equal('5,37', @marker1.positions_on(@map1).collect{|p| p.first.from.to_s}.sort{|a,b| a.to_i <=> b.to_i}.join(',')) # FIXME: Test is not correct (uses Location.first)
115
+ end
116
+
117
+ def test_mappings_on
118
+ @map1.add_mapping_as_map(@marker1, '5')
119
+ @map1.add_mapping_as_map(@marker1, '37')
120
+ assert_equal('5,37', @marker1.mappings_on(@map1).sort{|a,b| a.location[0].from.to_i <=> b.location[0].from.to_i}.collect{|m| m.location[0].from}.join(',')) # FIXME: Test is not correct (uses Location.first)
121
+ end
122
+
123
+ def test_mapping_location_comparison
124
+ @map1.add_mapping_as_map(@marker1, '5')
125
+ @map1.add_mapping_as_map(@marker2, '5')
126
+ @map1.add_mapping_as_map(@marker3, '17')
127
+
128
+ mapping1 = @marker1.mappings_on(@map1)[0]
129
+ mapping2 = @marker2.mappings_on(@map1)[0]
130
+ mapping3 = @marker3.mappings_on(@map1)[0]
131
+ assert_equal(true, mapping1 == mapping2)
132
+ assert_equal(false, mapping1 < mapping2)
133
+ assert_equal(false, mapping1 > mapping2)
134
+ assert_equal(false, mapping1 == mapping3)
135
+ assert_equal(true, mapping1 < mapping3)
136
+ assert_equal(false, mapping1 > mapping3)
137
+
138
+ @map2.add_mapping_as_map(@marker1, '23')
139
+ mapping4 = @marker1.mappings_on(@map2)[0]
140
+ assert_raise(RuntimeError) { mapping2 < mapping4 }
141
+ end
142
+
143
+ def test_raise_error_kind_of
144
+ marker_without_class = 'marker1'
145
+ assert_raise(RuntimeError) { @map1.add_mapping_as_map(marker_without_class, '5') }
146
+ assert_raise(RuntimeError) { @map1.contains_marker?(marker_without_class) }
147
+
148
+ map_without_class = 'map1'
149
+ assert_raise(RuntimeError) { @marker1.add_mapping_as_marker(map_without_class, '5') }
150
+ assert_raise(RuntimeError) { @marker1.mapped_to?(map_without_class) }
151
+ assert_raise(RuntimeError) { @marker1.positions_on(map_without_class) }
152
+ assert_raise(RuntimeError) { @marker1.mappings_on(map_without_class) }
153
+
154
+ @map1.add_mapping_as_map(@marker1, '5')
155
+ mapping1 = @marker1.mappings_on(@map1)[0]
156
+ assert_raise(RuntimeError) { mapping1 > 'some_mapping' }
157
+ end
158
+ end
159
+
160
+ class CloneToActLikeMap
161
+ include Bio::Map::ActsLikeMap
162
+ def initialize
163
+ @mappings_as_map = Array.new
164
+ end
165
+ attr_accessor :mappings_as_map
166
+ end
167
+
168
+ class TestActsLikeMap < Test::Unit::TestCase
169
+ def setup
170
+ @clone = CloneToActLikeMap.new
171
+ end
172
+ def test_mixin
173
+ assert_instance_of(CloneToActLikeMap, @clone)
174
+ assert_respond_to(@clone, 'contains_marker?')
175
+ assert_respond_to(@clone, 'add_mapping_as_map')
176
+ assert_equal(0, @clone.mappings_as_map.length)
177
+ end
178
+ end
179
+
180
+ class CloneToActLikeMarker
181
+ include Bio::Map::ActsLikeMarker
182
+ def initialize
183
+ @mappings_as_marker = Array.new
184
+ end
185
+ attr_accessor :mappings_as_marker
186
+ end
187
+
188
+ class TestActsLikeMarker < Test::Unit::TestCase
189
+ def setup
190
+ @clone = CloneToActLikeMarker.new
191
+ end
192
+
193
+ def test_mixin
194
+ assert_instance_of(CloneToActLikeMarker, @clone)
195
+ assert_respond_to(@clone, 'mapped_to?')
196
+ assert_respond_to(@clone, 'add_mapping_as_marker')
197
+ end
198
+ end
199
+
200
+ class CloneToActLikeMapAndMarker
201
+ include Bio::Map::ActsLikeMap
202
+ include Bio::Map::ActsLikeMarker
203
+ def initialize
204
+ @mappings_as_map = Array.new
205
+ @mappings_as_marker = Array.new
206
+ end
207
+ attr_accessor :mappings_as_map, :mappings_as_marker
208
+ end
209
+
210
+ class TestActsLikeMapAndMarker < Test::Unit::TestCase
211
+ def setup
212
+ @clone_a = CloneToActLikeMapAndMarker.new
213
+ @clone_b = CloneToActLikeMapAndMarker.new
214
+ @clone_a.add_mapping_as_map(@clone_b, nil)
215
+ end
216
+
217
+ def test_mixin
218
+ assert_instance_of(CloneToActLikeMapAndMarker, @clone_a)
219
+ assert_respond_to(@clone_a, 'contains_marker?')
220
+ assert_respond_to(@clone_a, 'add_mapping_as_map')
221
+ assert_respond_to(@clone_a, 'mapped_to?')
222
+ assert_respond_to(@clone_a, 'add_mapping_as_marker')
223
+
224
+ assert_equal(1, @clone_a.mappings_as_map.length)
225
+ assert_equal(0, @clone_a.mappings_as_marker.length)
226
+ assert_equal(0, @clone_b.mappings_as_map.length)
227
+ assert_equal(1, @clone_b.mappings_as_marker.length)
228
+ end
229
+ end
230
+ end
@@ -1,23 +1,11 @@
1
1
  #
2
2
  # test/bio/tc_pathway.rb - Unit test for Bio::Pathway
3
3
  #
4
- # Copyright (C) 2004 Moses Hohman <mmhohman@northwestern.edu>
4
+ # Copyright:: Copyright (C) 2004
5
+ # Moses Hohman <mmhohman@northwestern.edu>
6
+ # License:: The Ruby License
5
7
  #
6
- # This library is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU Lesser General Public
8
- # License as published by the Free Software Foundation; either
9
- # version 2 of the License, or (at your option) any later version.
10
- #
11
- # This library is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with this library; if not, write to the Free Software
18
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- #
20
- # $Id: test_pathway.rb,v 1.3 2005/12/18 16:50:56 k Exp $
8
+ # $Id: test_pathway.rb,v 1.5 2007/04/05 23:35:42 trevor Exp $
21
9
  #
22
10
 
23
11
  require 'pathname'
@@ -3,9 +3,9 @@
3
3
  #
4
4
  # Copyright:: Copyright (C) 2006
5
5
  # Mitsuteru C. Nakao <n@bioruby.org>
6
- # Lisence:: Ruby's
6
+ # License:: The Ruby License
7
7
  #
8
- # $Id: test_reference.rb,v 1.1 2006/02/08 15:06:26 nakao Exp $
8
+ # $Id: test_reference.rb,v 1.3 2007/04/05 23:35:42 trevor Exp $
9
9
  #
10
10
 
11
11
  require 'pathname'
@@ -1,24 +1,12 @@
1
1
  #
2
2
  # test/unit/bio/test_sequence.rb - Unit test for Bio::Sequencce
3
3
  #
4
- # Copyright (C) 2004 Moses Hohman <mmhohman@northwestern.edu>
5
- # Copyright (C) 2006 Mitsuteru C. Nakao <n@bioruby.org>
4
+ # Copyright:: Copyright (C) 2004
5
+ # Moses Hohman <mmhohman@northwestern.edu>
6
+ # 2006 Mitsuteru C. Nakao <n@bioruby.org>
7
+ # License:: The Ruby License
6
8
  #
7
- # This library is free software; you can redistribute it and/or
8
- # modify it under the terms of the GNU Lesser General Public
9
- # License as published by the Free Software Foundation; either
10
- # version 2 of the License, or (at your option) any later version.
11
- #
12
- # This library is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- # Lesser General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU Lesser General Public
18
- # License along with this library; if not, write to the Free Software
19
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
- #
21
- # $Id: test_sequence.rb,v 1.6 2006/02/05 17:39:27 nakao Exp $
9
+ # $Id: test_sequence.rb,v 1.9 2007/04/05 23:35:42 trevor Exp $
22
10
  #
23
11
 
24
12
  require 'pathname'
@@ -202,11 +190,11 @@ module Bio
202
190
  # Test Sequence::NA#to_re
203
191
 
204
192
  def test_dna_to_re
205
- assert_equal(/atgc[ag][tc][ac][tg][atg][atc][agc][tgc][gc][at][atgc]/, Sequence::NA.new('atgcrymkdhvbswn').to_re)
193
+ assert_equal(/atgc[agr][tcy][acm][tgk][atgrwkd][atcwmyh][agcmrsv][tgcyskb][gcw][atw][atgcyrwskmbdhvn]/, Sequence::NA.new('atgcrymkdhvbswn').to_re)
206
194
  end
207
195
 
208
196
  def test_rna_to_re
209
- assert_equal(/augc[ag][uc][ac][ug][aug][auc][agc][ugc][gc][au][augc]/, Sequence::NA.new('augcrymkdhvbswn').to_re)
197
+ assert_equal(/augc[agr][ucy][acm][ugk][augrwkd][aucwmyh][agcmrsv][ugcyskb][gcw][auw][augcyrwskmbdhvn]/, Sequence::NA.new('augcrymkdhvbswn').to_re)
210
198
  end
211
199
 
212
200
  # Test Sequence::NA#names
@@ -1,23 +1,10 @@
1
1
  #
2
2
  # test/unit/bio/test_shell.rb - Unit test for Bio::Shell
3
3
  #
4
- # Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
4
+ # Copyright:: Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
5
+ # License:: The Ruby License
5
6
  #
6
- # This library is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU Lesser General Public
8
- # License as published by the Free Software Foundation; either
9
- # version 2 of the License, or (at your option) any later version.
10
- #
11
- # This library is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with this library; if not, write to the Free Software
18
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- #
20
- # $Id: test_shell.rb,v 1.5 2006/02/21 17:40:37 nakao Exp $
7
+ # $Id: test_shell.rb,v 1.7 2007/04/05 23:35:42 trevor Exp $
21
8
  #
22
9
 
23
10
  require 'pathname'
@@ -0,0 +1,593 @@
1
+ #
2
+ # = test/bio/test_tree.rb - unit test for Bio::Tree
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Naohisa Goto <ng@bioruby.org>
6
+ # License:: The Ruby License
7
+ #
8
+ # $Id: test_tree.rb,v 1.5 2007/04/05 23:35:42 trevor Exp $
9
+ #
10
+
11
+ require 'test/unit'
12
+
13
+ require 'pathname'
14
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), [".."] * 3, "lib")).cleanpath.to_s
15
+ $:.unshift(libpath) unless $:.include?(libpath)
16
+
17
+ require 'bio'
18
+ require 'bio/tree'
19
+
20
+ module Bio
21
+ class TestTreeEdge < Test::Unit::TestCase
22
+ def setup
23
+ @obj = Bio::Tree::Edge.new(123.45)
24
+ end
25
+
26
+ def test_initialize
27
+ assert_nothing_raised { Bio::Tree::Edge.new }
28
+ assert_equal(1.23, Bio::Tree::Edge.new(1.23).distance)
29
+ assert_equal(12.3, Bio::Tree::Edge.new('12.3').distance)
30
+ end
31
+
32
+ def test_distance
33
+ assert_equal(123.45, @obj.distance)
34
+ end
35
+
36
+ def test_distance_string
37
+ assert_equal("123.45", @obj.distance_string)
38
+ end
39
+
40
+ def test_distance=()
41
+ @obj.distance = 678.9
42
+ assert_equal(678.9, @obj.distance)
43
+ assert_equal("678.9", @obj.distance_string)
44
+ @obj.distance = nil
45
+ assert_equal(nil, @obj.distance)
46
+ assert_equal(nil, @obj.distance_string)
47
+ end
48
+
49
+ def test_distance_string=()
50
+ @obj.distance_string = "678.9"
51
+ assert_equal(678.9, @obj.distance)
52
+ assert_equal("678.9", @obj.distance_string)
53
+ @obj.distance_string = nil
54
+ assert_equal(nil, @obj.distance)
55
+ assert_equal(nil, @obj.distance_string)
56
+ end
57
+
58
+ def test_inspect
59
+ assert_equal("<Edge distance=123.45>", @obj.inspect)
60
+ end
61
+
62
+ def test_to_s
63
+ assert_equal("123.45", @obj.to_s)
64
+ end
65
+ end #class TestTreeEdge
66
+
67
+ class TestTreeNode < Test::Unit::TestCase
68
+ def setup
69
+ @obj = Bio::Tree::Node.new
70
+ end
71
+
72
+ def test_initialize
73
+ assert_nothing_raised { Bio::Tree::Node.new }
74
+ a = nil
75
+ assert_nothing_raised { a = Bio::Tree::Node.new('mouse') }
76
+ assert_equal('mouse', a.name)
77
+ end
78
+
79
+ def test_name
80
+ assert_equal(nil, @obj.name)
81
+ @obj.name = 'human'
82
+ assert_equal('human', @obj.name)
83
+ end
84
+
85
+ def test_bootstrap
86
+ assert_equal(nil, @obj.bootstrap)
87
+ end
88
+
89
+ def test_bootstrap_string
90
+ assert_equal(nil, @obj.bootstrap_string)
91
+ end
92
+
93
+ def test_bootstrap=()
94
+ @obj.bootstrap = 98
95
+ assert_equal(98, @obj.bootstrap)
96
+ assert_equal('98', @obj.bootstrap_string)
97
+ @obj.bootstrap = nil
98
+ assert_equal(nil, @obj.bootstrap)
99
+ assert_equal(nil, @obj.bootstrap_string)
100
+ end
101
+
102
+ def test_bootstrap_string=()
103
+ @obj.bootstrap_string = '98'
104
+ assert_equal(98, @obj.bootstrap)
105
+ assert_equal('98', @obj.bootstrap_string)
106
+ @obj.bootstrap_string = '99.98'
107
+ assert_equal(99.98, @obj.bootstrap)
108
+ assert_equal('99.98', @obj.bootstrap_string)
109
+ @obj.bootstrap = nil
110
+ assert_equal(nil, @obj.bootstrap)
111
+ assert_equal(nil, @obj.bootstrap_string)
112
+ end
113
+
114
+ def test_inspect
115
+ @obj.name = 'human'
116
+ assert_equal('(Node:"human")', @obj.inspect)
117
+ @obj.bootstrap = 99.98
118
+ assert_equal('(Node:"human" bootstrap=99.98)', @obj.inspect)
119
+ end
120
+
121
+ def test_to_s
122
+ @obj.name = 'human'
123
+ assert_equal('human', @obj.to_s)
124
+ end
125
+ end #class TestTreeNode
126
+
127
+ class TestTree < Test::Unit::TestCase
128
+ def setup
129
+ @tree = Bio::Tree.new
130
+ end
131
+
132
+ def test_get_edge_distance
133
+ edge = Bio::Tree::Edge.new
134
+ assert_equal(nil, @tree.get_edge_distance(edge))
135
+ edge = Bio::Tree::Edge.new(12.34)
136
+ assert_equal(12.34, @tree.get_edge_distance(edge))
137
+ assert_equal(12.34, @tree.get_edge_distance(12.34))
138
+ end
139
+
140
+ def test_get_edge_distance_string
141
+ edge = Bio::Tree::Edge.new
142
+ assert_equal(nil, @tree.get_edge_distance_string(edge))
143
+ edge = Bio::Tree::Edge.new(12.34)
144
+ assert_equal("12.34", @tree.get_edge_distance_string(edge))
145
+ assert_equal("12.34", @tree.get_edge_distance_string(12.34))
146
+ end
147
+
148
+ def test_get_node_name
149
+ node = Bio::Tree::Node.new
150
+ assert_equal(nil, @tree.get_node_name(node))
151
+ node.name = 'human'
152
+ assert_equal('human', @tree.get_node_name(node))
153
+ end
154
+
155
+ def test_initialize
156
+ assert_nothing_raised { Bio::Tree.new }
157
+ assert_nothing_raised { Bio::Tree.new(@tree) }
158
+ end
159
+
160
+ def test_root
161
+ assert_equal(nil, @tree.root)
162
+ end
163
+
164
+ def test_root=()
165
+ assert_equal(nil, @tree.root)
166
+ node = Bio::Tree::Node.new
167
+ @tree.root = node
168
+ assert_equal(node, @tree.root)
169
+ end
170
+
171
+ def test_options
172
+ assert_equal({}, @tree.options)
173
+ @tree.options[:bootstrap_style] = :traditional
174
+ assert_equal(:traditional, @tree.options[:bootstrap_style])
175
+ end
176
+
177
+ end #class TestTree
178
+
179
+ class TestTree2 < Test::Unit::TestCase
180
+ def setup
181
+ # Note that below data is NOT real. The distances are random.
182
+ @tree = Bio::Tree.new
183
+ @mouse = Bio::Tree::Node.new('mouse')
184
+ @rat = Bio::Tree::Node.new('rat')
185
+ @rodents = Bio::Tree::Node.new('rodents')
186
+ @human = Bio::Tree::Node.new('human')
187
+ @chimpanzee = Bio::Tree::Node.new('chimpanzee')
188
+ @primates = Bio::Tree::Node.new('primates')
189
+ @mammals = Bio::Tree::Node.new('mammals')
190
+ @nodes =
191
+ [ @mouse, @rat, @rodents, @human, @chimpanzee, @primates, @mammals ]
192
+ @edge_rodents_mouse = Bio::Tree::Edge.new(0.0968)
193
+ @edge_rodents_rat = Bio::Tree::Edge.new(0.1125)
194
+ @edge_mammals_rodents = Bio::Tree::Edge.new(0.2560)
195
+ @edge_primates_human = Bio::Tree::Edge.new(0.0386)
196
+ @edge_primates_chimpanzee = Bio::Tree::Edge.new(0.0503)
197
+ @edge_mammals_primates = Bio::Tree::Edge.new(0.2235)
198
+ @edges = [
199
+ [ @rodents, @mouse, @edge_rodents_mouse ],
200
+ [ @rodents, @rat, @edge_rodents_rat ],
201
+ [ @mammals, @rodents, @edge_mammals_rodents ],
202
+ [ @primates, @human, @edge_primates_human ],
203
+ [ @primates, @chimpanzee, @edge_primates_chimpanzee ],
204
+ [ @mammals, @primates, @edge_mammals_primates ]
205
+ ]
206
+ @edges.each do |a|
207
+ @tree.add_edge(*a)
208
+ end
209
+
210
+ @by_id = Proc.new { |a, b| a.__id__ <=> b.__id__ }
211
+ end
212
+
213
+ def test_clear
214
+ assert_nothing_raised { @tree.clear }
215
+ assert_equal(0, @tree.number_of_nodes)
216
+ assert_equal(0, @tree.number_of_edges)
217
+ end
218
+
219
+ def test_nodes
220
+ nodes = @nodes.sort(&@by_id)
221
+ assert_equal(nodes, @tree.nodes.sort(&@by_id))
222
+ end
223
+
224
+ def test_number_of_nodes
225
+ assert_equal(7, @tree.number_of_nodes)
226
+ end
227
+
228
+ def test_each_node
229
+ @tree.each_node do |x|
230
+ assert_not_nil(@nodes.delete(x))
231
+ end
232
+ assert_equal(true, @nodes.empty?)
233
+ end
234
+
235
+ def test_each_edge
236
+ @tree.each_edge do |source, target, edge|
237
+ assert_not_nil(@edges.delete([ source, target, edge ]))
238
+ end
239
+ assert_equal(true, @edges.empty?)
240
+ end
241
+
242
+ def test_edges
243
+ edges = @edges.sort { |a, b| a[-1].distance <=> b[-1].distance }
244
+ assert_equal(edges,
245
+ @tree.edges.sort {
246
+ |a, b| a[-1].distance <=> b[-1].distance })
247
+ end
248
+
249
+ def test_number_of_edges
250
+ assert_equal(@edges.size, @tree.number_of_edges)
251
+ end
252
+
253
+ def test_adjacent_nodes
254
+ assert_equal([ @rodents ], @tree.adjacent_nodes(@mouse))
255
+ assert_equal([ @rodents ], @tree.adjacent_nodes(@rat))
256
+ assert_equal([ @primates ], @tree.adjacent_nodes(@human))
257
+ assert_equal([ @primates ], @tree.adjacent_nodes(@chimpanzee))
258
+ assert_equal([ @mouse, @rat, @mammals ].sort(&@by_id),
259
+ @tree.adjacent_nodes(@rodents).sort(&@by_id))
260
+ assert_equal([ @human, @chimpanzee, @mammals ].sort(&@by_id),
261
+ @tree.adjacent_nodes(@primates).sort(&@by_id))
262
+ assert_equal([ @rodents, @primates ].sort(&@by_id),
263
+ @tree.adjacent_nodes(@mammals).sort(&@by_id))
264
+ end
265
+
266
+ def test_adjacent_nodes_nonexistent
267
+ # test for not existed nodes
268
+ assert_equal([], @tree.adjacent_nodes(Bio::Tree::Node.new))
269
+ end
270
+
271
+ def test_out_edges
272
+ assert_equal([[ @mouse, @rodents, @edge_rodents_mouse ]],
273
+ @tree.out_edges(@mouse))
274
+ assert_equal([[ @rat, @rodents, @edge_rodents_rat ]],
275
+ @tree.out_edges(@rat))
276
+ assert_equal([[ @human, @primates, @edge_primates_human ]],
277
+ @tree.out_edges(@human))
278
+ assert_equal([[ @chimpanzee, @primates, @edge_primates_chimpanzee ]],
279
+ @tree.out_edges(@chimpanzee))
280
+ end
281
+
282
+ def test_out_edges_rodents
283
+ adjacents = [ @mouse, @rat, @mammals ]
284
+ edges = [ @edge_rodents_mouse, @edge_rodents_rat, @edge_mammals_rodents ]
285
+ @tree.out_edges(@rodents).each do |a|
286
+ assert_equal(@rodents, a[0])
287
+ assert_not_nil(i = adjacents.index(a[1]))
288
+ assert_equal(edges[i], a[2])
289
+ adjacents.delete_at(i)
290
+ edges.delete_at(i)
291
+ end
292
+ assert_equal(true, adjacents.empty?)
293
+ assert_equal(true, edges.empty?)
294
+ end
295
+
296
+ def test_out_edges_primates
297
+ adjacents = [ @human, @chimpanzee, @mammals ]
298
+ edges = [ @edge_primates_human, @edge_primates_chimpanzee,
299
+ @edge_mammals_primates ]
300
+ @tree.out_edges(@primates).each do |a|
301
+ assert_equal(@primates, a[0])
302
+ assert_not_nil(i = adjacents.index(a[1]))
303
+ assert_equal(edges[i], a[2])
304
+ adjacents.delete_at(i)
305
+ edges.delete_at(i)
306
+ end
307
+ assert_equal(true, adjacents.empty?)
308
+ assert_equal(true, edges.empty?)
309
+ end
310
+
311
+ def test_out_edges_mammals
312
+ adjacents = [ @rodents, @primates ]
313
+ edges = [ @edge_mammals_rodents, @edge_mammals_primates ]
314
+ @tree.out_edges(@mammals).each do |a|
315
+ assert_equal(@mammals, a[0])
316
+ assert_not_nil(i = adjacents.index(a[1]))
317
+ assert_equal(edges[i], a[2])
318
+ adjacents.delete_at(i)
319
+ edges.delete_at(i)
320
+ end
321
+ assert_equal(true, adjacents.empty?)
322
+ assert_equal(true, edges.empty?)
323
+ end
324
+
325
+ def test_out_edges_nonexistent
326
+ # test for not existed nodes
327
+ assert_equal([], @tree.out_edges(Bio::Tree::Node.new))
328
+ end
329
+
330
+ def test_each_out_edge
331
+ flag = nil
332
+ r = @tree.each_out_edge(@mouse) do |src, tgt, edge|
333
+ assert_equal(@mouse, src)
334
+ assert_equal(@rodents, tgt)
335
+ assert_equal(@edge_rodents_mouse, edge)
336
+ flag = true
337
+ end
338
+ assert_equal(@tree, r)
339
+ assert_equal(true, flag)
340
+ end
341
+
342
+ def test_each_out_edge_rat
343
+ flag = nil
344
+ r = @tree.each_out_edge(@rat) do |src, tgt, edge|
345
+ assert_equal(@rat, src)
346
+ assert_equal(@rodents, tgt)
347
+ assert_equal(@edge_rodents_rat, edge)
348
+ flag = true
349
+ end
350
+ assert_equal(@tree, r)
351
+ assert_equal(true, flag)
352
+ end
353
+
354
+ def test_each_out_edge_human
355
+ flag = nil
356
+ r = @tree.each_out_edge(@human) do |src, tgt, edge|
357
+ assert_equal(@human, src)
358
+ assert_equal(@primates, tgt)
359
+ assert_equal(@edge_primates_human, edge)
360
+ flag = true
361
+ end
362
+ assert_equal(@tree, r)
363
+ assert_equal(true, flag)
364
+ end
365
+
366
+ def test_each_out_edge_chimpanzee
367
+ flag = nil
368
+ r = @tree.each_out_edge(@chimpanzee) do |src, tgt, edge|
369
+ assert_equal(@chimpanzee, src)
370
+ assert_equal(@primates, tgt)
371
+ assert_equal(@edge_primates_chimpanzee, edge)
372
+ flag = true
373
+ end
374
+ assert_equal(@tree, r)
375
+ assert_equal(true, flag)
376
+ end
377
+
378
+ def test_each_out_edge_rodents
379
+ adjacents = [ @mouse, @rat, @mammals ]
380
+ edges = [ @edge_rodents_mouse, @edge_rodents_rat, @edge_mammals_rodents ]
381
+ @tree.each_out_edge(@rodents) do |src, tgt, edge|
382
+ assert_equal(@rodents, src)
383
+ assert_not_nil(i = adjacents.index(tgt))
384
+ assert_equal(edges[i], edge)
385
+ adjacents.delete_at(i)
386
+ edges.delete_at(i)
387
+ end
388
+ assert_equal(true, adjacents.empty?)
389
+ assert_equal(true, edges.empty?)
390
+ end
391
+
392
+ def test_each_out_edge_primates
393
+ adjacents = [ @human, @chimpanzee, @mammals ]
394
+ edges = [ @edge_primates_human, @edge_primates_chimpanzee,
395
+ @edge_mammals_primates ]
396
+ @tree.each_out_edge(@primates) do |src, tgt, edge|
397
+ assert_equal(@primates, src)
398
+ assert_not_nil(i = adjacents.index(tgt))
399
+ assert_equal(edges[i], edge)
400
+ adjacents.delete_at(i)
401
+ edges.delete_at(i)
402
+ end
403
+ assert_equal(true, adjacents.empty?)
404
+ assert_equal(true, edges.empty?)
405
+ end
406
+
407
+ def test_each_out_edge_mammals
408
+ adjacents = [ @rodents, @primates ]
409
+ edges = [ @edge_mammals_rodents, @edge_mammals_primates ]
410
+ @tree.each_out_edge(@mammals) do |src, tgt, edge|
411
+ assert_equal(@mammals, src)
412
+ assert_not_nil(i = adjacents.index(tgt))
413
+ assert_equal(edges[i], edge)
414
+ adjacents.delete_at(i)
415
+ edges.delete_at(i)
416
+ end
417
+ assert_equal(true, adjacents.empty?)
418
+ assert_equal(true, edges.empty?)
419
+ end
420
+
421
+ def test_each_out_edge_nonexistent
422
+ # test for not existed nodes
423
+ flag = nil
424
+ node = Bio::Tree::Node.new
425
+ r = @tree.each_out_edge(node) do |src, tgt, edge|
426
+ flag = true
427
+ end
428
+ assert_equal(@tree, r)
429
+ assert_equal(nil, flag)
430
+ end
431
+
432
+ def test_out_degree
433
+ assert_equal(1, @tree.out_degree(@mouse))
434
+ assert_equal(1, @tree.out_degree(@rat))
435
+ assert_equal(3, @tree.out_degree(@rodents))
436
+ assert_equal(1, @tree.out_degree(@human))
437
+ assert_equal(1, @tree.out_degree(@chimpanzee))
438
+ assert_equal(3, @tree.out_degree(@primates))
439
+ assert_equal(2, @tree.out_degree(@mammals))
440
+ end
441
+
442
+ def test_out_degree_nonexistent
443
+ assert_equal(0, @tree.out_degree(Bio::Tree::Node.new))
444
+ end
445
+
446
+ def test_get_edge
447
+ assert_not_nil(@tree.get_edge(@rodents, @mouse))
448
+ assert_not_nil(@tree.get_edge(@mouse, @rodents))
449
+ assert_equal(@edge_rodents_mouse, @tree.get_edge(@rodents, @mouse))
450
+ assert_equal(@edge_rodents_mouse, @tree.get_edge(@mouse, @rodents))
451
+
452
+ assert_not_nil(@tree.get_edge(@rodents, @rat))
453
+ assert_not_nil(@tree.get_edge(@rat, @rodents))
454
+ assert_equal(@edge_rodents_rat, @tree.get_edge(@rodents, @rat))
455
+ assert_equal(@edge_rodents_rat, @tree.get_edge(@rat, @rodents))
456
+
457
+ assert_not_nil(@tree.get_edge(@mammals, @rodents))
458
+ assert_not_nil(@tree.get_edge(@rodents, @mammals))
459
+ assert_equal(@edge_mammals_rodents, @tree.get_edge(@mammals, @rodents))
460
+ assert_equal(@edge_mammals_rodents, @tree.get_edge(@rodents, @mammals))
461
+
462
+ assert_not_nil(@tree.get_edge(@primates, @human))
463
+ assert_not_nil(@tree.get_edge(@human, @primates))
464
+ assert_equal(@edge_primates_human, @tree.get_edge(@primates, @human))
465
+ assert_equal(@edge_primates_human, @tree.get_edge(@human, @primates))
466
+
467
+ assert_not_nil(@tree.get_edge(@primates, @chimpanzee))
468
+ assert_not_nil(@tree.get_edge(@chimpanzee, @primates))
469
+ assert_equal(@edge_primates_chimpanzee, @tree.get_edge(@primates, @chimpanzee))
470
+ assert_equal(@edge_primates_chimpanzee, @tree.get_edge(@chimpanzee, @primates))
471
+
472
+ assert_not_nil(@tree.get_edge(@mammals, @primates))
473
+ assert_not_nil(@tree.get_edge(@primates, @mammals))
474
+ assert_equal(@edge_mammals_primates, @tree.get_edge(@mammals, @primates))
475
+ assert_equal(@edge_mammals_primates, @tree.get_edge(@primates, @mammals))
476
+ end
477
+
478
+ def test_get_edge_indirect
479
+ assert_nil(@tree.get_edge(@mouse, @rat))
480
+ assert_nil(@tree.get_edge(@human, @chimpanzee))
481
+ end
482
+
483
+ def test_get_edge_nonexistent
484
+ assert_nil(@tree.get_edge(@mouse, Bio::Tree::Node.new))
485
+ end
486
+
487
+ def test_get_node_by_name
488
+ assert_not_nil(@tree.get_node_by_name('mouse'))
489
+ assert_not_nil(@tree.get_node_by_name('rat'))
490
+ assert_not_nil(@tree.get_node_by_name('human'))
491
+ assert_not_nil(@tree.get_node_by_name('chimpanzee'))
492
+ assert_equal(@mouse, @tree.get_node_by_name('mouse'))
493
+ assert_equal(@rat, @tree.get_node_by_name('rat'))
494
+ assert_equal(@human, @tree.get_node_by_name('human'))
495
+ assert_equal(@chimpanzee, @tree.get_node_by_name('chimpanzee'))
496
+ end
497
+
498
+ def test_get_node_by_name_noexistent
499
+ assert_nil(@tree.get_node_by_name('frog'))
500
+ end
501
+
502
+ def test_add_edge
503
+ amphibian = Bio::Tree::Node.new('amphibian')
504
+ edge = Bio::Tree::Edge.new(0.3123)
505
+ assert_equal(edge, @tree.add_edge(@mammals, amphibian, edge))
506
+
507
+ frog = Bio::Tree::Node.new('frog')
508
+ newt = Bio::Tree::Node.new('newt')
509
+ assert_instance_of(Bio::Tree::Edge, @tree.add_edge(frog, newt))
510
+ end
511
+
512
+ def test_add_node
513
+ frog = Bio::Tree::Node.new('frog')
514
+ # the node does not exist
515
+ assert_nil(@tree.get_node_by_name('frog'))
516
+ assert_equal(false, @tree.include?(frog))
517
+ # add node
518
+ assert_equal(@tree, @tree.add_node(frog))
519
+ # the node exists
520
+ assert_equal(frog, @tree.get_node_by_name('frog'))
521
+ assert_equal(true, @tree.include?(frog))
522
+ end
523
+
524
+ def test_include?
525
+ assert_equal(true, @tree.include?(@mouse))
526
+ assert_equal(true, @tree.include?(@rat))
527
+ assert_equal(true, @tree.include?(@rodents))
528
+ assert_equal(true, @tree.include?(@human))
529
+ assert_equal(true, @tree.include?(@chimpanzee))
530
+ assert_equal(true, @tree.include?(@primates))
531
+ assert_equal(true, @tree.include?(@mammals))
532
+ end
533
+
534
+ def test_include_nonexistent
535
+ assert_equal(false, @tree.include?(Bio::Tree::Node.new))
536
+ end
537
+
538
+ def test_clear_node
539
+ assert_equal(2, @tree.out_degree(@mammals))
540
+ # clear node
541
+ assert_equal(@tree, @tree.clear_node(@mammals))
542
+ # checks
543
+ assert_equal(true, @tree.include?(@mammals))
544
+ assert_equal(0, @tree.out_degree(@mammals))
545
+ assert_equal(2, @tree.out_degree(@rodents))
546
+ assert_equal(2, @tree.out_degree(@primates))
547
+ end
548
+
549
+ def test_clear_node_nonexistent
550
+ assert_raise(IndexError) { @tree.clear_node(Bio::Tree::Node.new) }
551
+ end
552
+
553
+ def test_remove_node
554
+ assert_equal(2, @tree.out_degree(@mammals))
555
+ # remove node
556
+ assert_equal(@tree, @tree.remove_node(@mammals))
557
+ # checks
558
+ assert_equal(false, @tree.include?(@mammals))
559
+ assert_equal(0, @tree.out_degree(@mammals))
560
+ assert_equal(2, @tree.out_degree(@rodents))
561
+ assert_equal(2, @tree.out_degree(@primates))
562
+ end
563
+
564
+ def test_remove_node_nonexistent
565
+ assert_raise(IndexError) { @tree.remove_node(Bio::Tree::Node.new) }
566
+ end
567
+
568
+ def test_remove_node_if
569
+ assert_equal(@tree, @tree.remove_node_if { |node| node == @mouse })
570
+ assert_equal(false, @tree.include?(@mouse))
571
+ end
572
+
573
+ def test_remove_node_if_false
574
+ ary = []
575
+ assert_equal(@tree, @tree.remove_node_if { |node| ary << node; false })
576
+ nodes = @nodes.sort(&@by_id)
577
+ assert_equal(nodes, ary.sort(&@by_id))
578
+ assert_equal(nodes, @tree.nodes.sort(&@by_id))
579
+ end
580
+
581
+ def test_remove_edge
582
+ assert_not_nil(@tree.get_edge(@mouse, @rodents))
583
+ assert_equal(@tree, @tree.remove_edge(@mouse, @rodents))
584
+ assert_nil(@tree.get_edge(@mouse, @rodents))
585
+ end
586
+
587
+ def test_remove_edge_nonexistent
588
+ assert_raise(IndexError) { @tree.remove_edge(@mouse, @rat) }
589
+ end
590
+ end #class TestTree2
591
+
592
+ end #module Bio
593
+