test/unit/bio/appl/blast/test_report.rb in bio-1.4.3.0001 vs test/unit/bio/appl/blast/test_report.rb in bio-1.5.0

- old
+ new

@@ -60,11 +60,11 @@ Bio::Blast::Report.new(text) end end end #module TestBlastReportHelper - class TestBlastReport < Test::Unit::TestCase + module TemplateTestBlastReport include TestBlastReportHelper def setup @report = create_report_object end @@ -88,13 +88,11 @@ def test_version assert_equal('blastp 2.2.10 [Oct-19-2004]', @report.version) end def test_reference - xml_quoted_str = "~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~&quot;Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs&quot;, Nucleic Acids Res. 25:3389-3402." 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.' -# assert_equal(xml_quoted_str, @report.reference) assert_equal(text_str, @report.reference) end def test_db assert_equal('b0002.faa', @report.db) @@ -201,13 +199,14 @@ end def test_message assert_equal(nil, @report.message) end - end - - class TestBlastReportIteration < Test::Unit::TestCase + end #module TemplateTestBlastReport + + + module TemplateTestBlastReportIteration include TestBlastReportHelper def setup report = create_report_object @itr = report.iterations.first @@ -229,13 +228,14 @@ end def test_message assert_equal(nil, @itr.message) end - end + end #module TemplateTestBlastReportIteration - class TestBlastReportHit < Test::Unit::TestCase + + module TemplateTestBlastReportHit include TestBlastReportHelper def setup report = create_report_object @hit = report.hits.first @@ -341,13 +341,14 @@ end def test_Hit_lap_at assert_equal([1, 820, 1, 820], @hit.lap_at) end - end + end #module TemplateTestBlastReportHit - class TestBlastReportHsp < Test::Unit::TestCase + + module TemplateTestBlastReportHsp include TestBlastReportHelper def setup report = create_report_object @hsp = report.hits.first.hsps.first @@ -442,41 +443,67 @@ def test_Hsp_mismatch_count assert_nothing_raised { @hsp.mismatch_count } end - end + end #module TestBlastReportHsp - class TestBlastReportREXML < TestBlastReport + class TestBlastReport < Test::Unit::TestCase + include TemplateTestBlastReport end - class TestBlastReportIterationREXML < TestBlastReportIteration + class TestBlastReportIteration < Test::Unit::TestCase + include TemplateTestBlastReportIteration end - class TestBlastReportHitREXML < TestBlastReportHit + class TestBlastReportHit < Test::Unit::TestCase + include TemplateTestBlastReportHit end - class TestBlastReportHspREXML < TestBlastReportHsp + class TestBlastReportHsp < Test::Unit::TestCase + include TemplateTestBlastReportHsp end + class TestBlastReportREXML < Test::Unit::TestCase + include TemplateTestBlastReport + end + + class TestBlastReportIterationREXML < Test::Unit::TestCase + include TemplateTestBlastReportIteration + end + + class TestBlastReportHitREXML < Test::Unit::TestCase + include TemplateTestBlastReportHit + end + + class TestBlastReportHspREXML < Test::Unit::TestCase + include TemplateTestBlastReportHsp + end + if defined? XMLParser then - class TestBlastReportXMLParser < TestBlastReport + class TestBlastReportXMLParser < Test::Unit::TestCase + include TemplateTestBlastReport end - class TestBlastReportIterationXMLParser < TestBlastReportIteration + class TestBlastReportIterationXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportIteration end - class TestBlastReportHitXMLParser < TestBlastReportHit + class TestBlastReportHitXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportHit end - class TestBlastReportHspXMLParser < TestBlastReportHsp + class TestBlastReportHspXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportHsp end end #if defined? XMLParser - class TestBlastReportDefault < TestBlastReport + class TestBlastReportDefault < Test::Unit::TestCase + include TemplateTestBlastReport + undef test_entrez_query undef test_filter undef test_hsp_len undef test_inclusion undef test_parameters @@ -517,17 +544,20 @@ end def test_gapped_entropy assert_equal(0.140, @report.gapped_entropy) end - end + end #class TestBlastReportDefault - class TestBlastReportIterationDefault < TestBlastReportIteration + class TestBlastReportIterationDefault < Test::Unit::TestCase + include TemplateTestBlastReportIteration undef test_statistics end - class TestBlastReportHitDefault < TestBlastReportHit + class TestBlastReportHitDefault < Test::Unit::TestCase + include TemplateTestBlastReportHit + undef test_Hit_accession undef test_Hit_hit_id undef test_Hit_num undef test_Hit_query_def undef test_Hit_query_id @@ -558,13 +588,15 @@ def test_Hit_query_seq # differs from XML because filtered residues are not specified in XML seq = @filtered_query_sequence.gsub(/x/, 'X') assert_equal(seq, @hit.query_seq) end - end + end #class TestBlastReportHitDefault - class TestBlastReportHspDefault < TestBlastReportHsp + class TestBlastReportHspDefault < Test::Unit::TestCase + include TemplateTestBlastReportHsp + undef test_Hsp_density undef test_Hsp_mismatch_count undef test_Hsp_num undef test_Hsp_pattern_from undef test_Hsp_pattern_to @@ -610,12 +642,13 @@ def test_Hsp_query_frame # differs from XML because not available in the default BLASTP format assert_equal(nil, @hsp.query_frame) end - end + end #class TestBlastReportHspDefault + module TestBlastReportTabularHelper def def_test_assert_nil(test_method) str = test_method.to_s name = str.sub(/test(\_(Hit|Hsp))?\_/, '') method = name.intern @@ -632,14 +665,15 @@ define_method(test_method) do assert_nil(instance_variable_get(instance).__send__(method)) end end - end #module + end #module TestBlastReportTabularHelper - class TestBlastReportTabular < TestBlastReport + class TestBlastReportTabular < Test::Unit::TestCase extend TestBlastReportTabularHelper + include TemplateTestBlastReport def_test_assert_nil :test_db def_test_assert_nil :test_db_len def_test_assert_nil :test_db_num def_test_assert_nil :test_eff_space @@ -676,20 +710,22 @@ def test_statistics assert_equal({}, @report.statistics) end end #class TestBlastReportTabular - class TestBlastReportIterationTabular < TestBlastReportIteration + class TestBlastReportIterationTabular < Test::Unit::TestCase + include TemplateTestBlastReportIteration # No statistics information available in the "-m 8" format def test_statistics assert_equal({}, @itr.statistics) end end #class TestBlastReportIterationTabular - class TestBlastReportHitTabular < TestBlastReportHit + class TestBlastReportHitTabular < Test::Unit::TestCase extend TestBlastReportTabularHelper + include TemplateTestBlastReportHit def_test_assert_nil :test_Hit_hit_id def_test_assert_nil :test_Hit_identity def_test_assert_nil :test_Hit_len def_test_assert_nil :test_Hit_midline @@ -712,12 +748,13 @@ # differs from XML because of the limited data assert_equal("eco:b0002", @hit.query_id) end end #class TestBlastReportHitTabular - class TestBlastReportHspTabular < TestBlastReportHsp + class TestBlastReportHspTabular < Test::Unit::TestCase extend TestBlastReportTabularHelper + include TemplateTestBlastReportHsp def_test_assert_nil :test_Hsp_density def_test_assert_nil :test_Hsp_hit_frame def_test_assert_nil :test_Hsp_hseq def_test_assert_nil :test_Hsp_identity @@ -736,11 +773,11 @@ ######################################################################## # Tests for new BLAST XML format (blastall 2.2.14 or later) # with the result of multiple query sequences ######################################################################## - class TestBlastReportMulti < Test::Unit::TestCase + module TemplateTestBlastReportMulti include TestBlastReportHelper def setup @report = create_report_object('blastp-multi') @overall = [ @report ] + @report.reports @@ -953,13 +990,13 @@ def test_message @overall.each do |r| assert_equal(nil, r.message) end end - end - - class TestBlastReportIterationMulti < Test::Unit::TestCase + end #module TemplateTestBlastReportMulti + + module TemplateTestBlastReportIterationMulti include TestBlastReportHelper def setup report = create_report_object('blastp-multi') @itr = report.reports[4].iterations[0] @@ -1003,13 +1040,13 @@ end def test_message assert_equal(nil, @itr.message) end - end + end #module TemplateTestBlastReportIterationMulti - class TestBlastReportHitMulti < Test::Unit::TestCase + module TemplateTestBlastReportHitMulti include TestBlastReportHelper def setup report = create_report_object('blastp-multi') @hit = report.reports[4].iterations[0].hits[1] @@ -1117,13 +1154,13 @@ end def test_Hit_lap_at assert_equal([190, 311, 569, 668], @hit.lap_at) end - end + end #module TemplateTestBlastReportHitMulti - class TestBlastReportHspMulti < Test::Unit::TestCase + module TemplateTestBlastReportHspMulti include TestBlastReportHelper def setup report = create_report_object('blastp-multi') @hsp = report.reports[4].iterations[0].hits[1].hsps[0] @@ -1218,37 +1255,62 @@ def test_Hsp_mismatch_count assert_nothing_raised { @hsp.mismatch_count } end - end + end #module TemplateTestBlastReportHspMulti + + class TestBlastReportMulti < Test::Unit::TestCase + include TemplateTestBlastReportMulti + end + + class TestBlastReportIterationMulti < Test::Unit::TestCase + include TemplateTestBlastReportIterationMulti + end + + class TestBlastReportHitMulti < Test::Unit::TestCase + include TemplateTestBlastReportHitMulti + end + + class TestBlastReportHspMulti < Test::Unit::TestCase + include TemplateTestBlastReportHspMulti + end + # Tests for REXML version - class TestBlastReportMultiREXML < TestBlastReportMulti + class TestBlastReportMultiREXML < Test::Unit::TestCase + include TemplateTestBlastReportMulti end - class TestBlastReportIterationMultiREXML < TestBlastReportIterationMulti + class TestBlastReportIterationMultiREXML < Test::Unit::TestCase + include TemplateTestBlastReportIterationMulti end - class TestBlastReportHitMultiREXML < TestBlastReportHitMulti + class TestBlastReportHitMultiREXML < Test::Unit::TestCase + include TemplateTestBlastReportHitMulti end - class TestBlastReportHspMultiREXML < TestBlastReportHspMulti + class TestBlastReportHspMultiREXML < Test::Unit::TestCase + include TemplateTestBlastReportHspMulti end # Tests for XMLParser version if defined? XMLParser then - class TestBlastReportMultiXMLParser < TestBlastReportMulti + class TestBlastReportMultiXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportMulti end - class TestBlastReportIterationMultiXMLParser < TestBlastReportIterationMulti + class TestBlastReportIterationMultiXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportIterationMulti end - class TestBlastReportHitMultiXMLParser < TestBlastReportHitMulti + class TestBlastReportHitMultiXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportHitMulti end - class TestBlastReportHspMultiXMLParser < TestBlastReportHspMulti + class TestBlastReportHspMultiXMLParser < Test::Unit::TestCase + include TemplateTestBlastReportHspMulti end end #if defined? XMLParser end # module Bio