def test_build_gap_rightmost(self): gap_utility = GapUtility(original_read_len=50, delimiter="|", logger=MockLogger()) gap_utility._read_group_sample_dict = {'1':'sampleName'} sam_line = "read-name-L-42|131|transcript42|150|score|cigar|=|80|-50|ACGCT|CCCFF|RG:Z:1" gap = gap_utility.build_gap(sam_line) self.assertEqual("transcript42", gap.chromosome) self.assertEqual(80, gap._read_start) self.assertEqual(125, gap.gap_start) self.assertEqual(150, gap._gap_end) self.assertEqual(155, gap._read_end) self.assertEqual("read-name-L-42", gap._split_read_name)
def test_write_sam_file(self): gap_utility = GapUtility(original_read_len=10, delimiter="|", logger=MockLogger()) gap_utility._read_group_sample_dict = {'1':'sampleName'} read1_leftmost = "read1-L-1|67|transcript42|150|score|cigar|=|200|50|ACGCT|qual|RG:Z:1" read1_rightmost = "read1-L-1|131|transcript42|200|score|cigar|=|150|-50|GCAGG|qual|RG:Z:1" read2_leftmost = "read2-L-1|147|transcript43|155|score|cigar|=|205|50|ACGCT|qual|RG:Z:1" read2_rightmost = "read2-L-1|115|transcript43|205|score|cigar|=|155|-50|GCAGG|qual|RG:Z:1" input_sam_file = \ [line +"\n" for line in ["@header1", "@header2", read1_leftmost, read1_rightmost, read2_leftmost, read2_rightmost ] ] read1_gap = gap_utility.build_gap(read1_leftmost) read1_gap.cluster = 5 read2_gap = gap_utility.build_gap(read2_leftmost) read2_gap.cluster = 10 gaps = [read1_gap, read2_gap] writer = MockWriter() additional_header_lines=["hoopy", "frood"] gap_utility.write_sam_file(input_sam_file, gaps, writer, additional_header_lines) actual_lines = writer.lines() self.assertEqual(["@CO\thoopy", "@CO\tfrood"], actual_lines[0:2]) self.assertEqual(["@header1", "@header2"], actual_lines[2:4]) self.assertEqual([read1_leftmost + "|XC:i:5|XR:Z:read1", read1_rightmost + "|XC:i:5|XR:Z:read1"], actual_lines[4:6]) self.assertEqual([read2_leftmost + "|XC:i:10|XR:Z:read2", read2_rightmost + "|XC:i:10|XR:Z:read2"], actual_lines[6:8])