]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/test/maasha/test_seq.rb
added ambiguity to hamming_distance
[biopieces.git] / code_ruby / test / maasha / test_seq.rb
index 0c847205cb6bbd06ec7df4cbb6602a654cd22cf0..bbb6759277359c0254275cc92101bd00c113abe6 100755 (executable)
@@ -298,13 +298,26 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("UAGCuagc", @entry.complement!.seq)
   end
 
-
-  test "#hamming distance returns correctly" do
+  test "#hamming_distance returns correctly" do
     seq1 = Seq.new("test1", "ATCG")
     seq2 = Seq.new("test2", "atgg")
     assert_equal(1, seq1.hamming_distance(seq2))
   end
 
+  test "#hamming_distance with ambiguity codes return correctly" do
+    seq1 = Seq.new("test1", "ATCG")
+    seq2 = Seq.new("test2", "atng")
+
+    assert_equal(1, seq1.hamming_distance(seq2))
+    assert_equal(0, seq1.hamming_distance(seq2, ambiguity: true))
+  end
+
+  test "#edit_distance returns correctly" do
+    seq1 = Seq.new("test1", "ATCG")
+    seq2 = Seq.new("test2", "tgncg")
+    assert_equal(2, seq1.edit_distance(seq2))
+  end
+
   test "#generate with length < 1 raises" do
     assert_raise(SeqError) { @entry.generate(-10, :dna) }
     assert_raise(SeqError) { @entry.generate(0, :dna) }
@@ -546,26 +559,6 @@ class TestSeq < Test::Unit::TestCase
     assert_equal(0, @entry.composition["X"])
   end
 
-  test "#homopol_max returns 0 with empty sequence" do
-    @entry.seq = ""
-    assert_equal(0, @entry.homopol_max)
-  end
-
-  test "#homopol_max returns 0 with nil sequence" do
-    @entry.seq = nil
-    assert_equal(0, @entry.homopol_max)
-  end
-
-  test "#homopol_max returns 0 when not found" do
-    @entry.seq = "AtTcCcGggGnnNnn"
-    assert_equal(0, @entry.homopol_max(6))
-  end
-
-  test "#homopol_max returns correctly" do
-    @entry.seq = "AtTcCcGggGnnNnn"
-    assert_equal(5, @entry.homopol_max(3))
-  end
-
   test "#hard_mask returns correctly" do
     @entry.seq = "--AAAANn"
     assert_equal(33.33, @entry.hard_mask)