]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/test/maasha/test_seq.rb
revamped find_homopolymers
[biopieces.git] / code_ruby / test / maasha / test_seq.rb
index eab90cb758f1a95a4d1f71a968f5681f63728da7..8eed8d5733077915f51c1405537c04170bf028b7 100755 (executable)
@@ -333,6 +333,22 @@ class TestSeq < Test::Unit::TestCase
     assert_not_equal(@entry.seq, @entry.shuffle!.seq)
   end
 
+  test "#+ without qual returns correctly" do
+    entry = Seq.new("test1", "at") + Seq.new("test2", "cg")
+    assert_nil(entry.seq_name)
+    assert_equal("atcg", entry.seq)
+    assert_nil(entry.type)
+    assert_nil(entry.qual)
+  end
+
+  test "#+ with qual returns correctly" do
+    entry = Seq.new("test1", "at", :dna, "II") + Seq.new("test2", "cg", :dna, "JJ")
+    assert_nil(entry.seq_name)
+    assert_equal("atcg", entry.seq)
+    assert_equal(:dna,   entry.type)
+    assert_equal("IIJJ", entry.qual)
+  end
+
   test "#<< with different types raises" do
     @entry.seq = "atcg"
     assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna) }
@@ -373,6 +389,50 @@ class TestSeq < Test::Unit::TestCase
     assert_equal("HHHHIIII", @entry.qual)
   end
 
+  test "#[] with qual returns correctly" do
+    entry = Seq.new("test", "atcg", :dna, "FGHI")
+
+    e = entry[2]
+
+    assert_equal("test", e.seq_name)
+    assert_equal("c",    e.seq)
+    assert_equal(:dna,   e.type)
+    assert_equal("H",    e.qual)
+    assert_equal("atcg", entry.seq)
+    assert_equal("FGHI", entry.qual)
+  end
+
+  test "#[] without qual returns correctly" do
+    entry = Seq.new("test", "atcg")
+
+    e = entry[2]
+
+    assert_equal("test", e.seq_name)
+    assert_equal("c",    e.seq)
+    assert_nil(e.qual)
+    assert_equal("atcg", entry.seq)
+  end
+
+  test "[]= with qual returns correctly" do
+    entry = Seq.new("test", "atcg", :dna, "FGHI")
+
+    entry[0] = Seq.new("foo", "T", :dna, "I")
+
+    assert_equal("test", entry.seq_name)
+    assert_equal("Ttcg", entry.seq)
+    assert_equal(:dna,   entry.type)
+    assert_equal("IGHI", entry.qual)
+  end
+
+  test "[]= without qual returns correctly" do
+    entry = Seq.new("test", "atcg")
+
+    entry[0] = Seq.new("foo", "T")
+
+    assert_equal("test", entry.seq_name)
+    assert_equal("Ttcg", entry.seq)
+  end
+
   test "#subseq with start < 0 raises" do
     @entry.seq = "ATCG"
     assert_raise(SeqError) { @entry.subseq(-1, 1) }
@@ -486,26 +546,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)