]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/test/maasha/seq/test_assemble.rb
fixed bug in assemble_pairs
[biopieces.git] / code_ruby / test / maasha / seq / test_assemble.rb
index bd1baf0649390f0a2cbabc382af0d9cce9b551a8..93174085f4509767ccb50c047510a73f7f981108 100755 (executable)
@@ -18,6 +18,38 @@ class TestAssemble < Test::Unit::TestCase
     assert_equal("ATCG",    Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "atcg")).seq)
   end
 
+  test "Assemble.pair with first sequence longer than second and terminal overlap returns correctly" do
+    e1 = Seq.new(seq_name: "t1", seq: "AGGCGT")
+    e2 = Seq.new(seq_name: "t2", seq: "GT")
+    a = Assemble.pair(e1, e2)
+    assert_equal("t1:overlap=2:hamming=0", a.seq_name)
+    assert_equal("aggcGT", a.seq)
+  end
+
+  test "Assemble.pair with first sequence longer than second and internal overlap returns correctly" do
+    e1 = Seq.new(seq_name: "t1", seq: "AGGCGT")
+    e2 = Seq.new(seq_name: "t2", seq: "GC")
+    a = Assemble.pair(e1, e2)
+    assert_equal("t1:overlap=2:hamming=0", a.seq_name)
+    assert_equal("agGCgt", a.seq)
+  end
+
+  test "Assemble.pair with first sequence longer than second and initial overlap returns correctly" do
+    e1 = Seq.new(seq_name: "t1", seq: "GTCAGA")
+    e2 = Seq.new(seq_name: "t2", seq: "GT")
+    a = Assemble.pair(e1, e2)
+    assert_equal("t1:overlap=2:hamming=0", a.seq_name)
+    assert_equal("GTcaga", a.seq)
+  end
+
+  test "Assemble.pair with first sequence shorter than second and initial overlap returns correctly" do
+    e1 = Seq.new(seq_name: "t1", seq: "AG")
+    e2 = Seq.new(seq_name: "t2", seq: "AGTCAG")
+    a = Assemble.pair(e1, e2)
+    assert_equal("t1:overlap=2:hamming=0", a.seq_name)
+    assert_equal("AGtcag", a.seq)
+  end
+
   test "Assemble.pair with overlap and overlap_min returns correctly" do
     assert_nil(Assemble.pair(Seq.new(seq: "atcg"), Seq.new(seq: "gatc"), :overlap_min => 2))
     assert_equal("atCGat", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "cgat"), :overlap_min => 2).seq)
@@ -25,7 +57,7 @@ class TestAssemble < Test::Unit::TestCase
 
   test "Assemble.pair with overlap and overlap_max returns correctly" do
     assert_equal("aTCGa", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "tcga"), :overlap_max => 3).seq)
-    assert_nil(Assemble.pair(Seq.new(seq: "atcg"), Seq.new(seq: "atcg"), :overlap_max => 3))
+    assert_nil(Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "atcg"), :overlap_max => 3))
   end
 
   test "Assemble.pair with overlap returns correct quality" do