bio 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/ChangeLog +3421 -0
  2. data/KNOWN_ISSUES.rdoc +88 -0
  3. data/README.rdoc +252 -0
  4. data/README_DEV.rdoc +285 -0
  5. data/Rakefile +143 -0
  6. data/bin/bioruby +0 -0
  7. data/bin/br_biofetch.rb +0 -0
  8. data/bin/br_bioflat.rb +12 -1
  9. data/bin/br_biogetseq.rb +0 -0
  10. data/bin/br_pmfetch.rb +4 -3
  11. data/bioruby.gemspec +477 -0
  12. data/bioruby.gemspec.erb +117 -0
  13. data/doc/Changes-0.7.rd +7 -0
  14. data/doc/Changes-1.3.rdoc +239 -0
  15. data/doc/Tutorial.rd +296 -184
  16. data/doc/Tutorial.rd.html +1031 -0
  17. data/doc/Tutorial.rd.ja +111 -45
  18. data/doc/Tutorial.rd.ja.html +2225 -0
  19. data/doc/bioruby.css +281 -0
  20. data/extconf.rb +2 -0
  21. data/lib/bio.rb +29 -4
  22. data/lib/bio/appl/blast.rb +306 -121
  23. data/lib/bio/appl/blast/ddbj.rb +142 -0
  24. data/lib/bio/appl/blast/format0.rb +35 -25
  25. data/lib/bio/appl/blast/format8.rb +2 -2
  26. data/lib/bio/appl/blast/genomenet.rb +263 -0
  27. data/lib/bio/appl/blast/ncbioptions.rb +220 -0
  28. data/lib/bio/appl/blast/remote.rb +106 -0
  29. data/lib/bio/appl/blast/report.rb +260 -9
  30. data/lib/bio/appl/blast/rexml.rb +12 -5
  31. data/lib/bio/appl/blast/rpsblast.rb +277 -0
  32. data/lib/bio/appl/blast/wublast.rb +133 -12
  33. data/lib/bio/appl/blast/xmlparser.rb +35 -18
  34. data/lib/bio/appl/blat/report.rb +46 -5
  35. data/lib/bio/appl/emboss.rb +62 -13
  36. data/lib/bio/appl/fasta.rb +9 -11
  37. data/lib/bio/appl/genscan/report.rb +3 -3
  38. data/lib/bio/appl/hmmer.rb +1 -1
  39. data/lib/bio/appl/hmmer/report.rb +10 -10
  40. data/lib/bio/appl/paml/baseml.rb +95 -0
  41. data/lib/bio/appl/paml/baseml/report.rb +32 -0
  42. data/lib/bio/appl/paml/codeml.rb +242 -0
  43. data/lib/bio/appl/paml/codeml/rates.rb +67 -0
  44. data/lib/bio/appl/paml/codeml/report.rb +67 -0
  45. data/lib/bio/appl/paml/common.rb +348 -0
  46. data/lib/bio/appl/paml/common_report.rb +38 -0
  47. data/lib/bio/appl/paml/yn00.rb +103 -0
  48. data/lib/bio/appl/paml/yn00/report.rb +32 -0
  49. data/lib/bio/appl/psort.rb +2 -2
  50. data/lib/bio/appl/pts1.rb +5 -5
  51. data/lib/bio/appl/tmhmm/report.rb +10 -1
  52. data/lib/bio/command.rb +297 -41
  53. data/lib/bio/compat/features.rb +157 -0
  54. data/lib/bio/compat/references.rb +128 -0
  55. data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
  56. data/lib/bio/db/biosql/sequence.rb +508 -0
  57. data/lib/bio/db/embl/common.rb +28 -12
  58. data/lib/bio/db/embl/embl.rb +107 -9
  59. data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
  60. data/lib/bio/db/embl/format_embl.rb +190 -0
  61. data/lib/bio/db/embl/sptr.rb +15 -16
  62. data/lib/bio/db/fantom.rb +6 -8
  63. data/lib/bio/db/fasta.rb +10 -507
  64. data/lib/bio/db/fasta/defline.rb +532 -0
  65. data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
  66. data/lib/bio/db/fasta/format_fasta.rb +97 -0
  67. data/lib/bio/db/genbank/common.rb +25 -8
  68. data/lib/bio/db/genbank/format_genbank.rb +187 -0
  69. data/lib/bio/db/genbank/genbank.rb +36 -1
  70. data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
  71. data/lib/bio/db/gff.rb +1791 -119
  72. data/lib/bio/db/kegg/glycan.rb +2 -6
  73. data/lib/bio/db/lasergene.rb +3 -3
  74. data/lib/bio/db/medline.rb +4 -1
  75. data/lib/bio/db/newick.rb +10 -10
  76. data/lib/bio/db/pdb/chain.rb +6 -2
  77. data/lib/bio/db/pdb/pdb.rb +12 -3
  78. data/lib/bio/db/rebase.rb +7 -8
  79. data/lib/bio/db/soft.rb +3 -3
  80. data/lib/bio/feature.rb +1 -88
  81. data/lib/bio/io/biosql/biodatabase.rb +64 -0
  82. data/lib/bio/io/biosql/bioentry.rb +29 -0
  83. data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
  84. data/lib/bio/io/biosql/bioentry_path.rb +12 -0
  85. data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
  86. data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
  87. data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
  88. data/lib/bio/io/biosql/biosequence.rb +11 -0
  89. data/lib/bio/io/biosql/comment.rb +7 -0
  90. data/lib/bio/io/biosql/config/database.yml +20 -0
  91. data/lib/bio/io/biosql/dbxref.rb +13 -0
  92. data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
  93. data/lib/bio/io/biosql/location.rb +32 -0
  94. data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
  95. data/lib/bio/io/biosql/ontology.rb +10 -0
  96. data/lib/bio/io/biosql/reference.rb +9 -0
  97. data/lib/bio/io/biosql/seqfeature.rb +32 -0
  98. data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
  99. data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
  100. data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
  101. data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
  102. data/lib/bio/io/biosql/taxon.rb +12 -0
  103. data/lib/bio/io/biosql/taxon_name.rb +9 -0
  104. data/lib/bio/io/biosql/term.rb +27 -0
  105. data/lib/bio/io/biosql/term_dbxref.rb +11 -0
  106. data/lib/bio/io/biosql/term_path.rb +12 -0
  107. data/lib/bio/io/biosql/term_relationship.rb +13 -0
  108. data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
  109. data/lib/bio/io/biosql/term_synonym.rb +10 -0
  110. data/lib/bio/io/das.rb +7 -7
  111. data/lib/bio/io/ddbjxml.rb +57 -0
  112. data/lib/bio/io/ensembl.rb +2 -2
  113. data/lib/bio/io/fetch.rb +28 -14
  114. data/lib/bio/io/flatfile.rb +17 -853
  115. data/lib/bio/io/flatfile/autodetection.rb +545 -0
  116. data/lib/bio/io/flatfile/buffer.rb +237 -0
  117. data/lib/bio/io/flatfile/index.rb +17 -7
  118. data/lib/bio/io/flatfile/indexer.rb +30 -12
  119. data/lib/bio/io/flatfile/splitter.rb +297 -0
  120. data/lib/bio/io/hinv.rb +442 -0
  121. data/lib/bio/io/keggapi.rb +2 -2
  122. data/lib/bio/io/ncbirest.rb +733 -0
  123. data/lib/bio/io/pubmed.rb +34 -80
  124. data/lib/bio/io/registry.rb +2 -2
  125. data/lib/bio/io/sql.rb +178 -357
  126. data/lib/bio/io/togows.rb +458 -0
  127. data/lib/bio/location.rb +106 -11
  128. data/lib/bio/pathway.rb +120 -14
  129. data/lib/bio/reference.rb +115 -101
  130. data/lib/bio/sequence.rb +164 -183
  131. data/lib/bio/sequence/adapter.rb +108 -0
  132. data/lib/bio/sequence/common.rb +22 -45
  133. data/lib/bio/sequence/compat.rb +2 -2
  134. data/lib/bio/sequence/dblink.rb +54 -0
  135. data/lib/bio/sequence/format.rb +254 -77
  136. data/lib/bio/sequence/format_raw.rb +23 -0
  137. data/lib/bio/shell.rb +3 -1
  138. data/lib/bio/shell/core.rb +2 -2
  139. data/lib/bio/shell/plugin/entry.rb +33 -4
  140. data/lib/bio/shell/plugin/ncbirest.rb +64 -0
  141. data/lib/bio/shell/plugin/togows.rb +40 -0
  142. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/bioruby_generator.rb +0 -0
  143. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_classes.rhtml +0 -0
  144. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_log.rhtml +0 -0
  145. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_methods.rhtml +0 -0
  146. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_modules.rhtml +0 -0
  147. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_variables.rhtml +0 -0
  148. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-bg.gif +0 -0
  149. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-gem.png +0 -0
  150. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-link.gif +0 -0
  151. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.css +0 -0
  152. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.rhtml +0 -0
  153. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_controller.rb +0 -0
  154. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_helper.rb +0 -0
  155. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/commands.rhtml +0 -0
  156. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/history.rhtml +0 -0
  157. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/index.rhtml +0 -0
  158. data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/spinner.gif +0 -0
  159. data/lib/bio/tree.rb +4 -2
  160. data/lib/bio/util/color_scheme.rb +2 -2
  161. data/lib/bio/util/contingency_table.rb +2 -2
  162. data/lib/bio/util/restriction_enzyme.rb +2 -2
  163. data/lib/bio/util/restriction_enzyme/single_strand.rb +6 -5
  164. data/lib/bio/version.rb +25 -0
  165. data/rdoc.zsh +8 -0
  166. data/sample/any2fasta.rb +0 -0
  167. data/sample/biofetch.rb +0 -0
  168. data/sample/dbget +0 -0
  169. data/sample/demo_sequence.rb +158 -0
  170. data/sample/enzymes.rb +0 -0
  171. data/sample/fasta2tab.rb +0 -0
  172. data/sample/fastagrep.rb +72 -0
  173. data/sample/fastasort.rb +54 -0
  174. data/sample/fsplit.rb +0 -0
  175. data/sample/gb2fasta.rb +2 -3
  176. data/sample/gb2tab.rb +0 -0
  177. data/sample/gbtab2mysql.rb +0 -0
  178. data/sample/genes2nuc.rb +0 -0
  179. data/sample/genes2pep.rb +0 -0
  180. data/sample/genes2tab.rb +0 -0
  181. data/sample/genome2rb.rb +0 -0
  182. data/sample/genome2tab.rb +0 -0
  183. data/sample/goslim.rb +0 -0
  184. data/sample/gt2fasta.rb +0 -0
  185. data/sample/na2aa.rb +34 -0
  186. data/sample/pmfetch.rb +0 -0
  187. data/sample/pmsearch.rb +0 -0
  188. data/sample/ssearch2tab.rb +0 -0
  189. data/sample/tfastx2tab.rb +0 -0
  190. data/sample/vs-genes.rb +0 -0
  191. data/setup.rb +1596 -0
  192. data/test/data/blast/blastp-multi.m7 +188 -0
  193. data/test/data/command/echoarg2.bat +1 -0
  194. data/test/data/paml/codeml/control_file.txt +30 -0
  195. data/test/data/paml/codeml/output.txt +78 -0
  196. data/test/data/paml/codeml/rates +217 -0
  197. data/test/data/rpsblast/misc.rpsblast +193 -0
  198. data/test/data/soft/GDS100_partial.soft +0 -0
  199. data/test/data/soft/GSE3457_family_partial.soft +0 -0
  200. data/test/functional/bio/appl/test_pts1.rb +115 -0
  201. data/test/functional/bio/io/test_ensembl.rb +123 -80
  202. data/test/functional/bio/io/test_togows.rb +267 -0
  203. data/test/functional/bio/sequence/test_output_embl.rb +51 -0
  204. data/test/functional/bio/test_command.rb +301 -0
  205. data/test/runner.rb +17 -1
  206. data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
  207. data/test/unit/bio/appl/blast/test_report.rb +753 -35
  208. data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
  209. data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
  210. data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
  211. data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
  212. data/test/unit/bio/appl/test_blast.rb +135 -4
  213. data/test/unit/bio/appl/test_fasta.rb +2 -2
  214. data/test/unit/bio/appl/test_pts1.rb +1 -64
  215. data/test/unit/bio/db/embl/test_common.rb +15 -15
  216. data/test/unit/bio/db/embl/test_embl.rb +4 -4
  217. data/test/unit/bio/db/embl/test_embl_rel89.rb +5 -5
  218. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
  219. data/test/unit/bio/db/embl/test_sptr.rb +38 -1
  220. data/test/unit/bio/db/pdb/test_pdb.rb +2 -2
  221. data/test/unit/bio/db/test_gff.rb +1151 -25
  222. data/test/unit/bio/db/test_medline.rb +127 -0
  223. data/test/unit/bio/db/test_nexus.rb +5 -1
  224. data/test/unit/bio/db/test_prosite.rb +4 -4
  225. data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
  226. data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
  227. data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
  228. data/test/unit/bio/io/test_ddbjxml.rb +8 -3
  229. data/test/unit/bio/io/test_fastacmd.rb +5 -5
  230. data/test/unit/bio/io/test_flatfile.rb +357 -106
  231. data/test/unit/bio/io/test_soapwsdl.rb +2 -2
  232. data/test/unit/bio/io/test_togows.rb +161 -0
  233. data/test/unit/bio/sequence/test_common.rb +210 -11
  234. data/test/unit/bio/sequence/test_compat.rb +3 -3
  235. data/test/unit/bio/sequence/test_dblink.rb +58 -0
  236. data/test/unit/bio/sequence/test_na.rb +2 -2
  237. data/test/unit/bio/test_command.rb +111 -50
  238. data/test/unit/bio/test_feature.rb +29 -1
  239. data/test/unit/bio/test_location.rb +566 -6
  240. data/test/unit/bio/test_pathway.rb +91 -65
  241. data/test/unit/bio/test_reference.rb +67 -13
  242. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +3 -3
  243. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +3 -3
  244. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +3 -3
  245. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +4 -3
  246. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +3 -3
  247. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +3 -3
  248. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +3 -3
  249. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +3 -3
  250. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +3 -3
  251. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +3 -3
  252. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +4 -4
  253. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +3 -3
  254. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +3 -3
  255. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +3 -3
  256. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +3 -3
  257. data/test/unit/bio/util/test_restriction_enzyme.rb +3 -3
  258. metadata +202 -167
  259. data/test/unit/bio/appl/blast/test_xmlparser.rb +0 -388
@@ -6,9 +6,25 @@ require 'pathname'
6
6
  bioruby_libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'], 'lib')).cleanpath.to_s
7
7
  $:.unshift(bioruby_libpath) unless $:.include?(bioruby_libpath)
8
8
 
9
- if RUBY_VERSION > "1.8.2"
9
+ if !defined?(Test::Unit::AutoRunner) then
10
+ # Ruby 1.9.1 does not have Test::Unit::AutoRunner
11
+ Test::Unit.setup_argv do |files|
12
+ [ File.dirname($0) ]
13
+ end
14
+ # tests called when exiting the program
15
+
16
+ elsif defined?(Test::Unit::Color) then
17
+ # workaround for test-unit-2.0.x
18
+ r = Test::Unit::AutoRunner.new(true)
19
+ r.to_run.push File.dirname($0)
20
+ r.process_args(ARGV)
21
+ exit r.run
22
+
23
+ elsif RUBY_VERSION > "1.8.2"
24
+ # current Test::Unit -- Ruby 1.8.3 or later
10
25
  exit Test::Unit::AutoRunner.run(true, File.dirname($0))
11
26
  else
27
+ # old Test::Unit -- Ruby 1.8.2 or older
12
28
  exit Test::Unit::AutoRunner.run(false, File.dirname($0))
13
29
  end
14
30
 
@@ -0,0 +1,112 @@
1
+ #
2
+ # = test/unit/bio/appl/blast/test_ncbioptions.rb - Unit test for Bio::Blast::NCBIOptions
3
+ #
4
+ # Copyright:: Copyright (C) 2008 Naohisa Goto <ng@bioruby.org>
5
+ # License:: The Ruby License
6
+ #
7
+ # $Id:$
8
+ #
9
+
10
+ require 'pathname'
11
+ libpath = Pathname.new(File.join(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib'))).cleanpath.to_s
12
+ $:.unshift(libpath) unless $:.include?(libpath)
13
+
14
+ require 'test/unit'
15
+ require 'bio/appl/blast/ncbioptions'
16
+
17
+ module Bio
18
+
19
+ class TestBlastNCBIOptions < Test::Unit::TestCase
20
+
21
+ def setup
22
+ @str = '-p blastn -m0 -m 1 -m2 -m 3 -F T -m 4 m5 -pblastx -m 6 -m 7'
23
+ @options = %w( -p blastn -m0 -m 1 -m2 -m 3 -F T -m 4 m5
24
+ -pblastx -m 6 -m 7 )
25
+ @normalized_options = %w( -F T m5 -p blastx -m 7 )
26
+ @obj = Bio::Blast::NCBIOptions.parse(@str)
27
+ end
28
+
29
+ def test_parse
30
+ str = '-p tblastx -d cdna_human -i est001.fst -o test.blastn -e 0.1'
31
+ options = %w( -p tblastx -d cdna_human -i est001.fst
32
+ -o test.blastn -e 0.1 )
33
+ obj = Bio::Blast::NCBIOptions.parse(str)
34
+ assert_equal(options, obj.options)
35
+ end
36
+
37
+ def test_normalize!
38
+ assert_nothing_raised { @obj.normalize! }
39
+ assert_equal(@normalized_options, @obj.options)
40
+ end
41
+
42
+ def test_get
43
+ assert_equal('blastx', @obj.get('-p'))
44
+ assert_equal('blastx', @obj.get('p'))
45
+
46
+ assert_equal('7', @obj.get('-m'))
47
+ assert_equal('7', @obj.get('m'))
48
+
49
+ assert_equal('T', @obj.get('-F'))
50
+ assert_equal('T', @obj.get('F'))
51
+
52
+ assert_nil(@obj.get('-X'))
53
+ end
54
+
55
+ def test_delete
56
+ assert_equal('blastx', @obj.delete('-p'))
57
+ assert_nil(@obj.delete('p'))
58
+
59
+ assert_equal('7', @obj.delete('-m'))
60
+ assert_nil(@obj.delete('m'))
61
+
62
+ assert_equal('T', @obj.delete('F'))
63
+ assert_nil(@obj.delete('-F'))
64
+
65
+ assert_nil(@obj.delete('-X'))
66
+ end
67
+
68
+ def test_set
69
+ assert_equal('blastx', @obj.set('-p', 'blastp'))
70
+ assert_equal('blastp', @obj.set('p', 'tblastx'))
71
+ assert_equal('tblastx',@obj.get('p'))
72
+
73
+ assert_equal('7', @obj.set('m', '8'))
74
+ assert_equal('8', @obj.set('-m', '0'))
75
+ assert_equal('0', @obj.get('m'))
76
+
77
+ assert_equal('T', @obj.set('-F', 'F'))
78
+ assert_equal('F', @obj.get('F'))
79
+
80
+ assert_nil(@obj.set('-d', 'nr'))
81
+ assert_equal('nr', @obj.get('d'))
82
+
83
+ assert_nil(@obj.set('i', 'test.fst'))
84
+ assert_equal('test.fst', @obj.get('-i'))
85
+ end
86
+
87
+ def test_equal_equal
88
+ obj1 = Bio::Blast::NCBIOptions.parse(@str)
89
+ assert_equal(true, @obj == obj1)
90
+
91
+ obj2 = Bio::Blast::NCBIOptions.parse('-F F')
92
+ assert_equal(false, @obj == obj2)
93
+
94
+ assert_equal(false, @obj == 12345)
95
+ end
96
+
97
+ def test_add_options
98
+ opts = %w( -p tblastx -m 8 -d cdna -i est.fst -o test.blast -e 0.01 )
99
+ result_opts = %w( -F T m5 ) + opts
100
+ assert_nothing_raised { @obj.add_options(opts) }
101
+ assert_equal(result_opts, @obj.options)
102
+ end
103
+
104
+ def test_make_command_line_options
105
+ opts = %w( -p tblastx -d cdna -i est.fst -o test.blast -e 0.01 )
106
+ result_opts = opts + %w( -m 0 -m 1 -m 2 -m 3 -F T -m 4 m5 -m 6 -m 7 )
107
+ assert_equal(result_opts, @obj.make_command_line_options(opts))
108
+ end
109
+
110
+ end #class TestBlastNCBIOptions
111
+
112
+ end #module Bio
@@ -1,10 +1,12 @@
1
1
  #
2
2
  # test/unit/bio/appl/blast/test_report.rb - Unit test for Bio::Blast::Report
3
3
  #
4
- # Copyright:: Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
4
+ # Copyright:: Copyright (C) 2005, 2008
5
+ # Mitsuteru Nakao <n@bioruby.org>,
6
+ # Naohisa Goto <ng@bioruby.org>
5
7
  # License:: The Ruby License
6
8
  #
7
- # $Id: test_report.rb,v 1.5 2007/04/05 23:35:43 trevor Exp $
9
+ # $Id:$
8
10
  #
9
11
 
10
12
  require 'pathname'
@@ -16,32 +18,54 @@ require 'bio/appl/blast/report'
16
18
 
17
19
 
18
20
  module Bio
19
- class TestBlastReportData
21
+
22
+ module TestBlastReportHelper
20
23
  bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s
21
24
  TestDataBlast = Pathname.new(File.join(bioruby_root, 'test', 'data', 'blast')).cleanpath.to_s
22
25
 
23
- def self.input
24
- File.open(File.join(TestDataBlast, 'b0002.faa')).read
26
+ private
27
+
28
+ def get_input_data(basename = 'b0002.faa')
29
+ File.open(File.join(TestDataBlast, basename)).read
25
30
  end
26
31
 
27
- def self.output(format = 7)
28
- case format
29
- when 0
30
- File.open(File.join(TestDataBlast, 'b0002.faa.m0')).read
31
- when 7
32
- File.open(File.join(TestDataBlast, 'b0002.faa.m7')).read
33
- when 8
34
- File.open(File.join(TestDataBlast, 'b0002.faa.m8')).read
32
+ def get_output_data(basename = 'b0002.faa', format = 7)
33
+ fn = basename + ".m#{format.to_i}"
34
+
35
+ # available filenames:
36
+ # 'b0002.faa.m0'
37
+ # 'b0002.faa.m7'
38
+ # 'b0002.faa.m8'
39
+
40
+ File.open(File.join(TestDataBlast, fn)).read
41
+ end
42
+
43
+ def create_report_object(basename = 'b0002.faa')
44
+ case self.class.name.to_s
45
+ when /XMLParser/i
46
+ text = get_output_data(basename, 7)
47
+ Bio::Blast::Report.new(text, :xmlparser)
48
+ when /REXML/i
49
+ text = get_output_data(basename, 7)
50
+ Bio::Blast::Report.new(text, :rexml)
51
+ when /Default/i
52
+ text = get_output_data(basename, 0)
53
+ Bio::Blast::Default::Report.new(text)
54
+ when /Tab/i
55
+ text = get_output_data(basename, 8)
56
+ Bio::Blast::Report.new(text)
57
+ else
58
+ text = get_output_data(basename, 7)
59
+ Bio::Blast::Report.new(text)
35
60
  end
36
61
  end
37
- end
62
+ end #module TestBlastReportHelper
38
63
 
39
-
40
64
  class TestBlastReport < Test::Unit::TestCase
41
- require 'bio/appl/blast/report'
65
+ include TestBlastReportHelper
42
66
 
43
67
  def setup
44
- @report = Bio::Blast::Report.new(Bio::TestBlastReportData.output)
68
+ @report = create_report_object
45
69
  end
46
70
 
47
71
  def test_iterations
@@ -96,15 +120,15 @@ module Bio
96
120
  end
97
121
 
98
122
  def test_inclusion
99
- assert(@report.inclusion)
123
+ assert_nothing_raised { @report.inclusion }
100
124
  end
101
125
 
102
126
  def test_sc_match
103
- assert(@report.sc_match)
127
+ assert_nothing_raised { @report.sc_match }
104
128
  end
105
129
 
106
130
  def test_sc_mismatch
107
- assert(@report.sc_mismatch)
131
+ assert_nothing_raised { @report.sc_mismatch }
108
132
  end
109
133
 
110
134
  def test_gap_open
@@ -123,16 +147,20 @@ module Bio
123
147
  assert_equal(nil, @report.pattern)
124
148
  end
125
149
 
126
- def test_extrez_query
150
+ def test_entrez_query
127
151
  assert_equal(nil, @report.entrez_query)
128
152
  end
129
153
 
130
154
  def test_each_iteration
131
- @report.each_iteration { |itr| }
155
+ assert_nothing_raised {
156
+ @report.each_iteration { |itr| }
157
+ }
132
158
  end
133
159
 
134
160
  def test_each_hit
135
- @report.each_hit { |hit| }
161
+ assert_nothing_raised {
162
+ @report.each_hit { |hit| }
163
+ }
136
164
  end
137
165
 
138
166
  def test_hits
@@ -177,9 +205,10 @@ module Bio
177
205
  end
178
206
 
179
207
  class TestBlastReportIteration < Test::Unit::TestCase
208
+ include TestBlastReportHelper
209
+
180
210
  def setup
181
- data = Bio::TestBlastReportData.output
182
- report = Bio::Blast::Report.new(data)
211
+ report = create_report_object
183
212
  @itr = report.iterations.first
184
213
  end
185
214
 
@@ -204,9 +233,10 @@ module Bio
204
233
  end
205
234
 
206
235
  class TestBlastReportHit < Test::Unit::TestCase
236
+ include TestBlastReportHelper
237
+
207
238
  def setup
208
- data = Bio::TestBlastReportData.output
209
- report = Bio::Blast::Report.new(data)
239
+ report = create_report_object
210
240
  @hit = report.hits.first
211
241
  end
212
242
 
@@ -315,9 +345,10 @@ module Bio
315
345
  end
316
346
 
317
347
  class TestBlastReportHsp < Test::Unit::TestCase
348
+ include TestBlastReportHelper
349
+
318
350
  def setup
319
- data = Bio::TestBlastReportData.output
320
- report = Bio::Blast::Report.new(data)
351
+ report = create_report_object
321
352
  @hsp = report.hits.first.hsps.first
322
353
  end
323
354
 
@@ -325,7 +356,7 @@ module Bio
325
356
  assert_equal(1, @hsp.num)
326
357
  end
327
358
 
328
- def test_Hsp_hit_score
359
+ def test_Hsp_bit_score
329
360
  assert_equal(1567.75, @hsp.bit_score)
330
361
  end
331
362
 
@@ -342,7 +373,7 @@ module Bio
342
373
  end
343
374
 
344
375
  def test_Hsp_gaps
345
- assert(@hsp.gaps)
376
+ assert_nothing_raised { @hsp.gaps }
346
377
  end
347
378
 
348
379
  def test_Hsp_positive
@@ -382,11 +413,11 @@ module Bio
382
413
  end
383
414
 
384
415
  def test_Hsp_pattern_from
385
- @hsp.pattern_from
416
+ assert_nothing_raised { @hsp.pattern_from }
386
417
  end
387
418
 
388
419
  def test_Hsp_pattern_to
389
- @hsp.pattern_to
420
+ assert_nothing_raised { @hsp.pattern_to }
390
421
  end
391
422
 
392
423
  def test_Hsp_qseq
@@ -405,13 +436,700 @@ module Bio
405
436
  end
406
437
 
407
438
  def test_Hsp_percent_identity
408
- @hsp.percent_identity
439
+ assert_nothing_raised { @hsp.percent_identity }
440
+ end
441
+
442
+ def test_Hsp_mismatch_count
443
+ assert_nothing_raised { @hsp.mismatch_count }
444
+ end
445
+
446
+ end
447
+
448
+ class TestBlastReportREXML < TestBlastReport
449
+ end
450
+
451
+ class TestBlastReportIterationREXML < TestBlastReportIteration
452
+ end
453
+
454
+ class TestBlastReportHitREXML < TestBlastReportHit
455
+ end
456
+
457
+ class TestBlastReportHspREXML < TestBlastReportHsp
458
+ end
459
+
460
+ if defined? XMLParser then
461
+
462
+ class TestBlastReportXMLParser < TestBlastReport
463
+ end
464
+
465
+ class TestBlastReportIterationXMLParser < TestBlastReportIteration
466
+ end
467
+
468
+ class TestBlastReportHitXMLParser < TestBlastReportHit
469
+ end
470
+
471
+ class TestBlastReportHspXMLParser < TestBlastReportHsp
472
+ end
473
+
474
+ end #if defined? XMLParser
475
+
476
+ class TestBlastReportDefault < TestBlastReport
477
+ undef test_entrez_query
478
+ undef test_filter
479
+ undef test_hsp_len
480
+ undef test_inclusion
481
+ undef test_parameters
482
+ undef test_query_id
483
+ undef test_statistics
484
+
485
+ def test_program
486
+ assert_equal('BLASTP', @report.program)
487
+ end
488
+
489
+ def test_reference
490
+ text_str = 'Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), "Gapped BLAST and PSI-BLAST: a new generation of protein database search programs", Nucleic Acids Res. 25:3389-3402.'
491
+ assert_equal(text_str, @report.reference)
492
+ end
493
+
494
+ def test_version
495
+ assert_equal('BLASTP 2.2.10 [Oct-19-2004]', @report.version)
496
+ end
497
+
498
+ def test_kappa
499
+ assert_equal(0.134, @report.kappa)
500
+ end
501
+
502
+ def test_lambda
503
+ assert_equal(0.319, @report.lambda)
504
+ end
505
+
506
+ def test_entropy
507
+ assert_equal(0.383, @report.entropy)
508
+ end
509
+
510
+ def test_gapped_kappa
511
+ assert_equal(0.0410, @report.gapped_kappa)
512
+ end
513
+
514
+ def test_gapped_lambda
515
+ assert_equal(0.267, @report.gapped_lambda)
516
+ end
517
+
518
+ def test_gapped_entropy
519
+ assert_equal(0.140, @report.gapped_entropy)
520
+ end
521
+ end
522
+
523
+ class TestBlastReportIterationDefault < TestBlastReportIteration
524
+ undef test_statistics
525
+ end
526
+
527
+ class TestBlastReportHitDefault < TestBlastReportHit
528
+ undef test_Hit_accession
529
+ undef test_Hit_hit_id
530
+ undef test_Hit_num
531
+ undef test_Hit_query_def
532
+ undef test_Hit_query_id
533
+ undef test_Hit_query_len
534
+
535
+ def setup
536
+ @filtered_query_sequence = 'MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQxxxxxxxxxxxxxxALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV'
537
+ super
538
+ end
539
+
540
+ def test_Hit_bit_score
541
+ # differs from XML because of truncation in the default format
542
+ assert_equal(1567.0, @hit.bit_score)
543
+ end
544
+
545
+ def test_Hit_identity
546
+ # differs from XML because filtered residues are not counted in the
547
+ # default format
548
+ assert_equal(806, @hit.identity)
549
+ end
550
+
551
+ def test_Hit_midline
552
+ # differs from XML because filtered residues are not specified in XML
553
+ seq = @filtered_query_sequence.gsub(/x/, ' ')
554
+ assert_equal(seq, @hit.midline)
555
+ end
556
+
557
+ def test_Hit_query_seq
558
+ # differs from XML because filtered residues are not specified in XML
559
+ seq = @filtered_query_sequence.gsub(/x/, 'X')
560
+ assert_equal(seq, @hit.query_seq)
561
+ end
562
+ end
563
+
564
+ class TestBlastReportHspDefault < TestBlastReportHsp
565
+ undef test_Hsp_density
566
+ undef test_Hsp_mismatch_count
567
+ undef test_Hsp_num
568
+ undef test_Hsp_pattern_from
569
+ undef test_Hsp_pattern_to
570
+
571
+ def setup
572
+ @filtered_query_sequence = 'MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDALPNISDAERIFAELLTGLAAAQPGFPLAQLKTFVDQEFAQIKHVLHGISLLGQCPDSINAALICRGEKMSIAIMAGVLEARGHNVTVIDPVEKLLAVGHYLESTVDIAESTRRIAASRIPADHMVLMAGFTAGNEKGELVVLGRNGSDYSAAVLAACLRADCCEIWTDVDGVYTCDPRQVPDARLLKSMSYQEAMELSYFGAKVLHPRTITPIAQFQIPCLIKNTGNPQAPGTLIGASRDEDELPVKGISNLNNMAMFSVSGPGMKGMVGMAARVFAAMSRARISVVLITQSSSEYSISFCVPQSDCVRAERAMQEEFYLELKEGLLEPLAVTERLAIISVVGDGMRTLRGISAKFFAALARANINIVAIAQGSSERSISVVVNNDDATTGVRVTHQMLFNTDQxxxxxxxxxxxxxxALLEQLKRQQSWLKNKHIDLRVCGVANSKALLTNVHGLNLENWQEELAQAKEPFNLGRLIRLVKEYHLLNPVIVDCTSSQAVADQYADFLREGFHVVTPNKKANTSSMDYYHQLRYAAEKSRRKFLYDTNVGAGLPVIENLQNLLNAGDELMKFSGILSGSLSYIFGKLDEGMSFSEATTLAREMGYTEPDPRDDLSGMDVARKLLILARETGRELELADIEIEPVLPAEFNAEGDVAAFMANLSQLDDLFAARVAKARDEGKVLRYVGNIDEDGVCRVKIAEVDGNDPLFKVKNGENALAFYSHYYQPLPLVLRGYGAGNDVTAAGVFADLLRTLSWKLGV'
573
+ super
574
+ end
575
+
576
+ def test_Hsp_identity
577
+ # differs from XML because filtered residues are not counted in the
578
+ # default format
579
+ assert_equal(806, @hsp.identity)
580
+ end
581
+
582
+ def test_Hsp_positive
583
+ # differs from XML because filtered residues are not counted in the
584
+ # default format
585
+ assert_equal(806, @hsp.positive)
586
+ end
587
+
588
+ def test_Hsp_midline
589
+ # differs from XML because filtered residues are not specified in XML
590
+ seq = @filtered_query_sequence.gsub(/x/, ' ')
591
+ assert_equal(seq, @hsp.midline)
592
+ end
593
+
594
+ def test_Hsp_qseq
595
+ # differs from XML because filtered residues are not specified in XML
596
+ seq = @filtered_query_sequence.gsub(/x/, 'X')
597
+ assert_equal(seq, @hsp.qseq)
598
+ end
599
+
600
+ def test_Hsp_bit_score
601
+ # differs from XML because of truncation in the default format
602
+ assert_equal(1567.0, @hsp.bit_score)
603
+ end
604
+
605
+ def test_Hsp_hit_frame
606
+ # differs from XML because not available in the default BLASTP format
607
+ assert_equal(nil, @hsp.hit_frame)
608
+ end
609
+
610
+ def test_Hsp_query_frame
611
+ # differs from XML because not available in the default BLASTP format
612
+ assert_equal(nil, @hsp.query_frame)
613
+ end
614
+ end
615
+
616
+ ########################################################################
617
+ # Tests for new BLAST XML format (blastall 2.2.14 or later)
618
+ # with the result of multiple query sequences
619
+ ########################################################################
620
+
621
+ class TestBlastReportMulti < Test::Unit::TestCase
622
+ include TestBlastReportHelper
623
+
624
+ def setup
625
+ @report = create_report_object('blastp-multi')
626
+ @overall = [ @report ] + @report.reports
627
+ end
628
+
629
+ def test_reports
630
+ assert_equal(5, @report.reports.size)
631
+ end
632
+
633
+ def test_iterations
634
+ assert_equal(1, @report.iterations.size)
635
+ assert_equal([ 1, 1, 1, 1, 1],
636
+ @report.reports.collect { |x| x.iterations.size })
637
+ end
638
+
639
+ def test_parameters
640
+ @overall.each do |r|
641
+ assert_equal('BLOSUM62', r.parameters['matrix'])
642
+ assert_equal(0.001, r.parameters['expect'])
643
+ assert_equal(11, r.parameters['gap-open'])
644
+ assert_equal(1, r.parameters['gap-extend'])
645
+ assert_equal('F', r.parameters['filter'])
646
+ end
647
+ end
648
+
649
+ def test_program
650
+ @overall.each do |r|
651
+ assert_equal('blastp', r.program)
652
+ end
653
+ end
654
+
655
+ def test_version
656
+ @overall.each do |r|
657
+ assert_equal('blastp 2.2.18 [Mar-02-2008]', r.version)
658
+ end
659
+ end
660
+
661
+ def test_reference
662
+ text_str = '~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402.'
663
+
664
+ @overall.each do |r|
665
+ assert_equal(text_str, r.reference)
666
+ end
667
+ end
668
+
669
+ def test_db
670
+ @overall.each do |r|
671
+ assert_equal('BA000007.faa', r.db)
672
+ end
673
+ end
674
+
675
+ def test_query_id
676
+ qids = [ 'lcl|1_0', 'lcl|2_0', 'lcl|3_0', nil, 'lcl|5_0' ]
677
+ assert_equal(qids[0], @report.query_id)
678
+ assert_equal(qids,
679
+ @report.reports.collect { |r| r.query_id })
680
+ end
681
+
682
+ def test_query_def
683
+ qdefs =
684
+ [ 'gi|1790845|gb|AAC77338.1| predicted DNA-binding transcriptional regulator [Escherichia coli str. K-12 substr. MG1655]',
685
+ 'gi|1790846|gb|AAC77339.1| lipoate-protein ligase A [Escherichia coli str. K-12',
686
+ 'gi|1790847|gb|AAC77340.1| conserved protein [Escherichia coli str. K-12 substr. MG1655]',
687
+ nil,
688
+ 'gi|1790849|gb|AAC77341.1| 3-phosphoserine phosphatase [Escherichia coli str. K-12 substr. MG1655]'
689
+ ]
690
+ assert_equal(qdefs[0], @report.query_def)
691
+ assert_equal(qdefs,
692
+ @report.reports.collect { |r| r.query_def })
693
+ end
694
+
695
+ def test_query_len
696
+ qlens = [ 443, 346, 214, nil, 322 ]
697
+ assert_equal(qlens[0], @report.query_len)
698
+ assert_equal(qlens,
699
+ @report.reports.collect { |r| r.query_len })
700
+ end
701
+
702
+ def test_matrix
703
+ @overall.each do |r|
704
+ assert_equal('BLOSUM62', r.matrix)
705
+ end
706
+ end
707
+
708
+ def test_expect
709
+ @overall.each do |r|
710
+ assert_equal(0.001, r.expect)
711
+ end
712
+ end
713
+
714
+ def test_gap_open
715
+ @overall.each do |r|
716
+ assert_equal(11, r.gap_open)
717
+ end
718
+ end
719
+
720
+ def test_gap_extend
721
+ @overall.each do |r|
722
+ assert_equal(1, r.gap_extend)
723
+ end
724
+ end
725
+
726
+ def test_filter
727
+ @overall.each do |r|
728
+ assert_equal('F', r.filter)
729
+ end
730
+ end
731
+
732
+ def test_pattern
733
+ @overall.each do |r|
734
+ assert_equal(nil, r.pattern)
735
+ end
736
+ end
737
+
738
+ def test_each_iteration
739
+ @overall.each do |r|
740
+ count = 0
741
+ assert_nothing_raised {
742
+ r.each_iteration { |itr| count += 1 }
743
+ }
744
+ assert_equal(1, count)
745
+ end
746
+ end
747
+
748
+ def test_each_hit
749
+ @overall.each do |r|
750
+ assert_nothing_raised {
751
+ r.each_hit { |hit| }
752
+ }
753
+ end
754
+ end
755
+
756
+ def test_hits
757
+ hsizes = [ 0, 1, 1, 0, 2 ]
758
+ assert_equal(hsizes[0], @report.hits.size)
759
+ assert_equal(hsizes,
760
+ @report.reports.collect { |r| r.hits.size })
761
+ end
762
+
763
+ def test_statistics
764
+ assert_equal({}, @report.statistics)
765
+
766
+ stat = {
767
+ "kappa" => 0.041, "eff-space" => 0, "db-num" => 5361,
768
+ "hsp-len" => 0, "db-len" => 1609188, "lambda" => 0.267,
769
+ "entropy" => 0.14
770
+ }
771
+ stats = [ {}, stat, stat, {}, stat ]
772
+ @report.reports.each do |r|
773
+ assert_equal(stats.shift, r.statistics)
774
+ end
775
+ end
776
+
777
+ def test_db_num
778
+ assert_equal(nil, @report.db_num)
779
+ ary = [ nil, 5361, 5361, nil, 5361 ]
780
+ @report.reports.each do |r|
781
+ assert_equal(ary.shift, r.db_num)
782
+ end
783
+ end
784
+
785
+ def test_db_len
786
+ assert_equal(nil, @report.db_len)
787
+ ary = [ nil, 1609188, 1609188, nil, 1609188 ]
788
+ @report.reports.each do |r|
789
+ assert_equal(ary.shift, r.db_len)
790
+ end
791
+ end
792
+
793
+ def test_hsp_len
794
+ assert_equal(nil, @report.hsp_len)
795
+ ary = [ nil, 0, 0, nil, 0 ]
796
+ @report.reports.each do |r|
797
+ assert_equal(ary.shift, r.hsp_len)
798
+ end
799
+ end
800
+
801
+ def test_eff_space
802
+ assert_equal(nil, @report.eff_space)
803
+ ary = [ nil, 0, 0, nil, 0 ]
804
+ @report.reports.each do |r|
805
+ assert_equal(ary.shift, r.eff_space)
806
+ end
807
+ end
808
+
809
+ def test_kappa
810
+ assert_equal(nil, @report.kappa)
811
+ ary = [ nil, 0.041, 0.041, nil, 0.041 ]
812
+ @report.reports.each do |r|
813
+ assert_equal(ary.shift, r.kappa)
814
+ end
815
+ end
816
+
817
+ def test_lambda
818
+ assert_equal(nil, @report.lambda)
819
+ ary = [ nil, 0.267, 0.267, nil, 0.267 ]
820
+ @report.reports.each do |r|
821
+ assert_equal(ary.shift, r.lambda)
822
+ end
823
+ end
824
+
825
+ def test_entropy
826
+ assert_equal(nil, @report.entropy)
827
+ ary = [ nil, 0.14, 0.14, nil, 0.14 ]
828
+ @report.reports.each do |r|
829
+ assert_equal(ary.shift, r.entropy)
830
+ end
831
+ end
832
+
833
+ def test_message
834
+ @overall.each do |r|
835
+ assert_equal(nil, r.message)
836
+ end
837
+ end
838
+ end
839
+
840
+ class TestBlastReportIterationMulti < Test::Unit::TestCase
841
+ include TestBlastReportHelper
842
+
843
+ def setup
844
+ report = create_report_object('blastp-multi')
845
+ @itr = report.reports[4].iterations[0]
846
+ end
847
+
848
+ def test_query_id
849
+ assert_equal('lcl|5_0', @itr.query_id)
850
+ end
851
+
852
+ def test_query_def
853
+ assert_equal('gi|1790849|gb|AAC77341.1| 3-phosphoserine phosphatase [Escherichia coli str. K-12 substr. MG1655]', @itr.query_def)
854
+ end
855
+
856
+ def test_query_len
857
+ assert_equal(322, @itr.query_len)
858
+ end
859
+
860
+ def test_hits
861
+ assert_equal(2, @itr.hits.size)
862
+ end
863
+
864
+ def test_each
865
+ count = 0
866
+ assert_nothing_raised {
867
+ @itr.each { |hit| count += 1 }
868
+ }
869
+ assert_equal(2, count)
870
+ end
871
+
872
+ def test_statistics
873
+ stat = {
874
+ "kappa" => 0.041, "eff-space" => 0, "db-num" => 5361,
875
+ "hsp-len" => 0, "db-len" => 1609188, "lambda" => 0.267,
876
+ "entropy" => 0.14
877
+ }
878
+ assert_equal(stat, @itr.statistics)
879
+ end
880
+
881
+ def test_num
882
+ assert_equal(5, @itr.num)
883
+ end
884
+
885
+ def test_message
886
+ assert_equal(nil, @itr.message)
887
+ end
888
+ end
889
+
890
+ class TestBlastReportHitMulti < Test::Unit::TestCase
891
+ include TestBlastReportHelper
892
+
893
+ def setup
894
+ report = create_report_object('blastp-multi')
895
+ @hit = report.reports[4].iterations[0].hits[1]
896
+ end
897
+
898
+ def test_Hit_hsps
899
+ assert_equal(1, @hit.hsps.size)
900
+ end
901
+
902
+ def test_Hit_query_id
903
+ assert_equal('lcl|5_0', @hit.query_id)
904
+ end
905
+
906
+ def test_Hit_query_def
907
+ assert_equal('gi|1790849|gb|AAC77341.1| 3-phosphoserine phosphatase [Escherichia coli str. K-12 substr. MG1655]', @hit.query_def)
908
+ end
909
+
910
+ def test_Hit_query_len
911
+ assert_equal(322, @hit.query_len)
912
+ end
913
+
914
+ def test_Hit_num
915
+ assert_equal(2, @hit.num)
916
+ end
917
+
918
+ def test_Hit_hit_id
919
+ assert_equal('gi|13363792|dbj|BAB37741.1|', @hit.hit_id)
920
+ end
921
+
922
+ def test_Hit_len
923
+ assert_equal(732, @hit.len)
924
+ end
925
+
926
+ def test_Hit_target_len
927
+ assert_equal(732, @hit.target_len)
928
+ end
929
+
930
+ def test_Hit_definition
931
+ assert_equal('zinc-transporting ATPase [Escherichia coli O157:H7 str. Sakai]', @hit.definition)
932
+ end
933
+
934
+ def test_Hit_taeget_def
935
+ assert_equal('zinc-transporting ATPase [Escherichia coli O157:H7 str. Sakai]', @hit.target_def)
936
+ end
937
+
938
+ def test_Hit_accession
939
+ assert_equal('BAB37741', @hit.accession)
940
+ end
941
+
942
+ def test_Hit_target_id
943
+ #assert_equal('gi|13363792|dbj|BAB37741.1|', @hit.target_id)
944
+ assert_equal('BAB37741', @hit.target_id)
945
+ end
946
+
947
+ def test_Hit_evalue
948
+ assert_equal(0.000899657, @hit.evalue)
949
+ end
950
+
951
+ def test_Hit_bit_score
952
+ assert_equal(38.1206, @hit.bit_score)
953
+ end
954
+
955
+ def test_Hit_identity
956
+ assert_equal(39, @hit.identity)
957
+ end
958
+
959
+ def test_Hit_overlap
960
+ # alignment length
961
+ assert_equal(123, @hit.overlap)
962
+ end
963
+
964
+ def test_Hit_query_seq
965
+ seq = 'VLKLETLGWKVAIASGGFTFFAEYLRDKLRLTAVVANELEIMDGKFTGNVIGDIVDAQYKAKTLTRLAQEYEIPLAQTVAIGDGANDLPMIKAAGLGIAYHAKPKVN-EKAEVTIRHADLMGV'
966
+ assert_equal(seq, @hit.query_seq)
967
+ end
968
+
969
+ def test_Hit_target_seq
970
+ seq = 'ISELNALGVKGVILTG----------DNPRAAAAIAGELGL---EFKAGLL-----PEDKVKAVTELNQHA--PLAM---VGDGINDAPAMKAAAIGIAMGSGTDVALETADAALTHNHLRGL'
971
+ assert_equal(seq, @hit.target_seq)
972
+ end
973
+
974
+ def test_Hit_midline
975
+ seq = '+ +L LG K I +G D R A +A EL + +F ++ + K K +T L Q PLA +GDG ND P +KAA +GIA + V E A+ + H L G+'
976
+ assert_equal(seq, @hit.midline)
977
+ end
978
+
979
+ def test_Hit_query_start
980
+ assert_equal(190, @hit.query_start)
981
+ # assert_equal(190, @hit.query_from)
982
+ end
983
+
984
+ def test_Hit_query_end
985
+ assert_equal(311, @hit.query_end)
986
+ # assert_equal(311, @hit.query_to)
987
+ end
988
+
989
+ def test_Hit_target_start
990
+ assert_equal(569, @hit.target_start)
991
+ # assert_equal(569, @hit.hit_from)
992
+ end
993
+
994
+ def test_Hit_target_end
995
+ assert_equal(668, @hit.target_end)
996
+ # assert_equal(668, @hit.hit_to)
997
+ end
998
+
999
+ def test_Hit_lap_at
1000
+ assert_equal([190, 311, 569, 668], @hit.lap_at)
1001
+ end
1002
+ end
1003
+
1004
+ class TestBlastReportHspMulti < Test::Unit::TestCase
1005
+ include TestBlastReportHelper
1006
+
1007
+ def setup
1008
+ report = create_report_object('blastp-multi')
1009
+ @hsp = report.reports[4].iterations[0].hits[1].hsps[0]
1010
+ end
1011
+
1012
+ def test_Hsp_num
1013
+ assert_equal(1, @hsp.num)
1014
+ end
1015
+
1016
+ def test_Hsp_bit_score
1017
+ assert_equal(38.1206, @hsp.bit_score)
1018
+ end
1019
+
1020
+ def test_Hsp_score
1021
+ assert_equal(87, @hsp.score)
1022
+ end
1023
+
1024
+ def test_Hsp_evalue
1025
+ assert_equal(0.000899657, @hsp.evalue)
1026
+ end
1027
+
1028
+ def test_Hsp_identity
1029
+ assert_equal(39, @hsp.identity)
1030
+ end
1031
+
1032
+ def test_Hsp_gaps
1033
+ assert_equal(24, @hsp.gaps)
1034
+ end
1035
+
1036
+ def test_Hsp_positive
1037
+ assert_equal(56, @hsp.positive)
1038
+ end
1039
+
1040
+ def test_Hsp_align_len
1041
+ assert_equal(123, @hsp.align_len)
1042
+ end
1043
+
1044
+ def test_Hsp_density
1045
+ assert_nothing_raised { @hsp.density }
1046
+ end
1047
+
1048
+ def test_Hsp_query_frame
1049
+ assert_equal(1, @hsp.query_frame)
1050
+ end
1051
+
1052
+ def test_Hsp_query_from
1053
+ assert_equal(190, @hsp.query_from)
1054
+ end
1055
+
1056
+ def test_Hsp_query_to
1057
+ assert_equal(311, @hsp.query_to)
1058
+ end
1059
+
1060
+ def test_Hsp_hit_frame
1061
+ assert_equal(1, @hsp.hit_frame)
1062
+ end
1063
+
1064
+ def test_Hsp_hit_from
1065
+ assert_equal(569, @hsp.hit_from)
1066
+ end
1067
+
1068
+ def test_Hsp_hit_to
1069
+ assert_equal(668, @hsp.hit_to)
1070
+ end
1071
+
1072
+ def test_Hsp_pattern_from
1073
+ assert_nothing_raised { @hsp.pattern_from }
1074
+ end
1075
+
1076
+ def test_Hsp_pattern_to
1077
+ assert_nothing_raised { @hsp.pattern_to }
1078
+ end
1079
+
1080
+ def test_Hsp_qseq
1081
+ seq = 'VLKLETLGWKVAIASGGFTFFAEYLRDKLRLTAVVANELEIMDGKFTGNVIGDIVDAQYKAKTLTRLAQEYEIPLAQTVAIGDGANDLPMIKAAGLGIAYHAKPKVN-EKAEVTIRHADLMGV'
1082
+ assert_equal(seq, @hsp.qseq)
1083
+ end
1084
+
1085
+ def test_Hsp_midline
1086
+ seq = '+ +L LG K I +G D R A +A EL + +F ++ + K K +T L Q PLA +GDG ND P +KAA +GIA + V E A+ + H L G+'
1087
+ assert_equal(seq, @hsp.midline)
1088
+ end
1089
+
1090
+ def test_Hsp_hseq
1091
+ seq = 'ISELNALGVKGVILTG----------DNPRAAAAIAGELGL---EFKAGLL-----PEDKVKAVTELNQHA--PLAM---VGDGINDAPAMKAAAIGIAMGSGTDVALETADAALTHNHLRGL'
1092
+ assert_equal(seq, @hsp.hseq)
1093
+ end
1094
+
1095
+ def test_Hsp_percent_identity
1096
+ assert_nothing_raised { @hsp.percent_identity }
409
1097
  end
410
1098
 
411
1099
  def test_Hsp_mismatch_count
412
- @hsp.mismatch_count
1100
+ assert_nothing_raised { @hsp.mismatch_count }
413
1101
  end
414
1102
 
415
1103
  end
416
1104
 
1105
+ # Tests for REXML version
1106
+ class TestBlastReportMultiREXML < TestBlastReportMulti
1107
+ end
1108
+
1109
+ class TestBlastReportIterationMultiREXML < TestBlastReportIterationMulti
1110
+ end
1111
+
1112
+ class TestBlastReportHitMultiREXML < TestBlastReportHitMulti
1113
+ end
1114
+
1115
+ class TestBlastReportHspMultiREXML < TestBlastReportHspMulti
1116
+ end
1117
+
1118
+ # Tests for XMLParser version
1119
+ if defined? XMLParser then
1120
+
1121
+ class TestBlastReportMultiXMLParser < TestBlastReportMulti
1122
+ end
1123
+
1124
+ class TestBlastReportIterationMultiXMLParser < TestBlastReportIterationMulti
1125
+ end
1126
+
1127
+ class TestBlastReportHitMultiXMLParser < TestBlastReportHitMulti
1128
+ end
1129
+
1130
+ class TestBlastReportHspMultiXMLParser < TestBlastReportHspMulti
1131
+ end
1132
+
1133
+ end #if defined? XMLParser
1134
+
417
1135
  end # module Bio