+
+ def test_Sam_to_bp_alignment_descriptor_without_mismatch_or_indel_returns_correctly
+ string = "q_id\t0\ts_id\t1000\t40\t10M\t*\t0\t0\tGTTCCGCTAT\t*\tXT:A:U\tNM:i:0\tX0:i:1\tX1:i:0\tXM:i:0\tXO:i:1\tXG:i:1\tMD:Z:10\n"
+
+ sam = Sam.new(StringIO.new(string))
+
+ sam.each do |s|
+ assert_equal(nil, Sam.to_bp(s)[:ALIGN])
+ end
+ end
+
+ def test_Sam_to_bp_alignment_descriptor_with_mismatches_returns_correctly
+ string = "q_id\t0\ts_id\t1000\t40\t10M\t*\t0\t0\tgTTCCGCTAt\t*\tXT:A:U\tNM:i:2\tX0:i:1\tX1:i:0\tXM:i:0\tXO:i:1\tXG:i:1\tMD:Z:0C8A\n"
+
+ sam = Sam.new(StringIO.new(string))
+
+ sam.each do |s|
+ assert_equal("0:C>g,9:A>t", Sam.to_bp(s)[:ALIGN])
+ end
+ end
+
+ def test_Sam_to_bp_alignment_descriptor_with_insertions_returns_correctly
+ string = "q_id\t0\ts_id\t1000\t40\t1I10M1I\t*\t0\t0\taGTTCCGCTATc\t*\tXT:A:U\tNM:i:2\tX0:i:1\tX1:i:0\tXM:i:0\tXO:i:1\tXG:i:1\tMD:Z:12\n"
+
+ sam = Sam.new(StringIO.new(string))
+
+ sam.each do |s|
+ assert_equal("0:->a,11:->c", Sam.to_bp(s)[:ALIGN])
+ end
+ end
+
+ def test_Sam_to_bp_alignment_descriptor_with_deletions_returns_correctly
+ string = "q_id\t0\ts_id\t1000\t40\t2D10M\t*\t0\t0\tGTTCCGCTAT\t*\tXT:A:U\tNM:i:2\tX0:i:1\tX1:i:0\tXM:i:0\tXO:i:1\tXG:i:1\tMD:Z:^AC10\n"
+
+ sam = Sam.new(StringIO.new(string))
+
+ sam.each do |s|
+ assert_equal("0:A>-,1:C>-", Sam.to_bp(s)[:ALIGN])
+ end
+ end