]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/test/maasha/test_seq.rb
rewrite of FASTQ internals
[biopieces.git] / code_ruby / test / maasha / test_seq.rb
index 8bc6852927235b939414d80a02329b3b5490def7..8ec6f977cc69f75f9c61f36d29359eb1ca7dbc4a 100755 (executable)
@@ -1,22 +1,40 @@
 #!/usr/bin/env ruby
+$:.unshift File.join(File.dirname(__FILE__), '..', '..')
+
+# Copyright (C) 2011 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# This software is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 require 'maasha/seq'
 require 'test/unit'
-require 'pp'
+require 'test/helper'
 
 class TestSeq < Test::Unit::TestCase 
   def setup
     @entry = Seq.new
   end
 
-  #  # autoremoves whitespace, newlines, and carriage returns
-  #  def test_Seq_strip
-  #    dna = Seq.new
-  #    dna.seq = "A\tT\r\tC\nG  "
-  #    assert_equal(dna.seq, "ATCG")
-  #  end
-  
-  def test_Seq_new_bp_returns_correctly
+  test "Seq.new_bp returns correctly" do
     record = {:SEQ_NAME => "test", :SEQ => "ATCG", :SEQ_TYPE => "dna", :SCORES => "hhhh"}
     seq    = Seq.new_bp(record)
     assert_equal("test", seq.seq_name)
@@ -25,223 +43,223 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("hhhh", seq.qual)
   end
 
-  def test_Seq_is_dna_with_no_sequence_type_returns_false
+  test "#is_dna? with no sequence type returns false" do
     assert(@entry.is_dna? == false)
   end
 
-  def test_Seq_is_dna_with_dna_sequence_type_returns_true
+  test "#is_dna? with dna sequence type returns true" do
     @entry.type = 'dna'
     assert(@entry.is_dna? == true)
   end
 
-  def test_Seq_is_rna_with_no_sequence_type_returns_false
+  test "#is_rna? with no sequence type returns false" do
     assert(@entry.is_rna? == false)
   end
 
-  def test_Seq_is_rna_with_rna_sequence_type_returns_true
+  test "#is_rna? with rna sequence type returns true" do
     @entry.type = 'rna'
     assert(@entry.is_rna? == true)
   end
 
-  def test_Seq_is_protein_with_no_sequence_type_returns_false
+  test "#is_protein? with no sequence type returns false" do
     assert(@entry.is_protein? == false)
   end
 
-  def test_Seq_is_protein_with_protein_sequence_type_returns_true
+  test "#is_protein? with protein sequence type returns true" do
     @entry.type = 'protein'
     assert_equal(true, @entry.is_protein?)
   end
 
-  def test_Seq_type_guess_without_sequence_raises
+  test "#type_guess without sequence raises" do
     assert_raise(SeqError) { @entry.type_guess }
   end
 
-  def test_Seq_type_guess_with_protein_returns_protein
+  test "#type_guess with protein returns protein" do
     @entry.seq = 'atcatcrFgatcg'
     assert_equal('protein', @entry.type_guess)
   end
 
-  def test_Seq_type_guess_with_rna_returns_rna
+  test "#type_guess with rna returns rna" do
     @entry.seq = 'atcatcrUgatcg'
     assert_equal('rna', @entry.type_guess)
   end
 
-  def test_Seq_type_guess_with_dna_returns_dna
+  test "#type_guess with dna returns dna" do
     @entry.seq = 'atcatcgatcg'
     assert_equal('dna', @entry.type_guess)
   end
 
-  def test_Seq_type_guess_EM_without_sequence_raises
+  test "#type_guess! without sequence raises" do
     assert_raise(SeqError) { @entry.type_guess! }
   end
 
-  def test_Seq_type_guess_EM_with_protein_returns_protein
+  test "#type_guess! with protein returns protein" do
     @entry.seq = 'atcatcrFgatcg'
     @entry.type_guess!
     assert_equal('protein', @entry.type)
   end
 
-  def test_Seq_type_guess_EM_with_rna_returns_rna
+  test "#type_guess! with rna returns rna" do
     @entry.seq = 'atcatcrUgatcg'
     @entry.type_guess!
     assert_equal('rna', @entry.type)
   end
 
-  def test_Seq_type_guess_EM_with_dna_returns_dna
+  test "#type_guess! with dna returns dna" do
     @entry.seq = 'atcatcgatcg'
     @entry.type_guess!
     assert_equal('dna', @entry.type)
   end
 
-  def test_Seq_length_is_correct
+  test "#length returns corretly" do
     @entry.seq = 'ATCG'
     assert_equal(4, @entry.length)
   end
 
-  def test_Seq_indels_is_correct
+  test "#indels returns correctly" do
     @entry.seq = 'ATCG.-~_'
     assert_equal(4, @entry.indels)
   end
 
-  def test_Seq_to_rna_raises_if_no_sequence
+  test "#to_rna with no sequence raises" do
     @entry.type = 'dna'
     assert_raise(SeqError) { @entry.to_rna }
   end
 
-  def test_Seq_to_rna_raises_on_bad_type
+  test "#to_rna with bad type raises" do
     @entry.seq  = 'ATCG'
     @entry.type = 'rna'
     assert_raise(SeqError) { @entry.to_rna }
   end
 
-  def test_Seq_to_rna_transcribes_correctly
+  test "#to_rna transcribes correctly" do
     @entry.seq  = 'ATCGatcg'
     @entry.type = 'dna'
     assert_equal("AUCGaucg", @entry.to_rna)
   end
 
-  def test_Seq_to_rna_changes_entry_type_to_rna
+  test "#to_rna changes entry type to rna" do
     @entry.seq  = 'ATCGatcg'
     @entry.type = 'dna'
     @entry.to_rna
     assert_equal("rna", @entry.type)
   end
 
-  def test_Seq_to_dna_raises_if_no_sequence
+  test "#to_dna with no sequence raises" do
     @entry.type = 'rna'
     assert_raise(SeqError) { @entry.to_dna }
   end
 
-  def test_Seq_to_dna_raises_on_bad_type
+  test "#to_dna with bad type raises" do
     @entry.seq  = 'AUCG'
     @entry.type = 'dna'
     assert_raise(SeqError) { @entry.to_dna }
   end
 
-  def test_Seq_to_dna_transcribes_correctly
+  test "#to_dna transcribes correctly" do
     @entry.seq  = 'AUCGaucg'
     @entry.type = 'rna'
     assert_equal("ATCGatcg", @entry.to_dna)
   end
 
-  def test_Seq_to_dna_changes_entry_type_to_dna
+  test "#to_dna changes entry type to dna" do
     @entry.seq  = 'AUCGaucg'
     @entry.type = 'rna'
     @entry.to_dna
     assert_equal("dna", @entry.type)
   end
 
-  def test_Seq_to_bp_returns_correct_record
+  test "#to_bp returns correct record" do
     @entry.seq_name = 'test'
     @entry.seq      = 'ATCG'
     assert_equal({:SEQ_NAME=>"test", :SEQ=>"ATCG", :SEQ_LEN=>4}, @entry.to_bp)
   end
 
-  def test_Seq_to_bp_raises_on_missing_seq_name
+  test "#to_bp with missing seq_name raises" do
     @entry.seq = 'ATCG'
     assert_raise(SeqError) { @entry.to_bp }
   end
 
-  def test_Seq_to_bp_raises_on_missing_sequence
+  test "#to_bp with missing sequence raises" do
     @entry.seq_name = 'test'
     assert_raise(SeqError) { @entry.to_bp }
   end
 
-  def test_Seq_to_fasta_raises_on_missing_seq_name
+  test "#to_fasta with missing seq_name raises" do
     @entry.seq = 'ATCG'
     assert_raise(SeqError) { @entry.to_fasta }
   end
 
-  def test_Seq_to_fasta_raises_on_empty_seq_name
+  test "#to_fasta with empty seq_name raises" do
     @entry.seq_name = ''
     @entry.seq      = 'ATCG'
     assert_raise(SeqError) { @entry.to_fasta }
   end
 
-  def test_Seq_to_fasta_raises_on_missing_seq
+  test "#to_fasta with missing seq raises" do
     @entry.seq_name = 'test'
     assert_raise(SeqError) { @entry.to_fasta }
   end
 
-  def test_Seq_to_fasta_raises_on_empty_seq
+  test "#to_fasta with empty seq raises" do
     @entry.seq_name = 'test'
     @entry.seq      = ''
     assert_raise(SeqError) { @entry.to_fasta }
   end
 
-  def test_Seq_to_fasta_returns_correct_entry
+  test "#to_fasta returns correct entry" do
     @entry.seq_name = 'test'
     @entry.seq      = 'ATCG'
     assert_equal(">test\nATCG\n", @entry.to_fasta)
   end
 
-  def test_Seq_to_fasta_wraps_correctly
+  test "#to_fasta wraps correctly" do
     entry = Seq.new("test", "ATCG")
     assert_equal(">test\nAT\nCG\n", entry.to_fasta(2))
   end
 
-  def test_Seq_to_fastq_returns_correct_entry
+  test "#to_fastq returns correct entry" do
     @entry.seq_name = 'test'
     @entry.seq      = 'ATCG'
     @entry.qual     = 'hhhh'
     assert_equal("@test\nATCG\n+\nhhhh\n", @entry.to_fastq)
   end
 
-  def test_Seq_to_key_with_bad_residue_raises
+  test "#to_key with bad residue raises" do
     entry = Seq.new("test", "AUCG")
     assert_raise(SeqError) { entry.to_key }
   end
 
-  def test_Seq_to_key_returns_correctly
+  test "#to_key returns correctly" do
     entry = Seq.new("test", "ATCG")
     assert_equal(54, entry.to_key)
   end
 
-  def test_Seq_reverse_returns_correctly
+  test "#reverse returns correctly" do
     @entry.seq = "ATCG"
     new_entry  = @entry.reverse
     assert_equal("GCTA", new_entry.seq)
     assert_equal("ATCG", @entry.seq)
   end
 
-  def test_Seq_reverse_bang_returns_correctly
+  test "#reverse! returns correctly" do
     @entry.seq = "ATCG"
     @entry.reverse!
     assert_equal("GCTA", @entry.seq)
   end
 
-  def test_Seq_complement_raises_if_no_sequence
+  test "#complement with no sequence raises" do
     @entry.type = 'dna'
     assert_raise(SeqError) { @entry.complement }
   end
 
-  def test_Seq_complement_raises_on_bad_type
+  test "#complement with bad type raises" do
     @entry.seq  = 'ATCG'
     @entry.type = 'protein'
     assert_raise(SeqError) { @entry.complement }
   end
 
-  def test_Seq_complement_for_DNA_is_correct
+  test "#complement for DNA is correct" do
     @entry.seq  = 'ATCGatcg'
     @entry.type = 'dna'
     comp        = @entry.complement
@@ -249,7 +267,7 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("ATCGatcg", @entry.seq)
   end
 
-  def test_Seq_complement_for_RNA_is_correct
+  test "#complement for RNA is correct" do
     @entry.seq  = 'AUCGaucg'
     @entry.type = 'rna'
     comp        = @entry.complement
@@ -257,52 +275,52 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("AUCGaucg", @entry.seq)
   end
 
-  def test_Seq_complement_bang_raises_if_no_sequence
+  test "#complement! with no sequence raises" do
     @entry.type = 'dna'
     assert_raise(SeqError) { @entry.complement! }
   end
 
-  def test_Seq_complement_bang_raises_on_bad_type
+  test "#complement! with bad type raises" do
     @entry.seq  = 'ATCG'
     @entry.type = 'protein'
     assert_raise(SeqError) { @entry.complement! }
   end
 
-  def test_Seq_complement_bang_for_DNA_is_correct
+  test "#complement! for DNA is correct" do
     @entry.seq  = 'ATCGatcg'
     @entry.type = 'dna'
     assert_equal("TAGCtagc", @entry.complement!.seq)
   end
 
-  def test_Seq_complement_bang_for_RNA_is_correct
+  test "#complement! for RNA is correct" do
     @entry.seq  = 'AUCGaucg'
     @entry.type = 'rna'
     assert_equal("UAGCuagc", @entry.complement!.seq)
   end
 
 
-  def test_Seq_hamming_distance_returns_correctly
+  test "#hamming distance returns correctly" do
     seq1 = Seq.new("test1", "ATCG")
     seq2 = Seq.new("test2", "atgg")
     assert_equal(1, seq1.hamming_distance(seq2))
   end
 
-  def test_Seq_generate_with_length_lt_1_raises
+  test "#generate with length < 1 raises" do
     assert_raise(SeqError) { @entry.generate(-10, "dna") }
     assert_raise(SeqError) { @entry.generate(0, "dna") }
   end
 
-  def test_Seq_generate_with_bad_type_raises
+  test "#generate with bad type raises" do
     assert_raise(SeqError) { @entry.generate(10, "foo") }
   end
 
-  def test_Seq_generate_with_ok_type_dont_raise
+  test "#generate with ok type dont raise" do
     %w[dna DNA rna RNA protein Protein].each do |type|
       assert_nothing_raised { @entry.generate(10, type) }
     end
   end
 
-  def test_Seq_shuffle_returns_correctly
+  test "#shuffle returns correctly" do
     orig       = "actgactgactgatcgatcgatcgatcgtactg" 
     @entry.seq = "actgactgactgatcgatcgatcgatcgtactg"
     entry_shuf = @entry.shuffle
@@ -310,58 +328,58 @@ class TestSeq < Test::Unit::TestCase
     assert_not_equal(@entry.seq, entry_shuf.seq)
   end
 
-  def test_Seq_shuffle_bang_returns_correctly
+  test "#shuffle! returns correctly" do
     @entry.seq = "actgactgactgatcgatcgatcgatcgtactg"
     assert_not_equal(@entry.seq, @entry.shuffle!.seq)
   end
 
-  def test_Seq_subseq_with_start_lt_0_raises
+  test "#subseq with start < 0 raises" do
     @entry.seq = "ATCG"
     assert_raise(SeqError) { @entry.subseq(-1, 1) }
   end
 
-  def test_Seq_subseq_with_start_plus_length_gt_seq_raises
+  test "#subseq with start plus length gt seq raises" do
     @entry.seq = "ATCG"
     assert_raise(SeqError) { @entry.subseq(0, 5) }
   end
 
-  def test_Seq_subseq_returns_correct_sequence
+  test "#subseq returns correct sequence" do
     @entry.seq  = "ATCG"
     assert_equal("AT", @entry.subseq(0, 2).seq)
     assert_equal("CG", @entry.subseq(2, 2).seq)
   end
 
-  def test_Seq_subseq_without_len_returns_correct_sequence
+  test "#subseq without length returns correct sequence" do
     @entry.seq  = "ATCG"
     assert_equal("ATCG", @entry.subseq(0).seq)
     assert_equal("CG",   @entry.subseq(2).seq)
   end
 
-  def test_Seq_subseq_returns_correct_qual
+  test "#subseq returns correct qual" do
     @entry.seq  = "ATCG"
     @entry.qual = "abcd"
     assert_equal("ab", @entry.subseq(0, 2).qual)
     assert_equal("cd", @entry.subseq(2, 2).qual)
   end
 
-  def test_Seq_subseq_without_len_returns_correct_qual
+  test "#subseq without length returns correct qual" do
     @entry.seq  = "ATCG"
     @entry.qual = "abcd"
     assert_equal("abcd", @entry.subseq(0).qual)
     assert_equal("cd",   @entry.subseq(2).qual)
   end
 
-  def test_Seq_subseq_bang_with_start_lt_0_raises
+  test "#subseq! with start < 0 raises" do
     @entry.seq = "ATCG"
     assert_raise(SeqError) { @entry.subseq!(-1, 1) }
   end
 
-  def test_Seq_subseq_bang_with_start_plus_length_gt_seq_raises
+  test "#subseq! with start plus length > seq.length raises" do
     @entry.seq = "ATCG"
     assert_raise(SeqError) { @entry.subseq!(0, 5) }
   end
 
-  def test_Seq_subseq_bang_returns_correct_sequence
+  test "#subseq! returns correct sequence" do
     @entry.seq  = "ATCG"
     @entry.subseq!(0, 2)
     assert_equal("AT", @entry.seq)
@@ -370,7 +388,7 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("CG", @entry.seq)
   end
 
-  def test_Seq_subseq_bang_without_len_returns_correct_sequence
+  test "#subseq! without length returns correct sequence" do
     @entry.seq  = "ATCG"
     @entry.subseq!(0)
     assert_equal("ATCG", @entry.seq)
@@ -379,7 +397,7 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("CG", @entry.seq)
   end
 
-  def test_Seq_subseq_bang_with_pos_and_len_returns_correct_qual
+  test "#subseq! with pos and length returns correct qual" do
     @entry.seq  = "ATCG"
     @entry.qual = "abcd"
     @entry.subseq!(0, 2)
@@ -390,7 +408,7 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("cd", @entry.qual)
   end
 
-  def test_Seq_subseq_bang_with_pos_returns_correct_qual
+  test "#subseq! with pos returns correct qual" do
     @entry.seq  = "ATCG"
     @entry.qual = "abcd"
     @entry.subseq!(0)
@@ -401,25 +419,25 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("cd", @entry.qual)
   end
 
-  def test_Seq_subseq_rand_returns_correct_sequence
+  test "#subseq_rand returns correct sequence" do
     @entry.seq  = "ATCG"
     assert_equal("ATCG", @entry.subseq_rand(4).seq)
   end
 
-  def test_Seq_indels_remove_without_qual_returns_correctly
+  test "#indels_remove without qual returns correctly" do
     @entry.seq  = "A-T.CG~CG"
     @entry.qual = nil
     assert_equal("ATCGCG", @entry.indels_remove.seq)
   end
 
-  def test_Seq_indels_remove_with_qual_returns_correctly
+  test "#indels_remove with qual returns correctly" do
     @entry.seq  = "A-T.CG~CG"
     @entry.qual = "a@b@cd@fg"
     assert_equal("ATCGCG", @entry.indels_remove.seq)
     assert_equal("abcdfg", @entry.indels_remove.qual)
   end
 
-  def test_Seq_composition_returns_correctly
+  test "#composition returns correctly" do
     @entry.seq = "AAAATTTCCG"
     assert_equal(4, @entry.composition["A"])
     assert_equal(3, @entry.composition["T"])
@@ -428,56 +446,56 @@ class TestSeq < Test::Unit::TestCase
     assert_equal(0, @entry.composition["X"])
   end
 
-  def test_Seq_homopol_max_returns_0_with_empty_sequence
+  test "#homopol_max returns 0 with empty sequence" do
     @entry.seq = ""
     assert_equal(0, @entry.homopol_max)
   end
 
-  def test_Seq_homopol_max_returns_0_with_nil_sequence
+  test "#homopol_max returns 0 with nil sequence" do
     @entry.seq = nil
     assert_equal(0, @entry.homopol_max)
   end
 
-  def test_Seq_homopol_max_returns_0_when_not_found
+  test "#homopol_max returns 0 when not found" do
     @entry.seq = "AtTcCcGggGnnNnn"
     assert_equal(0, @entry.homopol_max(6))
   end
 
-  def test_Seq_homopol_max_returns_correctly
+  test "#homopol_max returns correctly" do
     @entry.seq = "AtTcCcGggGnnNnn"
     assert_equal(5, @entry.homopol_max(3))
   end
 
-  def test_Seq_hard_mask_returns_correctly
+  test "#hard_mask returns correctly" do
     @entry.seq = "--AAAANn"
     assert_equal(33.33, @entry.hard_mask)
   end
 
-  def test_Seq_soft_mask_returns_correctly
+  test "#soft_mask returns correctly" do
     @entry.seq = "--AAAa"
     assert_equal(25.00, @entry.soft_mask)
   end
 
-  def test_Seq_mask_seq_hard_bang_with_nil_seq_raises
+  test "#mask_seq_hard! with nil seq raises" do
     @entry.seq  = nil
     @entry.qual = ""
 
     assert_raise(SeqError) { @entry.mask_seq_hard!(20) }
   end
 
-  def test_Seq_mask_seq_hard_bang_with_nil_qual_raises
+  test "#mask_seq_hard! with nil qual raises" do
     @entry.seq  = ""
     @entry.qual = nil
 
     assert_raise(SeqError) { @entry.mask_seq_hard!(20) }
   end
 
-  def test_Seq_mask_seq_hard_bang_with_bad_cutoff_raises
+  test "#mask_seq_hard! with bad cutoff raises" do
     assert_raise(SeqError) { @entry.mask_seq_hard!(-1) }
     assert_raise(SeqError) { @entry.mask_seq_hard!(41) }
   end
 
-  def test_Seq_mask_seq_hard_bang_with_OK_cutoff_dont_raise
+  test "#mask_seq_hard! with OK cutoff dont raise" do
     @entry.seq  = "ATCG"
     @entry.qual = "RSTU"
 
@@ -485,33 +503,33 @@ class TestSeq < Test::Unit::TestCase
     assert_nothing_raised { @entry.mask_seq_hard!(40) }
   end
 
-  def test_Seq_mask_seq_hard_bang_returns_correctly
+  test "#mask_seq_hard! returns correctly" do
     @entry.seq  = "-ATCG"
-    @entry.qual = "RRSTU"
+    @entry.qual = "33456"
 
     assert_equal("-NNCG", @entry.mask_seq_hard!(20).seq)
   end
 
-  def test_Seq_mask_seq_soft_bang_with_nil_seq_raises
+  test "#mask_seq_soft! with nil seq raises" do
     @entry.seq  = nil
     @entry.qual = ""
 
     assert_raise(SeqError) { @entry.mask_seq_soft!(20) }
   end
 
-  def test_Seq_mask_seq_soft_bang_with_nil_qual_raises
+  test "#mask_seq_soft! with nil qual raises" do
     @entry.seq  = ""
     @entry.qual = nil
 
     assert_raise(SeqError) { @entry.mask_seq_soft!(20) }
   end
 
-  def test_Seq_mask_seq_soft_bang_with_bad_cutoff_raises
+  test "#mask_seq_soft! with bad cutoff raises" do
     assert_raise(SeqError) { @entry.mask_seq_soft!(-1) }
     assert_raise(SeqError) { @entry.mask_seq_soft!(41) }
   end
 
-  def test_Seq_mask_seq_soft_bang_with_OK_cutoff_dont_raise
+  test "#mask_seq_soft! with OK cutoff dont raise" do
     @entry.seq  = "ATCG"
     @entry.qual = "RSTU"
 
@@ -519,16 +537,16 @@ class TestSeq < Test::Unit::TestCase
     assert_nothing_raised { @entry.mask_seq_soft!(40) }
   end
 
-  def test_Seq_mask_seq_soft_bang_returns_correctly
+  test "#mask_seq_soft! returns correctly" do
     @entry.seq  = "-ATCG"
-    @entry.qual = "RRSTU"
+    @entry.qual = "33456"
 
     assert_equal("-atCG", @entry.mask_seq_soft!(20).seq)
   end
 
   # qual score detection
 
-  def test_Seq_qual_base33_returns_correctly
+  test "#qual_base33? returns correctly" do
     # self.qual.match(/[!-:]/)
     @entry.qual = '!"#$%&\'()*+,-./0123456789:'
     assert_equal(true,  @entry.qual_base33? )
@@ -538,7 +556,7 @@ class TestSeq < Test::Unit::TestCase
     assert_equal(false, @entry.qual_base33? )
   end
 
-  def test_Seq_qual_base64_returns_correctly
+  test "#qual_base64? returns correctly" do
     # self.qual.match(/[K-h]/)
     @entry.qual = 'KLMNOPQRSTUVWXYZ[\]^_`abcdefgh'
     assert_equal(true,  @entry.qual_base64? )
@@ -548,177 +566,71 @@ class TestSeq < Test::Unit::TestCase
     assert_equal(false, @entry.qual_base64? )
   end
 
-  def test_Seq_qual_valid_with_nil_qual_raises
-    assert_raise(SeqError) { @entry.qual_valid?("illumina1.8") }
+  test "#qual_valid? with nil qual raises" do
+    assert_raise(SeqError) { @entry.qual_valid?(:base_33) }
+    assert_raise(SeqError) { @entry.qual_valid?(:base_64) }
   end
 
-  def test_Seq_qual_valid_with_bad_encoding_raises
+  test "#qual_valid? with bad encoding raises" do
     @entry.qual = "abc"
     assert_raise(SeqError) { @entry.qual_valid?("foobar") }
   end
 
-  def test_Seq_qual_valid_returns_correctly
-    tests = [["sanger",      0, 93, 33],
-             ["454",         0, 62, 64],
-             ["solexa",     -5, 62, 64],
-             ["illumina13",  0, 62, 64],
-             ["illumina15",  0, 62, 64],
-             ["illumina18",  0, 93, 33]]
-
-    tests.each do |test|
-      @entry.qual = (test[1] + test[-1]).chr + (test[2] + test[-1]).chr
-      assert_equal(true, @entry.qual_valid?(test[0]))
-      @entry.qual = (test[1] + test[-1] - 1).chr
-      assert_equal(false, @entry.qual_valid?(test[0]))
-      @entry.qual = (test[2] + test[-1] + 1).chr
-      assert_equal(false, @entry.qual_valid?(test[0]))
-    end
-  end
-
-  # convert sanger to ...
-
-  def test_Seq_convert_scores_bang_from_sanger_to_sanger_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('sanger', 'sanger').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_sanger_to_solexa_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('abcdefgh', @entry.convert_scores!('sanger', 'solexa').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_sanger_to_illumina13_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('abcdefgh', @entry.convert_scores!('sanger', 'illumina13').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_sanger_to_illumina15_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('abcdefgh', @entry.convert_scores!('sanger', 'illumina15').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_sanger_to_illumina18_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('sanger', 'illumina18').qual)
+  test "#qual_valid? with OK range returns correctly" do
+    @entry.qual = ((Seq::SCORE_MIN + 33).chr .. (Seq::SCORE_MAX + 33).chr).to_a.join
+    assert_equal(true,  @entry.qual_valid?(:base_33))
+    @entry.qual = ((Seq::SCORE_MIN + 64).chr .. (Seq::SCORE_MAX + 64).chr).to_a.join
+    assert_equal(true,  @entry.qual_valid?(:base_64))
   end
 
-  # convert solexa to ...
+  test "#qual_valid? with bad range returns correctly" do
+    @entry.qual = ((Seq::SCORE_MIN + 33 - 1).chr .. (Seq::SCORE_MAX + 33).chr).to_a.join
+    assert_equal(false,  @entry.qual_valid?(:base_33))
+    @entry.qual = ((Seq::SCORE_MIN + 33).chr .. (Seq::SCORE_MAX + 33 + 1).chr).to_a.join
+    assert_equal(false,  @entry.qual_valid?(:base_33))
 
-  def test_Seq_convert_scores_bang_from_solexa_to_sanger_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal(%q[#$%&'()*], @entry.convert_scores!('solexa', 'sanger').qual)
+    @entry.qual = ((Seq::SCORE_MIN + 64 - 1).chr .. (Seq::SCORE_MAX + 64).chr).to_a.join
+    assert_equal(false,  @entry.qual_valid?(:base_64))
+    @entry.qual = ((Seq::SCORE_MIN + 64).chr .. (Seq::SCORE_MAX + 64 + 1).chr).to_a.join
+    assert_equal(false,  @entry.qual_valid?(:base_64))
   end
 
-  def test_Seq_convert_scores_bang_from_solexa_to_solexa_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('solexa', 'solexa').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_solexa_to_illumina13_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('solexa', 'illumina13').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_solexa_to_illumina15_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('solexa', 'illumina15').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_solexa_to_illumina18_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal(%q[#$%&'()*], @entry.convert_scores!('solexa', 'illumina18').qual)
-  end
-
-  # convert illumina13 to ...
-
-  def test_Seq_convert_scores_bang_from_illumina13_to_sanger_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina13', 'sanger').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina13_to_solexa_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina13', 'solexa').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina13_to_illumina13_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina13', 'illumina13').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina13_to_illumina15_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina13', 'illumina15').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina13_to_illumina18_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina13', 'illumina18').qual)
-  end
-
-  # convert illumina15 to ...
-
-  def test_Seq_convert_scores_bang_from_illumina15_to_sanger_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina15', 'sanger').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina15_to_solexa_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina15', 'solexa').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina15_to_illumina13_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina15', 'illumina13').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina15_to_illumina15_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina15', 'illumina15').qual)
-  end
-
-  def test_Seq_convert_scores_bang_from_illumina15_to_illumina18_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal(%q[#$%&'()*], @entry.convert_scores!('illumina15', 'illumina18').qual)
-  end
-
-  # convert illumina18 to ...
+  # convert sanger to ...
 
-  def test_Seq_convert_scores_bang_from_illumina18_to_sanger_returns_OK
+  test "#qual_convert! from base33 to base33 returns OK" do
     @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina18', 'sanger').qual)
+    assert_equal('BCDEFGHI', @entry.qual_convert!(:base_33, :base_33).qual)
   end
 
-  def test_Seq_convert_scores_bang_from_illumina18_to_solexa_returns_OK
+  test "#qual_convert! from base33 to base64 returns OK" do
     @entry.qual = 'BCDEFGHI'
-    assert_equal('abcdefgh', @entry.convert_scores!('illumina18', 'solexa').qual)
+    assert_equal('abcdefgh', @entry.qual_convert!(:base_33, :base_64).qual)
   end
 
-  def test_Seq_convert_scores_bang_from_illumina18_to_illumina13_returns_OK
+  test "#qual_convert! from base64 to base64 returns OK" do
     @entry.qual = 'BCDEFGHI'
-    assert_equal('abcdefgh', @entry.convert_scores!('illumina18', 'illumina13').qual)
+    assert_equal('BCDEFGHI', @entry.qual_convert!(:base_64, :base_64).qual)
   end
 
-  def test_Seq_convert_scores_bang_from_illumina18_to_illumina15_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('abcdefgh', @entry.convert_scores!('illumina18', 'illumina15').qual)
+  test "#qual_convert! from base64 to base33 returns OK" do
+    @entry.qual = 'abcdefgh'
+    assert_equal('BCDEFGHI', @entry.qual_convert!(:base_64, :base_33).qual)
   end
 
-  def test_Seq_convert_scores_bang_from_illumina18_to_illumina18_returns_OK
-    @entry.qual = 'BCDEFGHI'
-    assert_equal('BCDEFGHI', @entry.convert_scores!('illumina18', 'illumina18').qual)
+  test "#qual_coerce! returns correctly" do
+    @entry.qual = ('!' .. '~').to_a.join
+    assert_equal("!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII", @entry.qual_coerce!(:base_33).qual)
+    @entry.qual = ('!' .. '~').to_a.join
+    assert_equal("!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZh\\h^_`abcdefghhhhhhhhhhhhhhhhhhhhhhh", @entry.qual_coerce!(:base_64).qual)
   end
 
-  def test_Seq_scores_mean_without_qual_raises
+  test "#scores_mean without qual raises" do
     @entry.qual = nil
     assert_raise(SeqError) { @entry.scores_mean }
   end
 
-  def test_Seq_scores_mean_returns_correctly
-    @entry.qual = '@@hh'
+  test "#scores_mean returns correctly" do
+    @entry.qual = '!!II'
     assert_equal(20.0, @entry.scores_mean)
   end
 end
-
-__END__