wwood-bioruby 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (386) hide show
  1. data/README.rdoc +205 -0
  2. data/README_DEV.rdoc +285 -0
  3. data/VERSION.yml +4 -0
  4. data/bin/bioruby +44 -0
  5. data/bin/br_biofetch.rb +47 -0
  6. data/bin/br_bioflat.rb +293 -0
  7. data/bin/br_biogetseq.rb +45 -0
  8. data/bin/br_pmfetch.rb +421 -0
  9. data/lib/bio.rb +306 -0
  10. data/lib/bio/alignment.rb +2518 -0
  11. data/lib/bio/appl/bl2seq/report.rb +334 -0
  12. data/lib/bio/appl/blast.rb +505 -0
  13. data/lib/bio/appl/blast/ddbj.rb +142 -0
  14. data/lib/bio/appl/blast/format0.rb +1438 -0
  15. data/lib/bio/appl/blast/format8.rb +83 -0
  16. data/lib/bio/appl/blast/genomenet.rb +263 -0
  17. data/lib/bio/appl/blast/ncbioptions.rb +220 -0
  18. data/lib/bio/appl/blast/remote.rb +105 -0
  19. data/lib/bio/appl/blast/report.rb +767 -0
  20. data/lib/bio/appl/blast/rexml.rb +144 -0
  21. data/lib/bio/appl/blast/rpsblast.rb +277 -0
  22. data/lib/bio/appl/blast/wublast.rb +635 -0
  23. data/lib/bio/appl/blast/xmlparser.rb +236 -0
  24. data/lib/bio/appl/blat/report.rb +530 -0
  25. data/lib/bio/appl/clustalw.rb +219 -0
  26. data/lib/bio/appl/clustalw/report.rb +152 -0
  27. data/lib/bio/appl/emboss.rb +203 -0
  28. data/lib/bio/appl/fasta.rb +235 -0
  29. data/lib/bio/appl/fasta/format10.rb +325 -0
  30. data/lib/bio/appl/gcg/msf.rb +212 -0
  31. data/lib/bio/appl/gcg/seq.rb +195 -0
  32. data/lib/bio/appl/genscan/report.rb +552 -0
  33. data/lib/bio/appl/hmmer.rb +126 -0
  34. data/lib/bio/appl/hmmer/report.rb +683 -0
  35. data/lib/bio/appl/iprscan/report.rb +374 -0
  36. data/lib/bio/appl/mafft.rb +259 -0
  37. data/lib/bio/appl/mafft/report.rb +226 -0
  38. data/lib/bio/appl/muscle.rb +52 -0
  39. data/lib/bio/appl/paml/baseml.rb +95 -0
  40. data/lib/bio/appl/paml/baseml/report.rb +32 -0
  41. data/lib/bio/appl/paml/codeml.rb +242 -0
  42. data/lib/bio/appl/paml/codeml/rates.rb +67 -0
  43. data/lib/bio/appl/paml/codeml/report.rb +67 -0
  44. data/lib/bio/appl/paml/common.rb +348 -0
  45. data/lib/bio/appl/paml/common_report.rb +38 -0
  46. data/lib/bio/appl/paml/yn00.rb +103 -0
  47. data/lib/bio/appl/paml/yn00/report.rb +32 -0
  48. data/lib/bio/appl/phylip/alignment.rb +133 -0
  49. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  50. data/lib/bio/appl/probcons.rb +41 -0
  51. data/lib/bio/appl/psort.rb +548 -0
  52. data/lib/bio/appl/psort/report.rb +542 -0
  53. data/lib/bio/appl/pts1.rb +263 -0
  54. data/lib/bio/appl/sim4.rb +124 -0
  55. data/lib/bio/appl/sim4/report.rb +485 -0
  56. data/lib/bio/appl/sosui/report.rb +151 -0
  57. data/lib/bio/appl/spidey/report.rb +593 -0
  58. data/lib/bio/appl/targetp/report.rb +267 -0
  59. data/lib/bio/appl/tcoffee.rb +55 -0
  60. data/lib/bio/appl/tmhmm/report.rb +231 -0
  61. data/lib/bio/command.rb +593 -0
  62. data/lib/bio/compat/features.rb +157 -0
  63. data/lib/bio/compat/references.rb +128 -0
  64. data/lib/bio/data/aa.rb +353 -0
  65. data/lib/bio/data/codontable.rb +722 -0
  66. data/lib/bio/data/na.rb +223 -0
  67. data/lib/bio/db.rb +329 -0
  68. data/lib/bio/db/aaindex.rb +357 -0
  69. data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
  70. data/lib/bio/db/biosql/sequence.rb +508 -0
  71. data/lib/bio/db/embl/common.rb +352 -0
  72. data/lib/bio/db/embl/embl.rb +500 -0
  73. data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
  74. data/lib/bio/db/embl/format_embl.rb +190 -0
  75. data/lib/bio/db/embl/sptr.rb +1283 -0
  76. data/lib/bio/db/embl/swissprot.rb +42 -0
  77. data/lib/bio/db/embl/trembl.rb +41 -0
  78. data/lib/bio/db/embl/uniprot.rb +42 -0
  79. data/lib/bio/db/fantom.rb +597 -0
  80. data/lib/bio/db/fasta.rb +410 -0
  81. data/lib/bio/db/fasta/defline.rb +532 -0
  82. data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
  83. data/lib/bio/db/fasta/format_fasta.rb +97 -0
  84. data/lib/bio/db/genbank/common.rb +307 -0
  85. data/lib/bio/db/genbank/ddbj.rb +22 -0
  86. data/lib/bio/db/genbank/format_genbank.rb +187 -0
  87. data/lib/bio/db/genbank/genbank.rb +250 -0
  88. data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
  89. data/lib/bio/db/genbank/genpept.rb +60 -0
  90. data/lib/bio/db/genbank/refseq.rb +18 -0
  91. data/lib/bio/db/gff.rb +1846 -0
  92. data/lib/bio/db/go.rb +481 -0
  93. data/lib/bio/db/kegg/brite.rb +41 -0
  94. data/lib/bio/db/kegg/compound.rb +131 -0
  95. data/lib/bio/db/kegg/drug.rb +98 -0
  96. data/lib/bio/db/kegg/enzyme.rb +148 -0
  97. data/lib/bio/db/kegg/expression.rb +155 -0
  98. data/lib/bio/db/kegg/genes.rb +263 -0
  99. data/lib/bio/db/kegg/genome.rb +241 -0
  100. data/lib/bio/db/kegg/glycan.rb +166 -0
  101. data/lib/bio/db/kegg/keggtab.rb +357 -0
  102. data/lib/bio/db/kegg/kgml.rb +256 -0
  103. data/lib/bio/db/kegg/orthology.rb +136 -0
  104. data/lib/bio/db/kegg/reaction.rb +82 -0
  105. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  106. data/lib/bio/db/lasergene.rb +209 -0
  107. data/lib/bio/db/litdb.rb +107 -0
  108. data/lib/bio/db/medline.rb +326 -0
  109. data/lib/bio/db/nbrf.rb +191 -0
  110. data/lib/bio/db/newick.rb +658 -0
  111. data/lib/bio/db/nexus.rb +1854 -0
  112. data/lib/bio/db/pdb.rb +29 -0
  113. data/lib/bio/db/pdb/atom.rb +77 -0
  114. data/lib/bio/db/pdb/chain.rb +210 -0
  115. data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
  116. data/lib/bio/db/pdb/model.rb +148 -0
  117. data/lib/bio/db/pdb/pdb.rb +1911 -0
  118. data/lib/bio/db/pdb/residue.rb +176 -0
  119. data/lib/bio/db/pdb/utils.rb +399 -0
  120. data/lib/bio/db/prosite.rb +597 -0
  121. data/lib/bio/db/rebase.rb +456 -0
  122. data/lib/bio/db/soft.rb +404 -0
  123. data/lib/bio/db/transfac.rb +375 -0
  124. data/lib/bio/db/url.rb +42 -0
  125. data/lib/bio/feature.rb +139 -0
  126. data/lib/bio/io/biosql/biodatabase.rb +64 -0
  127. data/lib/bio/io/biosql/bioentry.rb +29 -0
  128. data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
  129. data/lib/bio/io/biosql/bioentry_path.rb +12 -0
  130. data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
  131. data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
  132. data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
  133. data/lib/bio/io/biosql/biosequence.rb +11 -0
  134. data/lib/bio/io/biosql/comment.rb +7 -0
  135. data/lib/bio/io/biosql/config/database.yml +20 -0
  136. data/lib/bio/io/biosql/dbxref.rb +13 -0
  137. data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
  138. data/lib/bio/io/biosql/location.rb +32 -0
  139. data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
  140. data/lib/bio/io/biosql/ontology.rb +10 -0
  141. data/lib/bio/io/biosql/reference.rb +9 -0
  142. data/lib/bio/io/biosql/seqfeature.rb +32 -0
  143. data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
  144. data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
  145. data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
  146. data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
  147. data/lib/bio/io/biosql/taxon.rb +12 -0
  148. data/lib/bio/io/biosql/taxon_name.rb +9 -0
  149. data/lib/bio/io/biosql/term.rb +27 -0
  150. data/lib/bio/io/biosql/term_dbxref.rb +11 -0
  151. data/lib/bio/io/biosql/term_path.rb +12 -0
  152. data/lib/bio/io/biosql/term_relationship.rb +13 -0
  153. data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
  154. data/lib/bio/io/biosql/term_synonym.rb +10 -0
  155. data/lib/bio/io/das.rb +461 -0
  156. data/lib/bio/io/dbget.rb +194 -0
  157. data/lib/bio/io/ddbjxml.rb +638 -0
  158. data/lib/bio/io/ebisoap.rb +158 -0
  159. data/lib/bio/io/ensembl.rb +229 -0
  160. data/lib/bio/io/fastacmd.rb +163 -0
  161. data/lib/bio/io/fetch.rb +195 -0
  162. data/lib/bio/io/flatfile.rb +482 -0
  163. data/lib/bio/io/flatfile/autodetection.rb +545 -0
  164. data/lib/bio/io/flatfile/bdb.rb +253 -0
  165. data/lib/bio/io/flatfile/buffer.rb +237 -0
  166. data/lib/bio/io/flatfile/index.rb +1381 -0
  167. data/lib/bio/io/flatfile/indexer.rb +805 -0
  168. data/lib/bio/io/flatfile/splitter.rb +297 -0
  169. data/lib/bio/io/higet.rb +73 -0
  170. data/lib/bio/io/hinv.rb +442 -0
  171. data/lib/bio/io/keggapi.rb +805 -0
  172. data/lib/bio/io/ncbirest.rb +733 -0
  173. data/lib/bio/io/ncbisoap.rb +155 -0
  174. data/lib/bio/io/pubmed.rb +307 -0
  175. data/lib/bio/io/registry.rb +292 -0
  176. data/lib/bio/io/soapwsdl.rb +119 -0
  177. data/lib/bio/io/sql.rb +186 -0
  178. data/lib/bio/location.rb +867 -0
  179. data/lib/bio/map.rb +410 -0
  180. data/lib/bio/pathway.rb +960 -0
  181. data/lib/bio/reference.rb +602 -0
  182. data/lib/bio/sequence.rb +456 -0
  183. data/lib/bio/sequence/aa.rb +152 -0
  184. data/lib/bio/sequence/adapter.rb +108 -0
  185. data/lib/bio/sequence/common.rb +310 -0
  186. data/lib/bio/sequence/compat.rb +123 -0
  187. data/lib/bio/sequence/dblink.rb +54 -0
  188. data/lib/bio/sequence/format.rb +358 -0
  189. data/lib/bio/sequence/format_raw.rb +23 -0
  190. data/lib/bio/sequence/generic.rb +24 -0
  191. data/lib/bio/sequence/na.rb +491 -0
  192. data/lib/bio/shell.rb +44 -0
  193. data/lib/bio/shell/core.rb +578 -0
  194. data/lib/bio/shell/demo.rb +146 -0
  195. data/lib/bio/shell/interface.rb +218 -0
  196. data/lib/bio/shell/irb.rb +95 -0
  197. data/lib/bio/shell/object.rb +71 -0
  198. data/lib/bio/shell/plugin/blast.rb +42 -0
  199. data/lib/bio/shell/plugin/codon.rb +218 -0
  200. data/lib/bio/shell/plugin/das.rb +58 -0
  201. data/lib/bio/shell/plugin/emboss.rb +23 -0
  202. data/lib/bio/shell/plugin/entry.rb +105 -0
  203. data/lib/bio/shell/plugin/flatfile.rb +101 -0
  204. data/lib/bio/shell/plugin/keggapi.rb +181 -0
  205. data/lib/bio/shell/plugin/midi.rb +430 -0
  206. data/lib/bio/shell/plugin/obda.rb +45 -0
  207. data/lib/bio/shell/plugin/psort.rb +56 -0
  208. data/lib/bio/shell/plugin/seq.rb +247 -0
  209. data/lib/bio/shell/plugin/soap.rb +87 -0
  210. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
  211. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
  212. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
  213. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
  214. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
  215. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
  216. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  217. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  218. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  219. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
  220. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
  221. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
  222. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
  223. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
  224. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
  225. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
  226. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  227. data/lib/bio/shell/script.rb +25 -0
  228. data/lib/bio/shell/setup.rb +109 -0
  229. data/lib/bio/shell/web.rb +102 -0
  230. data/lib/bio/tree.rb +852 -0
  231. data/lib/bio/util/color_scheme.rb +191 -0
  232. data/lib/bio/util/color_scheme/buried.rb +59 -0
  233. data/lib/bio/util/color_scheme/helix.rb +59 -0
  234. data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
  235. data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
  236. data/lib/bio/util/color_scheme/strand.rb +59 -0
  237. data/lib/bio/util/color_scheme/taylor.rb +50 -0
  238. data/lib/bio/util/color_scheme/turn.rb +59 -0
  239. data/lib/bio/util/color_scheme/zappo.rb +50 -0
  240. data/lib/bio/util/contingency_table.rb +370 -0
  241. data/lib/bio/util/restriction_enzyme.rb +228 -0
  242. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  243. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  244. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  245. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  246. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  247. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  248. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  249. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  250. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  251. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  252. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  253. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  254. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  255. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  256. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  257. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  258. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  259. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  260. data/lib/bio/util/restriction_enzyme/single_strand.rb +200 -0
  261. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  262. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  263. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  264. data/lib/bio/util/sirna.rb +288 -0
  265. data/test/data/HMMER/hmmpfam.out +64 -0
  266. data/test/data/HMMER/hmmsearch.out +88 -0
  267. data/test/data/SOSUI/sample.report +11 -0
  268. data/test/data/TMHMM/sample.report +21 -0
  269. data/test/data/aaindex/DAYM780301 +30 -0
  270. data/test/data/aaindex/PRAM900102 +20 -0
  271. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  272. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  273. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  274. data/test/data/blast/b0002.faa +15 -0
  275. data/test/data/blast/b0002.faa.m0 +128 -0
  276. data/test/data/blast/b0002.faa.m7 +65 -0
  277. data/test/data/blast/b0002.faa.m8 +1 -0
  278. data/test/data/blast/blastp-multi.m7 +188 -0
  279. data/test/data/command/echoarg2.bat +1 -0
  280. data/test/data/embl/AB090716.embl +65 -0
  281. data/test/data/embl/AB090716.embl.rel89 +63 -0
  282. data/test/data/fasta/example1.txt +75 -0
  283. data/test/data/fasta/example2.txt +21 -0
  284. data/test/data/genscan/sample.report +63 -0
  285. data/test/data/iprscan/merged.raw +32 -0
  286. data/test/data/iprscan/merged.txt +74 -0
  287. data/test/data/paml/codeml/control_file.txt +30 -0
  288. data/test/data/paml/codeml/output.txt +78 -0
  289. data/test/data/paml/codeml/rates +217 -0
  290. data/test/data/prosite/prosite.dat +2233 -0
  291. data/test/data/refseq/nm_126355.entret +64 -0
  292. data/test/data/rpsblast/misc.rpsblast +193 -0
  293. data/test/data/soft/GDS100_partial.soft +92 -0
  294. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  295. data/test/data/uniprot/p53_human.uniprot +1456 -0
  296. data/test/functional/bio/appl/test_pts1.rb +115 -0
  297. data/test/functional/bio/io/test_ensembl.rb +229 -0
  298. data/test/functional/bio/io/test_soapwsdl.rb +52 -0
  299. data/test/functional/bio/sequence/test_output_embl.rb +51 -0
  300. data/test/functional/bio/test_command.rb +301 -0
  301. data/test/runner.rb +14 -0
  302. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  303. data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
  304. data/test/unit/bio/appl/blast/test_report.rb +1135 -0
  305. data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
  306. data/test/unit/bio/appl/genscan/test_report.rb +182 -0
  307. data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
  308. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  309. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  310. data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
  311. data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
  312. data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
  313. data/test/unit/bio/appl/sosui/test_report.rb +81 -0
  314. data/test/unit/bio/appl/targetp/test_report.rb +146 -0
  315. data/test/unit/bio/appl/test_blast.rb +277 -0
  316. data/test/unit/bio/appl/test_fasta.rb +130 -0
  317. data/test/unit/bio/appl/test_psort.rb +57 -0
  318. data/test/unit/bio/appl/test_pts1.rb +77 -0
  319. data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
  320. data/test/unit/bio/data/test_aa.rb +90 -0
  321. data/test/unit/bio/data/test_codontable.rb +107 -0
  322. data/test/unit/bio/data/test_na.rb +80 -0
  323. data/test/unit/bio/db/embl/test_common.rb +117 -0
  324. data/test/unit/bio/db/embl/test_embl.rb +214 -0
  325. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  326. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
  327. data/test/unit/bio/db/embl/test_sptr.rb +1812 -0
  328. data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
  329. data/test/unit/bio/db/kegg/test_genes.rb +45 -0
  330. data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
  331. data/test/unit/bio/db/test_aaindex.rb +197 -0
  332. data/test/unit/bio/db/test_fasta.rb +250 -0
  333. data/test/unit/bio/db/test_gff.rb +1190 -0
  334. data/test/unit/bio/db/test_lasergene.rb +95 -0
  335. data/test/unit/bio/db/test_medline.rb +127 -0
  336. data/test/unit/bio/db/test_newick.rb +293 -0
  337. data/test/unit/bio/db/test_nexus.rb +364 -0
  338. data/test/unit/bio/db/test_prosite.rb +1437 -0
  339. data/test/unit/bio/db/test_rebase.rb +101 -0
  340. data/test/unit/bio/db/test_soft.rb +138 -0
  341. data/test/unit/bio/db/test_url.rb +36 -0
  342. data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
  343. data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
  344. data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
  345. data/test/unit/bio/io/test_ddbjxml.rb +80 -0
  346. data/test/unit/bio/io/test_ensembl.rb +109 -0
  347. data/test/unit/bio/io/test_fastacmd.rb +42 -0
  348. data/test/unit/bio/io/test_flatfile.rb +505 -0
  349. data/test/unit/bio/io/test_soapwsdl.rb +32 -0
  350. data/test/unit/bio/sequence/test_aa.rb +115 -0
  351. data/test/unit/bio/sequence/test_common.rb +373 -0
  352. data/test/unit/bio/sequence/test_compat.rb +69 -0
  353. data/test/unit/bio/sequence/test_dblink.rb +58 -0
  354. data/test/unit/bio/sequence/test_na.rb +330 -0
  355. data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
  356. data/test/unit/bio/test_alignment.rb +1025 -0
  357. data/test/unit/bio/test_command.rb +349 -0
  358. data/test/unit/bio/test_db.rb +96 -0
  359. data/test/unit/bio/test_feature.rb +144 -0
  360. data/test/unit/bio/test_location.rb +599 -0
  361. data/test/unit/bio/test_map.rb +230 -0
  362. data/test/unit/bio/test_pathway.rb +499 -0
  363. data/test/unit/bio/test_reference.rb +252 -0
  364. data/test/unit/bio/test_sequence.rb +329 -0
  365. data/test/unit/bio/test_shell.rb +18 -0
  366. data/test/unit/bio/test_tree.rb +593 -0
  367. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  368. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  369. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  370. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
  371. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  372. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  373. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  374. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  375. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  376. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  377. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  378. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  379. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  380. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  381. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  382. data/test/unit/bio/util/test_color_scheme.rb +33 -0
  383. data/test/unit/bio/util/test_contingency_table.rb +94 -0
  384. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  385. data/test/unit/bio/util/test_sirna.rb +245 -0
  386. metadata +543 -0
@@ -0,0 +1,1190 @@
1
+ #
2
+ # test/unit/bio/db/test_gff.rb - Unit test for Bio::GFF
3
+ #
4
+ # Copyright:: Copyright (C) 2005, 2008
5
+ # Mitsuteru Nakao <n@bioruby.org>
6
+ # Naohisa Goto <ng@bioruby.org>
7
+ # License:: The Ruby License
8
+ #
9
+ # $Id:$
10
+ #
11
+
12
+ require 'pathname'
13
+ libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
14
+ $:.unshift(libpath) unless $:.include?(libpath)
15
+
16
+ require 'test/unit'
17
+ require 'digest/sha1'
18
+ require 'bio/db/gff'
19
+
20
+ module Bio
21
+ class TestGFF < Test::Unit::TestCase
22
+
23
+ def setup
24
+ data = <<END_OF_DATA
25
+ I sgd CEN 151453 151591 . + . CEN "CEN1" ; Note "CEN1\; Chromosome I Centromere"
26
+ I sgd gene 147591 151163 . - . Gene "TFC3" ; Note "transcription factor tau (TFIIIC) subunit 138"
27
+ I sgd gene 147591 151163 . - . Gene "FUN24" ; Note "transcription factor tau (TFIIIC) subunit 138"
28
+ I sgd gene 147591 151163 . - . Gene "TSV115" ; Note "transcription factor tau (TFIIIC) subunit 138"
29
+ I sgd ORF 147591 151163 . - . ORF "YAL001C" ; Note "TFC3\; transcription factor tau (TFIIIC) subunit 138"
30
+ I sgd gene 143998 147528 . + . Gene "VPS8" ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
31
+ I sgd gene 143998 147528 . + . Gene "FUN15" ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
32
+ I sgd gene 143998 147528 . + . Gene "VPT8" ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
33
+ END_OF_DATA
34
+ @obj = Bio::GFF.new(data)
35
+ end
36
+
37
+ def test_records
38
+ assert_equal(8, @obj.records.size)
39
+ end
40
+
41
+ def test_record_class
42
+ assert_equal(Bio::GFF::Record, @obj.records[0].class)
43
+ end
44
+
45
+ end # class TestGFF
46
+
47
+ class TestGFFRecord < Test::Unit::TestCase
48
+
49
+ def setup
50
+ data =<<END_OF_DATA
51
+ I sgd gene 151453 151591 . + . Gene "CEN1" ; Note "Chromosome I Centromere"
52
+ END_OF_DATA
53
+ @obj = Bio::GFF::Record.new(data)
54
+ end
55
+
56
+ def test_seqname
57
+ assert_equal('I', @obj.seqname)
58
+ end
59
+
60
+ def test_source
61
+ assert_equal('sgd', @obj.source)
62
+ end
63
+
64
+ def test_feature
65
+ assert_equal('gene', @obj.feature)
66
+ end
67
+
68
+ def test_start
69
+ assert_equal('151453', @obj.start)
70
+ end
71
+
72
+ def test_end
73
+ assert_equal('151591', @obj.end)
74
+ end
75
+
76
+ def test_score
77
+ assert_equal('.', @obj.score)
78
+ end
79
+
80
+ def test_strand
81
+ assert_equal('+', @obj.strand)
82
+ end
83
+
84
+ def test_frame
85
+ assert_equal('.', @obj.frame)
86
+ end
87
+
88
+ def test_attributes
89
+ at = {"Note"=>'"Chromosome I Centromere"', "Gene"=>'"CEN1"'}
90
+ assert_equal(at, @obj.attributes)
91
+ end
92
+
93
+ def test_comment
94
+ assert_equal(nil, @obj.comment)
95
+ end
96
+
97
+ end # class TestGFFRecord
98
+
99
+ class TestGFFRecordConstruct < Test::Unit::TestCase
100
+
101
+ def setup
102
+ @obj = Bio::GFF.new
103
+ end
104
+
105
+ def test_add_seqname
106
+ name = "test"
107
+ record = Bio::GFF::Record.new("")
108
+ record.seqname = name
109
+ @obj.records << record
110
+ assert_equal(name, @obj.records[0].seqname)
111
+ end
112
+
113
+ end # class TestGFFRecordConstruct
114
+
115
+ class TestGFF2 < Test::Unit::TestCase
116
+ def setup
117
+ data = <<END_OF_DATA
118
+ ##gff-version 2
119
+ ##date 2008-09-22
120
+ I sgd CEN 151453 151591 . + . CEN "CEN1" ; Note "CEN1; Chromosome I Centromere"
121
+ I sgd gene 147591 151163 . - . Gene "TFC3" ; Note "transcription factor tau (TFIIIC) subunit 138"
122
+ I sgd gene 147591 151163 . - . Gene "FUN24" ; Note "transcription factor tau (TFIIIC) subunit 138"
123
+ I sgd gene 147591 151163 . - . Gene "TSV115" ; Note "transcription factor tau (TFIIIC) subunit 138"
124
+ I sgd ORF 147591 151163 . - . ORF "YAL001C" ; Note "TFC3; transcription factor tau (TFIIIC) subunit 138"
125
+ I sgd gene 143998 147528 . + . Gene "VPS8" ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
126
+ I sgd gene 143998 147528 . + . Gene "FUN15" ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
127
+ I sgd gene 143998 147528 . + . Gene "VPT8" ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
128
+ END_OF_DATA
129
+ @obj = Bio::GFF::GFF2.new(data)
130
+ end
131
+
132
+ def test_const_version
133
+ assert_equal(2, Bio::GFF::GFF2::VERSION)
134
+ end
135
+
136
+ def test_gff_version
137
+ assert_equal('2', @obj.gff_version)
138
+ end
139
+
140
+ def test_metadata_size
141
+ assert_equal(1, @obj.metadata.size)
142
+ end
143
+
144
+ def test_metadata
145
+ assert_equal(Bio::GFF::GFF2::MetaData.new('date', '2008-09-22'),
146
+ @obj.metadata[0])
147
+ end
148
+
149
+ def test_records_size
150
+ assert_equal(8, @obj.records.size)
151
+ end
152
+
153
+ def test_to_s
154
+ str = <<END_OF_DATA
155
+ ##gff-version 2
156
+ ##date 2008-09-22
157
+ I sgd CEN 151453 151591 . + . CEN CEN1 ; Note "CEN1; Chromosome I Centromere"
158
+ I sgd gene 147591 151163 . - . Gene TFC3 ; Note "transcription factor tau (TFIIIC) subunit 138"
159
+ I sgd gene 147591 151163 . - . Gene FUN24 ; Note "transcription factor tau (TFIIIC) subunit 138"
160
+ I sgd gene 147591 151163 . - . Gene TSV115 ; Note "transcription factor tau (TFIIIC) subunit 138"
161
+ I sgd ORF 147591 151163 . - . ORF YAL001C ; Note "TFC3; transcription factor tau (TFIIIC) subunit 138"
162
+ I sgd gene 143998 147528 . + . Gene VPS8 ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
163
+ I sgd gene 143998 147528 . + . Gene FUN15 ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
164
+ I sgd gene 143998 147528 . + . Gene VPT8 ; Note "Vps8p is a membrane-associated hydrophilic protein which contains a C-terminal cysteine-rich region that conforms to the H2 variant of the RING finger Zn2+ binding motif."
165
+ END_OF_DATA
166
+ assert_equal(str, @obj.to_s)
167
+ end
168
+ end #class TestGFF2
169
+
170
+ class TestGFF2Record < Test::Unit::TestCase
171
+ def setup
172
+ str = "seq1\tBLASTX\tsimilarity\t101\t235\t87.1\t+\t0\tTarget \"HBA_HUMAN\" 11 55 ; E_value 0.0003 ; Align 101 11 ; Align 179 36 ; Comment \"Please ignore this \\\"Comment\\\" attribute; Escape \\x1a\\037 and \\\\\\t\\r\\n\\f\\b\\a\\e\\v; This is test.\" 123 4.56e-34 \"Test for freetext\" ; Note \"\"; Misc IdString; Misc \"free text\"; Misc 5678 "
173
+
174
+ @obj = Bio::GFF::GFF2::Record.new(str)
175
+ end
176
+
177
+ def test_to_s
178
+ str = "seq1\tBLASTX\tsimilarity\t101\t235\t87.1\t+\t0\tTarget HBA_HUMAN 11 55 ; E_value 0.0003 ; Align 101 11 ; Align 179 36 ; Comment \"Please ignore this \\\"Comment\\\" attribute; Escape \\032\\037 and \\\\\\t\\r\\n\\f\\b\\a\\e\\v; This is test.\" 123 4.56e-34 \"Test for freetext\" ; Note \"\" ; Misc IdString ; Misc \"free text\" ; Misc 5678\n"
179
+
180
+ assert_equal(str, @obj.to_s)
181
+ end
182
+
183
+ def test_eqeq
184
+ obj2 = Bio::GFF::GFF2::Record.new(@obj.to_s)
185
+ assert_equal(true, @obj == obj2)
186
+ end
187
+
188
+ def test_eqeq_false
189
+ obj2 = Bio::GFF::GFF2::Record.new(@obj.to_s)
190
+ obj2.seqname = 'seq2'
191
+ assert_equal(false, @obj == obj2)
192
+ end
193
+
194
+ def test_comment_only?
195
+ assert_equal(false, @obj.comment_only?)
196
+ end
197
+
198
+ def test_seqname
199
+ assert_equal('seq1', @obj.seqname)
200
+ end
201
+
202
+ def test_source
203
+ assert_equal('BLASTX', @obj.source)
204
+ end
205
+
206
+ def test_feature
207
+ assert_equal('similarity', @obj.feature)
208
+ end
209
+
210
+ def test_start
211
+ assert_equal(101, @obj.start)
212
+ end
213
+
214
+ def test_end
215
+ assert_equal(235, @obj.end)
216
+ end
217
+
218
+ def test_score
219
+ assert_equal(87.1, @obj.score)
220
+ end
221
+
222
+ def test_strand
223
+ assert_equal('+', @obj.strand)
224
+ end
225
+
226
+ def test_frame
227
+ assert_equal(0, @obj.frame)
228
+ end
229
+
230
+ def test_attributes_to_hash
231
+ hash = {
232
+ 'Target' =>
233
+ Bio::GFF::GFF2::Record::Value.new(['HBA_HUMAN', '11', '55']),
234
+ 'E_value' => '0.0003',
235
+ 'Align' =>
236
+ Bio::GFF::GFF2::Record::Value.new(['101', '11']),
237
+ 'Comment' =>
238
+ Bio::GFF::GFF2::Record::Value.new(["Please ignore this \"Comment\" attribute; Escape \x1a\037 and \\\t\r\n\f\b\a\e\v; This is test.", "123", "4.56e-34", "Test for freetext"]),
239
+ 'Note' => '',
240
+ 'Misc' => 'IdString'
241
+ }
242
+ assert_equal(hash, @obj.attributes_to_hash)
243
+ end
244
+
245
+ def test_attributes
246
+ attributes =
247
+ [ [ 'Target',
248
+ Bio::GFF::GFF2::Record::Value.new(['HBA_HUMAN', '11', '55']) ],
249
+ [ 'E_value', '0.0003' ],
250
+ [ 'Align',
251
+ Bio::GFF::GFF2::Record::Value.new(['101', '11']) ],
252
+ [ 'Align',
253
+ Bio::GFF::GFF2::Record::Value.new(['179', '36']) ],
254
+ [ 'Comment',
255
+ Bio::GFF::GFF2::Record::Value.new(["Please ignore this \"Comment\" attribute; Escape \x1a\037 and \\\t\r\n\f\b\a\e\v; This is test.", "123", "4.56e-34", "Test for freetext"]) ],
256
+ [ 'Note', '' ],
257
+ [ 'Misc', 'IdString' ],
258
+ [ 'Misc', 'free text' ],
259
+ [ 'Misc', '5678' ]
260
+ ]
261
+ assert_equal(attributes, @obj.attributes)
262
+ end
263
+
264
+ def test_attribute
265
+ val_Target = Bio::GFF::GFF2::Record::Value.new(['HBA_HUMAN', '11', '55'])
266
+ assert_equal(val_Target, @obj.attribute('Target'))
267
+ assert_equal('0.0003', @obj.attribute('E_value'))
268
+ val_Align0 = Bio::GFF::GFF2::Record::Value.new(['101', '11'])
269
+ val_Align1 = Bio::GFF::GFF2::Record::Value.new(['179', '36'])
270
+ assert_equal(val_Align0, @obj.attribute('Align'))
271
+ val_Comment = Bio::GFF::GFF2::Record::Value.new(["Please ignore this \"Comment\" attribute; Escape \x1a\037 and \\\t\r\n\f\b\a\e\v; This is test.", "123", "4.56e-34", "Test for freetext"])
272
+ assert_equal(val_Comment, @obj.attribute('Comment'))
273
+ assert_equal('', @obj.attribute('Note'))
274
+ assert_equal('IdString', @obj.attribute('Misc'))
275
+ end
276
+
277
+ def test_attribute_nonexistent
278
+ assert_equal(nil, @obj.attribute('NonExistent'))
279
+ end
280
+
281
+ def test_get_attribute
282
+ val_Target = Bio::GFF::GFF2::Record::Value.new(['HBA_HUMAN', '11', '55'])
283
+ assert_equal(val_Target, @obj.get_attribute('Target'))
284
+ assert_equal('0.0003', @obj.get_attribute('E_value'))
285
+ val_Align0 = Bio::GFF::GFF2::Record::Value.new(['101', '11'])
286
+ val_Align1 = Bio::GFF::GFF2::Record::Value.new(['179', '36'])
287
+ assert_equal(val_Align0, @obj.get_attribute('Align'))
288
+ val_Comment = Bio::GFF::GFF2::Record::Value.new(["Please ignore this \"Comment\" attribute; Escape \x1a\037 and \\\t\r\n\f\b\a\e\v; This is test.", "123", "4.56e-34", "Test for freetext"])
289
+ assert_equal(val_Comment, @obj.get_attribute('Comment'))
290
+ assert_equal('', @obj.get_attribute('Note'))
291
+ assert_equal('IdString', @obj.get_attribute('Misc'))
292
+ end
293
+
294
+ def test_get_attribute_nonexistent
295
+ assert_equal(nil, @obj.get_attribute('NonExistent'))
296
+ end
297
+
298
+ def test_get_attributes
299
+ val_Target = Bio::GFF::GFF2::Record::Value.new(['HBA_HUMAN', '11', '55'])
300
+ assert_equal([ val_Target ], @obj.get_attributes('Target'))
301
+ assert_equal([ '0.0003' ], @obj.get_attributes('E_value'))
302
+ val_Align0 = Bio::GFF::GFF2::Record::Value.new(['101', '11'])
303
+ val_Align1 = Bio::GFF::GFF2::Record::Value.new(['179', '36'])
304
+ assert_equal([ val_Align0, val_Align1 ],
305
+ @obj.get_attributes('Align'))
306
+ val_Comment = Bio::GFF::GFF2::Record::Value.new(["Please ignore this \"Comment\" attribute; Escape \x1a\037 and \\\t\r\n\f\b\a\e\v; This is test.", "123", "4.56e-34", "Test for freetext"])
307
+ assert_equal([ val_Comment ], @obj.get_attributes('Comment'))
308
+ assert_equal([ '' ], @obj.get_attributes('Note'))
309
+ assert_equal([ 'IdString', 'free text', '5678' ],
310
+ @obj.get_attributes('Misc'))
311
+ end
312
+
313
+ def test_get_attributes_nonexistent
314
+ assert_equal([], @obj.get_attributes('NonExistent'))
315
+ end
316
+
317
+ def test_set_attribute
318
+ assert_equal('0.0003', @obj.attribute('E_value'))
319
+ assert_equal('1e-10', @obj.set_attribute('E_value', '1e-10'))
320
+ assert_equal('1e-10', @obj.attribute('E_value'))
321
+ end
322
+
323
+ def test_set_attribute_multiple
324
+ assert_equal([ 'IdString', 'free text', '5678' ],
325
+ @obj.get_attributes('Misc'))
326
+ assert_equal('Replaced',
327
+ @obj.set_attribute('Misc', 'Replaced'))
328
+ assert_equal([ 'Replaced', 'free text', '5678' ],
329
+ @obj.get_attributes('Misc'))
330
+ end
331
+
332
+ def test_set_attribute_nonexistent
333
+ assert_equal(nil, @obj.attribute('NonExistent'))
334
+ assert_equal('test', @obj.set_attribute('NonExistent', 'test'))
335
+ assert_equal('test', @obj.attribute('NonExistent'))
336
+ end
337
+
338
+ def test_replace_attributes
339
+ assert_equal([ '0.0003' ], @obj.get_attributes('E_value'))
340
+ assert_equal(@obj, @obj.replace_attributes('E_value', '1e-10'))
341
+ assert_equal([ '1e-10' ], @obj.get_attributes('E_value'))
342
+ end
343
+
344
+ def test_replace_attributes_single_multiple
345
+ assert_equal([ '0.0003' ], @obj.get_attributes('E_value'))
346
+ assert_equal(@obj, @obj.replace_attributes('E_value',
347
+ '1e-10', '3.14', '2.718'))
348
+ assert_equal([ '1e-10', '3.14', '2.718' ],
349
+ @obj.get_attributes('E_value'))
350
+ end
351
+
352
+ def test_replace_attributes_multiple_single
353
+ assert_equal([ 'IdString', 'free text', '5678' ],
354
+ @obj.get_attributes('Misc'))
355
+ assert_equal(@obj,
356
+ @obj.replace_attributes('Misc', 'Replaced_All'))
357
+ assert_equal([ 'Replaced_All' ],
358
+ @obj.get_attributes('Misc'))
359
+ end
360
+
361
+ def test_replace_attributes_multiple_multiple_two
362
+ assert_equal([ 'IdString', 'free text', '5678' ],
363
+ @obj.get_attributes('Misc'))
364
+ assert_equal(@obj,
365
+ @obj.replace_attributes('Misc',
366
+ 'Replaced', 'test2'))
367
+ assert_equal([ 'Replaced', 'test2' ],
368
+ @obj.get_attributes('Misc'))
369
+ end
370
+
371
+ def test_replace_attributes_multiple_multiple_same
372
+ assert_equal([ 'IdString', 'free text', '5678' ],
373
+ @obj.get_attributes('Misc'))
374
+ assert_equal(@obj,
375
+ @obj.replace_attributes('Misc',
376
+ 'Replaced', 'test2', 'test3'))
377
+ assert_equal([ 'Replaced', 'test2', 'test3' ],
378
+ @obj.get_attributes('Misc'))
379
+ end
380
+
381
+ def test_replace_attributes_multiple_multiple_over
382
+ assert_equal([ 'IdString', 'free text', '5678' ],
383
+ @obj.get_attributes('Misc'))
384
+ assert_equal(@obj,
385
+ @obj.replace_attributes('Misc',
386
+ 'Replaced', 'test2', 'test3', '4'))
387
+ assert_equal([ 'Replaced', 'test2', 'test3', '4' ],
388
+ @obj.get_attributes('Misc'))
389
+ end
390
+
391
+ def test_replace_attributes_nonexistent
392
+ assert_equal(nil, @obj.attribute('NonExistent'))
393
+ assert_equal(@obj, @obj.replace_attributes('NonExistent', 'test'))
394
+ assert_equal([ 'test' ], @obj.get_attributes('NonExistent'))
395
+ end
396
+
397
+ def test_replace_attributes_nonexistent_multiple
398
+ assert_equal(nil, @obj.attribute('NonExistent'))
399
+ assert_equal(@obj,
400
+ @obj.replace_attributes('NonExistent',
401
+ 'test', 'gff2', 'attr'))
402
+ assert_equal([ 'test', 'gff2', 'attr' ],
403
+ @obj.get_attributes('NonExistent'))
404
+ end
405
+
406
+ def test_delete_attribute
407
+ assert_equal('0.0003', @obj.attribute('E_value'))
408
+ assert_equal('0.0003', @obj.delete_attribute('E_value', '0.0003'))
409
+ assert_equal(nil, @obj.attribute('E_value'))
410
+ end
411
+
412
+ def test_delete_attribute_nil
413
+ assert_equal('0.0003', @obj.attribute('E_value'))
414
+ assert_equal(nil, @obj.delete_attribute('E_value', '3'))
415
+ assert_equal('0.0003', @obj.attribute('E_value'))
416
+ end
417
+
418
+ def test_delete_attribute_multiple
419
+ assert_equal([ 'IdString', 'free text', '5678' ],
420
+ @obj.get_attributes('Misc'))
421
+ assert_equal('free text',
422
+ @obj.delete_attribute('Misc', 'free text'))
423
+ assert_equal([ 'IdString', '5678' ],
424
+ @obj.get_attributes('Misc'))
425
+ end
426
+
427
+ def test_delete_attribute_multiple2
428
+ assert_equal([ 'IdString', 'free text', '5678' ],
429
+ @obj.get_attributes('Misc'))
430
+ assert_equal('IdString',
431
+ @obj.delete_attribute('Misc', 'IdString'))
432
+ assert_equal([ 'free text', '5678' ],
433
+ @obj.get_attributes('Misc'))
434
+ assert_equal('5678',
435
+ @obj.delete_attribute('Misc', '5678'))
436
+ assert_equal([ 'free text' ],
437
+ @obj.get_attributes('Misc'))
438
+ end
439
+
440
+ def test_delete_attribute_multiple_nil
441
+ assert_equal([ 'IdString', 'free text', '5678' ],
442
+ @obj.get_attributes('Misc'))
443
+ assert_equal(nil,
444
+ @obj.delete_attribute('Misc', 'test'))
445
+ assert_equal([ 'IdString', 'free text', '5678' ],
446
+ @obj.get_attributes('Misc'))
447
+ end
448
+
449
+ def test_delete_attribute_nonexistent
450
+ assert_equal(nil, @obj.attribute('NonExistent'))
451
+ assert_equal(nil, @obj.delete_attribute('NonExistent', 'test'))
452
+ assert_equal([], @obj.get_attributes('NonExistent'))
453
+ end
454
+
455
+ def test_delete_attributes
456
+ assert_equal('0.0003', @obj.attribute('E_value'))
457
+ assert_equal(@obj, @obj.delete_attributes('E_value'))
458
+ assert_equal(nil, @obj.attribute('E_value'))
459
+ end
460
+
461
+ def test_delete_attributes_multiple
462
+ assert_equal([ 'IdString', 'free text', '5678' ],
463
+ @obj.get_attributes('Misc'))
464
+ assert_equal(@obj, @obj.delete_attributes('Misc'))
465
+ assert_equal([], @obj.get_attributes('Misc'))
466
+ end
467
+
468
+ def test_delete_attributes_nonexistent
469
+ assert_equal(nil, @obj.attribute('NonExistent'))
470
+ assert_equal(nil, @obj.delete_attributes('NonExistent'))
471
+ assert_equal([], @obj.get_attributes('NonExistent'))
472
+ end
473
+
474
+ def test_sort_attributes_by_tag!
475
+ tags = %w( Comment Align E_value Note )
476
+ assert_equal(@obj, @obj.sort_attributes_by_tag!(tags))
477
+ assert_equal(%w( Comment Align Align E_value Note Target
478
+ Misc Misc Misc ),
479
+ @obj.attributes.collect { |x| x[0] })
480
+ # check if the order of 'Misc' is not changed
481
+ assert_equal([ 'IdString', 'free text', '5678' ],
482
+ @obj.get_attributes('Misc'))
483
+ end
484
+
485
+ def test_sort_attributes_by_tag_bang_test2
486
+ tags = %w( E_value Misc Note Target )
487
+ assert_equal(@obj, @obj.sort_attributes_by_tag!(tags))
488
+ assert_equal(%w( E_value Misc Misc Misc Note Target
489
+ Align Align Comment ),
490
+ @obj.attributes.collect { |x| x[0] })
491
+ # check if the order of 'Misc' is not changed
492
+ assert_equal([ 'IdString', 'free text', '5678' ],
493
+ @obj.get_attributes('Misc'))
494
+ end
495
+
496
+ def test_sort_attributes_by_tag_bang_with_block
497
+ assert_equal(@obj,
498
+ @obj.sort_attributes_by_tag! { |x, y|
499
+ x <=> y
500
+ })
501
+ assert_equal(%w( Align Align Comment E_value Misc Misc Misc
502
+ Note Target ),
503
+ @obj.attributes.collect { |x| x[0] })
504
+ # check if the order of 'Misc' is not changed
505
+ assert_equal([ 'IdString', 'free text', '5678' ],
506
+ @obj.get_attributes('Misc'))
507
+ end
508
+ end #class TestGFF2Record
509
+
510
+ class TestGFF2RecordEmpty < Test::Unit::TestCase
511
+ def setup
512
+ @obj = Bio::GFF::GFF2::Record.new('# test comment')
513
+ end
514
+
515
+ def test_comment_only?
516
+ assert_equal(true, @obj.comment_only?)
517
+ end
518
+
519
+ def test_comment_only_false
520
+ @obj.seqname = 'test'
521
+ assert_equal(false, @obj.comment_only?)
522
+ end
523
+
524
+ def test_to_s
525
+ assert_equal("# test comment\n", @obj.to_s)
526
+ end
527
+
528
+ def test_to_s_not_empty
529
+ @obj.seqname = 'test'
530
+ @obj.feature = 'region'
531
+ @obj.start = 1
532
+ @obj.end = 100
533
+ assert_equal("test\t.\tregion\t1\t100\t.\t.\t.\t\t# test comment\n",
534
+ @obj.to_s)
535
+ @obj.add_attribute('Gene', 'unknown')
536
+ assert_equal("test\t.\tregion\t1\t100\t.\t.\t.\tGene unknown\t# test comment\n",
537
+ @obj.to_s)
538
+ end
539
+
540
+ def test_comment
541
+ assert_equal(' test comment', @obj.comment)
542
+ end
543
+
544
+ def test_comment_eq
545
+ assert_equal('changed the comment',
546
+ @obj.comment = 'changed the comment')
547
+ end
548
+ end #class TestGFF2RecordEmpty
549
+
550
+ class TestGFF2ComplexAttributes < Test::Unit::TestCase
551
+
552
+ # The test string comes from the Popular genome annotation from the JGI.
553
+ # ftp://ftp.jgi-psf.org/pub/JGI_data/Poplar/annotation/v1.1/Poptr1_1.JamboreeModels.gff.gz
554
+ # Thanks to Tomoaki NISHIYAMA who picks up the example line.
555
+ def test_attributes_case1
556
+ str = "LG_I\tJGI\tCDS\t11052\t11064\t.\t-\t0\tname \"grail3.0116000101\"; proteinId 639579; exonNumber 3\n"
557
+
558
+ attributes = [
559
+ [ "name", "grail3.0116000101" ],
560
+ [ "proteinId", "639579" ],
561
+ [ "exonNumber", "3" ]
562
+ ]
563
+ record = Bio::GFF::GFF2::Record.new(str)
564
+ assert_equal(attributes, record.attributes)
565
+ end
566
+
567
+ # The test string is modified from that of test_attributes_case1.
568
+ def test_attributes_case2
569
+ str = "LG_I\tJGI\tCDS\t11052\t11064\t.\t-\t0\tname \"grail3.0116000101\"; proteinId 639579; exonNumber 3; Note \"Semicolons ; and \;, and quote \\\" can be OK\"; Comment \"This is the \\\"comment\\\"\"\n"
570
+
571
+ attributes = [
572
+ [ "name", "grail3.0116000101" ],
573
+ [ "proteinId", "639579" ],
574
+ [ "exonNumber", "3" ],
575
+ [ "Note", "Semicolons ; and ;, and quote \" can be OK" ],
576
+ [ "Comment", "This is the \"comment\"" ]
577
+ ]
578
+ record = Bio::GFF::GFF2::Record.new(str)
579
+ assert_equal(attributes, record.attributes)
580
+ end
581
+
582
+ def test_attributes_incompatible_backslash_semicolon
583
+ # No special treatments for backslash-semicolon outside the free text.
584
+ str =<<END_OF_DATA
585
+ I sgd gene 151453 151591 . + . Gene "CEN1" ; Note "Chromosome I Centromere"; Semicolon a "b;c" d "e;f;g" h; Illegal a\\;b c d; Comment "a ; b"
586
+ END_OF_DATA
587
+
588
+ attributes = [
589
+ [ 'Gene', 'CEN1' ],
590
+ [ 'Note', 'Chromosome I Centromere' ],
591
+ [ 'Semicolon',
592
+ Bio::GFF::GFF2::Record::Value.new(['a', 'b;c', 'd', 'e;f;g', 'h']) ],
593
+ [ 'Illegal', "a\\" ],
594
+ [ 'b', Bio::GFF::GFF2::Record::Value.new(['c', 'd']) ],
595
+ [ 'Comment', 'a ; b' ]
596
+ ]
597
+ record = Bio::GFF::GFF2::Record.new(str)
598
+ assert_equal(attributes, record.attributes)
599
+ end
600
+
601
+ end #class TestGFF2ComplexAttributes
602
+
603
+ class TestGFF2MetaData < Test::Unit::TestCase
604
+ def setup
605
+ @data =
606
+ Bio::GFF::GFF2::MetaData.new('date', '2008-09-22')
607
+ end
608
+
609
+ def test_parse
610
+ assert_equal(@data,
611
+ Bio::GFF::GFF2::MetaData.parse('##date 2008-09-22'))
612
+ end
613
+
614
+ def test_directive
615
+ assert_equal('date', @data.directive)
616
+ end
617
+
618
+ def test_data
619
+ assert_equal('2008-09-22', @data.data)
620
+ end
621
+ end #class TestGFF2MetaData
622
+
623
+ class TestGFF3 < Test::Unit::TestCase
624
+ def setup
625
+ @data =<<END_OF_DATA
626
+ ##gff-version 3
627
+ ##sequence-region test01 1 400
628
+ test01 RANDOM contig 1 400 . + . ID=test01;Note=this is test
629
+ test01 . mRNA 101 230 . + . ID=mrna01;Name=testmRNA;Note=this is test mRNA
630
+ test01 . mRNA 101 280 . + . ID=mrna01a;Name=testmRNAalterative;Note=test of alternative splicing variant
631
+ test01 . exon 101 160 . + . ID=exon01;Name=exon01;Alias=exon 1;Parent=mrna01,mrna01a
632
+ test01 . exon 201 230 . + . ID=exon02;Name=exon02;Alias=exon 2;Parent=mrna01
633
+ test01 . exon 251 280 . + . ID=exon02a;Name=exon02a;Alias=exon 2a;Parent=mrna01a
634
+ test01 . Match 101 123 . . . ID=match01;Name=match01;Target=EST101 1 21;Gap=M8 D3 M6 I1 M6
635
+ ##FASTA
636
+ >test01
637
+ ACGAAGATTTGTATGACTGATTTATCCTGGACAGGCATTGGTCAGATGTCTCCTTCCGTATCGTCGTTTA
638
+ GTTGCAAATCCGAGTGTTCGGGGGTATTGCTATTTGCCACCTAGAAGCGCAACATGCCCAGCTTCACACA
639
+ CCATAGCGAACACGCCGCCCCGGTGGCGACTATCGGTCGAAGTTAAGACAATTCATGGGCGAAACGAGAT
640
+ AATGGGTACTGCACCCCTCGTCCTGTAGAGACGTCACAGCCAACGTGCCTTCTTATCTTGATACATTAGT
641
+ GCCCAAGAATGCGATCCCAGAAGTCTTGGTTCTAAAGTCGTCGGAAAGATTTGAGGAACTGCCATACAGC
642
+ CCGTGGGTGAAACTGTCGACATCCATTGTGCGAATAGGCCTGCTAGTGAC
643
+ END_OF_DATA
644
+ @gff3 = Bio::GFF::GFF3.new(@data)
645
+ end
646
+
647
+ def test_const_version
648
+ assert_equal(3, Bio::GFF::GFF3::VERSION)
649
+ end
650
+
651
+ def test_sequence_regions
652
+ region = Bio::GFF::GFF3::SequenceRegion.new('test01', 1, 400)
653
+ assert_equal([ region ], @gff3.sequence_regions)
654
+ end
655
+
656
+ def test_gff_version
657
+ assert_equal('3', @gff3.gff_version)
658
+ end
659
+
660
+ def test_records
661
+ assert_equal(7, @gff3.records.size)
662
+ r_test01 = Bio::GFF::GFF3::Record.new('test01',
663
+ 'RANDOM',
664
+ 'contig',
665
+ 1, 400, nil, '+', nil,
666
+ [ ['ID', 'test01'],
667
+ ['Note', 'this is test'] ])
668
+ r_mrna01 = Bio::GFF::GFF3::Record.new('test01',
669
+ nil,
670
+ 'mRNA',
671
+ 101, 230, nil, '+', nil,
672
+ [ ['ID', 'mrna01'],
673
+ ['Name', 'testmRNA'],
674
+ ['Note', 'this is test mRNA'] ])
675
+ r_exon01 = Bio::GFF::GFF3::Record.new('test01',
676
+ nil,
677
+ 'exon',
678
+ 101, 160, nil, '+', nil,
679
+ [ ['ID', 'exon01'],
680
+ ['Name', 'exon01'],
681
+ ['Alias', 'exon 1'],
682
+ ['Parent', 'mrna01'],
683
+ ['Parent', 'mrna01a'] ])
684
+
685
+ target = Bio::GFF::GFF3::Record::Target.new('EST101', 1, 21)
686
+ gap = Bio::GFF::GFF3::Record::Gap.new('M8 D3 M6 I1 M6')
687
+ r_match01 =Bio::GFF::GFF3::Record.new('test01',
688
+ nil,
689
+ 'Match',
690
+ 101, 123, nil, nil, nil,
691
+ [ ['ID', 'match01'],
692
+ ['Name', 'match01'],
693
+ ['Target', target],
694
+ ['Gap', gap] ])
695
+ assert_equal(r_test01, @gff3.records[0])
696
+ assert_equal(r_mrna01, @gff3.records[1])
697
+ assert_equal(r_exon01, @gff3.records[3])
698
+ assert_equal(r_match01, @gff3.records[6])
699
+ end
700
+
701
+ def test_sequences
702
+ assert_equal(1, @gff3.sequences.size)
703
+ assert_equal('test01', @gff3.sequences[0].entry_id)
704
+ assert_equal('3510a3c4f66f9c2ab8d4d97446490aced7ed1fa4',
705
+ Digest::SHA1.hexdigest(@gff3.sequences[0].seq.to_s))
706
+ end
707
+
708
+ def test_to_s
709
+ assert_equal(@data, @gff3.to_s)
710
+ end
711
+
712
+ end #class TestGFF3
713
+
714
+ class TestGFF3Record < Test::Unit::TestCase
715
+
716
+ def setup
717
+ data =<<END_OF_DATA
718
+ chrI SGD centromere 151467 151584 . + . ID=CEN1;Name=CEN1;gene=CEN1;Alias=CEN1,test%3B0001;Note=Chromosome%20I%20centromere;dbxref=SGD:S000006463;Target=test%2002 123 456 -,test%2C03 159 314;memo%3Dtest%3Battr=99.9%25%09match
719
+ END_OF_DATA
720
+ @obj = Bio::GFF::GFF3::Record.new(data)
721
+ end
722
+
723
+ def test_seqname
724
+ assert_equal('chrI', @obj.seqname)
725
+ end
726
+
727
+ def test_source
728
+ assert_equal('SGD', @obj.source)
729
+ end
730
+
731
+ def test_feature
732
+ assert_equal('centromere', @obj.feature)
733
+ end
734
+
735
+ def test_start
736
+ assert_equal(151467, @obj.start)
737
+ end
738
+
739
+ def test_end
740
+ assert_equal(151584, @obj.end)
741
+ end
742
+
743
+ def test_score
744
+ assert_equal(nil, @obj.score)
745
+ end
746
+
747
+ def test_strand
748
+ assert_equal('+', @obj.strand)
749
+ end
750
+
751
+ def test_frame
752
+ assert_equal(nil, @obj.frame)
753
+ end
754
+
755
+ def test_attributes
756
+ attr = [
757
+ ['ID', 'CEN1'],
758
+ ['Name', 'CEN1'],
759
+ ['gene', 'CEN1'],
760
+ ['Alias', 'CEN1'],
761
+ ['Alias', 'test;0001'],
762
+ ['Note', 'Chromosome I centromere'],
763
+ ['dbxref', 'SGD:S000006463'],
764
+ ['Target',
765
+ Bio::GFF::GFF3::Record::Target.new('test 02', 123, 456, '-')],
766
+ ['Target',
767
+ Bio::GFF::GFF3::Record::Target.new('test,03', 159, 314)],
768
+ ['memo=test;attr', "99.9%\tmatch"]
769
+ ]
770
+ assert_equal(attr, @obj.attributes)
771
+ end
772
+
773
+ def test_to_s
774
+ str =<<END_OF_DATA
775
+ chrI SGD centromere 151467 151584 . + . ID=CEN1;Name=CEN1;gene=CEN1;Alias=CEN1,test%3B0001;Note=Chromosome I centromere;dbxref=SGD:S000006463;Target=test%2002 123 456 -,test%2C03 159 314;memo%3Dtest%3Battr=99.9%25%09match
776
+ END_OF_DATA
777
+ assert_equal(str, @obj.to_s)
778
+ end
779
+
780
+ def test_to_s_attr_order_changed
781
+ str = <<END_OF_STR
782
+ chrI SGD centromere 151467 151584 . + . ID=CEN1;Name=CEN1;Alias=CEN1,test%3B0001;Target=test%2002 123 456 -,test%2C03 159 314;Note=Chromosome I centromere;dbxref=SGD:S000006463;gene=CEN1;memo%3Dtest%3Battr=99.9%25%09match
783
+ END_OF_STR
784
+
785
+ keys = [ 'ID', 'Name', 'Alias', 'Target', 'Note', 'dbxref', 'gene' ]
786
+ @obj.sort_attributes_by_tag!(keys)
787
+ assert_equal(str, @obj.to_s)
788
+ end
789
+ end #class TestGFF3Record
790
+
791
+ class TestGFF3RecordMisc < Test::Unit::TestCase
792
+ def test_attributes_none
793
+ # test blank with tab
794
+ data =<<END_OF_DATA
795
+ I sgd gene 151453 151591 . + .
796
+ END_OF_DATA
797
+ obj = Bio::GFF::GFF3::Record.new(data)
798
+ assert_equal([], obj.attributes)
799
+
800
+ # test blank with no tab at end
801
+ data =<<END_OF_DATA
802
+ I sgd gene 151453 151591 . + .
803
+ END_OF_DATA
804
+ obj = Bio::GFF::GFF3::Record.new(data)
805
+ assert_equal([], obj.attributes)
806
+ end
807
+
808
+ def test_attributes_one
809
+ data =<<END_OF_DATA
810
+ I sgd gene 151453 151591 . + . ID=CEN1
811
+ END_OF_DATA
812
+ obj = Bio::GFF::GFF3::Record.new(data)
813
+ at = [ ["ID", 'CEN1'] ]
814
+ assert_equal(at, obj.attributes)
815
+ end
816
+
817
+ def test_attributes_with_escaping
818
+ data =<<END_OF_DATA
819
+ I sgd gene 151453 151591 . + . ID=CEN1;gene=CEN1%3Boh;Note=Chromosome I Centromere
820
+ END_OF_DATA
821
+ obj = Bio::GFF::GFF3::Record.new(data)
822
+ at = [ ['ID', 'CEN1'],
823
+ ["gene", 'CEN1;oh'],
824
+ ["Note", 'Chromosome I Centromere']
825
+ ]
826
+ assert_equal(at, obj.attributes)
827
+ end
828
+
829
+ def test_score
830
+ data =<<END_OF_DATA
831
+ ctg123 src match 456 788 1e-10 - . ID=test01
832
+ END_OF_DATA
833
+ obj = Bio::GFF::GFF3::Record.new(data)
834
+ assert_equal(1e-10, obj.score)
835
+ obj.score = 0.5
836
+ assert_equal(0.5, obj.score)
837
+ end
838
+
839
+ def test_phase
840
+ data =<<END_OF_DATA
841
+ ctg123 src CDS 456 788 . - 2 ID=test02
842
+ END_OF_DATA
843
+ obj = Bio::GFF::GFF3::Record.new(data)
844
+ assert_equal(2, obj.phase)
845
+ assert_equal(2, obj.frame)
846
+ obj.phase = 1
847
+ assert_equal(1, obj.phase)
848
+ assert_equal(1, obj.frame)
849
+ end
850
+
851
+ def test_initialize_9
852
+ obj = Bio::GFF::GFF3::Record.new('test01',
853
+ 'testsrc',
854
+ 'exon',
855
+ 1, 400, nil, '+', nil,
856
+ [ ['ID', 'test01'],
857
+ ['Note', 'this is test'] ])
858
+ assert_equal('test01', obj.seqid)
859
+ end
860
+
861
+ def test_to_s_void
862
+ obj = Bio::GFF::GFF3::Record.new
863
+ assert_equal(".\t.\t.\t.\t.\t.\t.\t.\t.\n", obj.to_s)
864
+ end
865
+
866
+ end #class TestGFF3RecordMisc
867
+
868
+ class TestGFF3RecordEscape < Test::Unit::TestCase
869
+ def setup
870
+ @obj = Object.new.extend(Bio::GFF::GFF3::Escape)
871
+ @str = "A>B\tC=100%;d=e,f,g h"
872
+ end
873
+
874
+ def test_escape
875
+ str = @str
876
+ assert_equal('A>B%09C=100%25;d=e,f,g h',
877
+ @obj.instance_eval { escape(str) })
878
+ end
879
+
880
+ def test_escape_attribute
881
+ str = @str
882
+ assert_equal('A>B%09C%3D100%25%3Bd%3De%2Cf%2Cg h',
883
+ @obj.instance_eval { escape_attribute(str) })
884
+ end
885
+
886
+ def test_escape_seqid
887
+ str = @str
888
+ assert_equal('A%3EB%09C%3D100%25%3Bd%3De%2Cf%2Cg%20h',
889
+ @obj.instance_eval { escape_seqid(str) })
890
+ end
891
+
892
+ def test_unescape
893
+ escaped_str = 'A%3EB%09C%3D100%25%3Bd%3De%2Cf%2Cg%20h'
894
+ assert_equal(@str,
895
+ @obj.instance_eval {
896
+ unescape(escaped_str) })
897
+ end
898
+ end #class TestGFF3RecordEscape
899
+
900
+ class TestGFF3RecordTarget < Test::Unit::TestCase
901
+
902
+ def setup
903
+ @target =
904
+ [ Bio::GFF::GFF3::Record::Target.new('ABCD1234', 123, 456, '+'),
905
+ Bio::GFF::GFF3::Record::Target.new(">X Y=Z;P%,Q\tR", 78, 90),
906
+ Bio::GFF::GFF3::Record::Target.new(nil, nil, nil),
907
+ ]
908
+ end
909
+
910
+ def test_parse
911
+ strings =
912
+ [ 'ABCD1234 123 456 +',
913
+ '%3EX%20Y%3DZ%3BP%25%2CQ%09R 78 90',
914
+ ''
915
+ ]
916
+ @target.each do |target|
917
+ str = strings.shift
918
+ assert_equal(target, Bio::GFF::GFF3::Record::Target.parse(str))
919
+ end
920
+ end
921
+
922
+ def test_target_id
923
+ assert_equal('ABCD1234', @target[0].target_id)
924
+ assert_equal(">X Y=Z;P%,Q\tR", @target[1].target_id)
925
+ assert_equal(nil, @target[2].target_id)
926
+ end
927
+
928
+ def test_start
929
+ assert_equal(123, @target[0].start)
930
+ assert_equal(78, @target[1].start)
931
+ assert_nil(@target[2].start)
932
+ end
933
+
934
+ def test_end
935
+ assert_equal(456, @target[0].end)
936
+ assert_equal(90, @target[1].end)
937
+ assert_nil(@target[2].end)
938
+ end
939
+
940
+ def test_strand
941
+ assert_equal('+', @target[0].strand)
942
+ assert_nil(@target[1].strand)
943
+ assert_nil(@target[2].strand)
944
+ end
945
+
946
+ def test_to_s
947
+ assert_equal('ABCD1234 123 456 +', @target[0].to_s)
948
+ assert_equal('%3EX%20Y%3DZ%3BP%25%2CQ%09R 78 90', @target[1].to_s)
949
+ assert_equal('. . .', @target[2].to_s)
950
+ end
951
+
952
+ end #class TestGFF3RecordTarget
953
+
954
+ class TestGFF3RecordGap < Test::Unit::TestCase
955
+ def setup
956
+ # examples taken from http://song.sourceforge.net/gff3.shtml
957
+ @gaps_src = [ 'M8 D3 M6 I1 M6',
958
+ 'M3 I1 M2 F1 M4',
959
+ 'M3 I1 M2 R1 M4' ]
960
+ @gaps = @gaps_src.collect { |x| Bio::GFF::GFF3::Record::Gap.new(x) }
961
+ end
962
+
963
+ def test_to_s
964
+ @gaps_src.each do |src|
965
+ assert_equal(src, @gaps.shift.to_s)
966
+ end
967
+ end
968
+
969
+ def test_eqeq
970
+ gap = Bio::GFF::GFF3::Record::Gap.new('M8 D3 M6 I1 M6')
971
+ assert(gap == @gaps[0])
972
+ assert_equal(false, gap == @gaps[1])
973
+ end
974
+
975
+ def test_process_sequences_na
976
+ ref = 'CAAGACCTAAACTGGATTCCAAT'
977
+ tgt = 'CAAGACCTCTGGATATCCAAT'
978
+ ref_aligned = 'CAAGACCTAAACTGGAT-TCCAAT'
979
+ tgt_aligned = 'CAAGACCT---CTGGATATCCAAT'
980
+ assert_equal([ ref_aligned, tgt_aligned ],
981
+ @gaps[0].process_sequences_na(ref, tgt))
982
+ end
983
+
984
+ def test_process_sequences_na_tooshort
985
+ ref = 'CAAGACCTAAACTGGATTCCAA'
986
+ tgt = 'CAAGACCTCTGGATATCCAA'
987
+ assert_raise(RuntimeError) { @gaps[0].process_sequences_na(ref, tgt) }
988
+ ref = 'c'
989
+ tgt = 'c'
990
+ assert_raise(RuntimeError) { @gaps[0].process_sequences_na(ref, tgt) }
991
+ end
992
+
993
+ def test_process_sequences_na_aa
994
+ ref1 = 'atgaaggaggttattgaatgtcggcggt'
995
+ tgt1 = 'MKEVVINVGG'
996
+ ref1_aligned = 'atgaaggag---gttattgaatgtcggcggt'
997
+ tgt1_aligned = 'M K E V V I >N V G G '
998
+ assert_equal([ ref1_aligned, tgt1_aligned ],
999
+ @gaps[1].process_sequences_na_aa(ref1, tgt1))
1000
+ end
1001
+
1002
+ def test_process_sequences_na_aa_reverse_frameshift
1003
+ ref2 = 'atgaaggaggttataatgtcggcggt'
1004
+ tgt2 = 'MKEVVINVGG'
1005
+ ref2_aligned = 'atgaaggag---gttat<aatgtcggcggt'
1006
+ tgt2_aligned = 'M K E V V I N V G G '
1007
+ assert_equal([ ref2_aligned, tgt2_aligned ],
1008
+ @gaps[2].process_sequences_na_aa(ref2, tgt2))
1009
+ end
1010
+
1011
+ def test_process_sequences_na_aa_reverse_frameshift_more
1012
+ gap = Bio::GFF::GFF3::Record::Gap.new("M3 R3 M3")
1013
+ ref = 'atgaagattaatgtc'
1014
+ tgt = 'MKIINV'
1015
+ ref_aligned = 'atgaag<<<attaatgtc'
1016
+ tgt_aligned = 'M K I I N V '
1017
+ assert_equal([ ref_aligned, tgt_aligned ],
1018
+ gap.process_sequences_na_aa(ref, tgt))
1019
+ end
1020
+
1021
+ def test_process_sequences_na_aa_tooshort
1022
+ ref2 = 'atgaaggaggttataatgtcggcgg'
1023
+ tgt2 = 'MKEVVINVG'
1024
+ assert_raise(RuntimeError) do
1025
+ @gaps[2].process_sequences_na_aa(ref2, tgt2)
1026
+ end
1027
+
1028
+ ref2 = 'atg'
1029
+ tgt2 = 'M'
1030
+ assert_raise(RuntimeError) do
1031
+ @gaps[2].process_sequences_na_aa(ref2, tgt2)
1032
+ end
1033
+ end
1034
+
1035
+ def test___scan_gap
1036
+ str1 = 'CAAGACCT---CTGGATATCCAAT'
1037
+ str2 = '-aaaaaaa-a-a---ggag--'
1038
+ c = Bio::GFF::GFF3::Record::Gap::Code
1039
+ data1 = [ c.new(:M, 8), c.new(:I, 3), c.new(:M, 13) ]
1040
+ data2 = [ c.new(:I, 1), c.new(:M, 7), c.new(:I, 1),
1041
+ c.new(:M, 1), c.new(:I, 1), c.new(:M, 1),
1042
+ c.new(:I, 3), c.new(:M, 4), c.new(:I, 2) ]
1043
+
1044
+ assert_equal(data1, @gaps[0].instance_eval { __scan_gap(str1) })
1045
+ assert_equal(data2, @gaps[0].instance_eval { __scan_gap(str2) })
1046
+ end
1047
+
1048
+ def test_new_from_sequences_na
1049
+ ref_aligned = 'CAAGACCTAAACTGGAT-TCCAAT'
1050
+ tgt_aligned = 'CAAGACCT---CTGGATATCCAAT'
1051
+
1052
+ assert_equal(@gaps[0], Bio::GFF::GFF3::Record::Gap.new_from_sequences_na(ref_aligned, tgt_aligned))
1053
+ end
1054
+
1055
+ def test_new_from_sequences_na_aa
1056
+ ref = 'atgaaggag---gttattgaatgtcggcggt'
1057
+ tgt = 'M K E V V I >N V G G '
1058
+ assert_equal(@gaps[1],
1059
+ Bio::GFF::GFF3::Record::Gap.new_from_sequences_na_aa(ref,
1060
+ tgt))
1061
+ end
1062
+
1063
+ def test_new_from_sequences_na_aa_reverse_frameshift
1064
+ ref = 'atgaaggag---gttat<aatgtcggcggt'
1065
+ tgt = 'M K E V V I N V G G '
1066
+ assert_equal(@gaps[2],
1067
+ Bio::GFF::GFF3::Record::Gap.new_from_sequences_na_aa(ref,
1068
+ tgt))
1069
+ end
1070
+
1071
+ def test_new_from_sequences_na_aa_reverse_frameshift_more
1072
+ gap = Bio::GFF::GFF3::Record::Gap.new("M3 R3 M3")
1073
+ ref = 'atgaag<<<attaatgtc'
1074
+ tgt = 'M K I I N V '
1075
+ assert_equal(gap,
1076
+ Bio::GFF::GFF3::Record::Gap.new_from_sequences_na_aa(ref,
1077
+ tgt))
1078
+ end
1079
+
1080
+ def test_new_from_sequences_na_aa_boundary_gap
1081
+ g = Bio::GFF::GFF3::Record::Gap
1082
+
1083
+ ref = '---atgatg'
1084
+ tgt = 'K M M '
1085
+ assert_equal(Bio::GFF::GFF3::Record::Gap.new('I1 M2'),
1086
+ g.new_from_sequences_na_aa(ref, tgt))
1087
+
1088
+ ref = 'atgatg---'
1089
+ tgt = 'M M K '
1090
+ assert_equal(Bio::GFF::GFF3::Record::Gap.new('M2 I1'),
1091
+ g.new_from_sequences_na_aa(ref, tgt))
1092
+
1093
+ ref = 'atgatgatg'
1094
+ tgt = '- M M '
1095
+ assert_equal(Bio::GFF::GFF3::Record::Gap.new('D1 M2'),
1096
+ g.new_from_sequences_na_aa(ref, tgt))
1097
+
1098
+ ref = 'atgatgatg'
1099
+ tgt = 'M M - '
1100
+ assert_equal(Bio::GFF::GFF3::Record::Gap.new('M2 D1'),
1101
+ g.new_from_sequences_na_aa(ref, tgt))
1102
+ end
1103
+
1104
+ def test_new_from_sequences_na_aa_example
1105
+ gap = Bio::GFF::GFF3::Record::Gap.new('M2 R1 M1 F2 M1')
1106
+ ref1 = 'atgg-taagac-att'
1107
+ tgt1 = 'M V K - I '
1108
+ ref2 = 'atggt<aagacatt'
1109
+ tgt2 = 'M V K >>I '
1110
+ gap1 = Bio::GFF::GFF3::Record::Gap.new_from_sequences_na_aa(ref1, tgt1)
1111
+ assert_equal(gap, gap1)
1112
+ gap2 = Bio::GFF::GFF3::Record::Gap.new_from_sequences_na_aa(ref2, tgt2)
1113
+ assert_equal(gap, gap2)
1114
+ end
1115
+ end #class TestGFF3RecordGap
1116
+
1117
+ class TestGFF3SequenceRegion < Test::Unit::TestCase
1118
+
1119
+ def setup
1120
+ @data =
1121
+ [ Bio::GFF::GFF3::SequenceRegion.new('ABCD1234', 123, 456),
1122
+ Bio::GFF::GFF3::SequenceRegion.new(">X Y=Z;P%,Q\tR", 78, 90),
1123
+ Bio::GFF::GFF3::SequenceRegion.new(nil, nil, nil),
1124
+ ]
1125
+ end
1126
+
1127
+ def test_parse
1128
+ strings =
1129
+ [ '##sequence-region ABCD1234 123 456',
1130
+ '##sequence-region %3EX%20Y%3DZ%3BP%25%2CQ%09R 78 90',
1131
+ '##sequence-region'
1132
+ ]
1133
+ @data.each do |reg|
1134
+ str = strings.shift
1135
+ assert_equal(reg, Bio::GFF::GFF3::SequenceRegion.parse(str))
1136
+ end
1137
+ end
1138
+
1139
+ def test_seqid
1140
+ assert_equal('ABCD1234', @data[0].seqid)
1141
+ assert_equal(">X Y=Z;P%,Q\tR", @data[1].seqid)
1142
+ assert_equal(nil, @data[2].seqid)
1143
+ end
1144
+
1145
+ def test_start
1146
+ assert_equal(123, @data[0].start)
1147
+ assert_equal(78, @data[1].start)
1148
+ assert_nil(@data[2].start)
1149
+ end
1150
+
1151
+ def test_end
1152
+ assert_equal(456, @data[0].end)
1153
+ assert_equal(90, @data[1].end)
1154
+ assert_nil(@data[2].end)
1155
+ end
1156
+
1157
+ def test_to_s
1158
+ assert_equal("##sequence-region ABCD1234 123 456\n", @data[0].to_s)
1159
+ assert_equal("##sequence-region %3EX%20Y%3DZ%3BP%25%2CQ%09R 78 90\n",
1160
+ @data[1].to_s)
1161
+ assert_equal("##sequence-region . . .\n", @data[2].to_s)
1162
+ end
1163
+
1164
+ end #class TestGFF3SequenceRegion
1165
+
1166
+ class TestGFF3MetaData < Test::Unit::TestCase
1167
+
1168
+ def setup
1169
+ @data =
1170
+ Bio::GFF::GFF3::MetaData.new('feature-ontology',
1171
+ 'http://song.cvs.sourceforge.net/*checkout*/song/ontology/sofa.obo?revision=1.12')
1172
+ end
1173
+
1174
+ def test_parse
1175
+ assert_equal(@data,
1176
+ Bio::GFF::GFF3::MetaData.parse('##feature-ontology http://song.cvs.sourceforge.net/*checkout*/song/ontology/sofa.obo?revision=1.12'))
1177
+ end
1178
+
1179
+ def test_directive
1180
+ assert_equal('feature-ontology', @data.directive)
1181
+ end
1182
+
1183
+ def test_data
1184
+ assert_equal('http://song.cvs.sourceforge.net/*checkout*/song/ontology/sofa.obo?revision=1.12', @data.data)
1185
+ end
1186
+ end #class TestGFF3MetaData
1187
+
1188
+ end #module Bio
1189
+
1190
+