def test_is_positive(self): mock_alignment_file = MockAlignmentFile({1: "chr1"}) read = util.Read(MockAlignedSegment(is_reverse=False), mock_alignment_file) self.assertEquals(True, read.is_positive_strand) read = util.Read(MockAlignedSegment(is_reverse=True), mock_alignment_file) self.assertEquals(False, read.is_positive_strand)
def test_set_tag(self): mock_alignment_file = MockAlignmentFile({2: "chr2"}) mock_aligned_segment = MockAlignedSegment() read = util.Read(mock_aligned_segment, mock_alignment_file) read.set_tag("name", "value", "type") self.assertEquals("name:type:value", mock_aligned_segment._tags["name"])
def test_isPaired(self): mock_alignment_file = MockAlignmentFile({1: "chr1"}) mock_aligned_segment = MockAlignedSegment(query_name="read1", reference_id=1, reference_start=100, cigarstring="10M", is_paired=True, mate_is_unmapped=True, mate_is_reverse=True, is_proper_pair=True, is_read1=True, next_reference_id=1, next_reference_start=200) read = util.Read(mock_aligned_segment, mock_alignment_file) read.is_paired = False self.assertEquals(False, mock_aligned_segment.__dict__['is_paired']) self.assertEquals(False, mock_aligned_segment.__dict__['mate_is_unmapped']) self.assertEquals(False, mock_aligned_segment.__dict__['is_proper_pair']) self.assertEquals(False, mock_aligned_segment.__dict__['is_read1']) self.assertEquals(-1, mock_aligned_segment.__dict__['next_reference_id']) self.assertEquals( 0, mock_aligned_segment.__dict__['next_reference_start'])
def test_mate_key_noneWhenNoMate(self): mock_alignment_file = MockAlignmentFile({2: "chr2"}) #pylint: disable=attribute-defined-outside-init mock_aligned_segment = MockAlignedSegment(query_name="read1", is_paired=True, mate_is_unmapped=False, mate_is_reverse=True, next_reference_id=2, next_reference_start=200) mock_aligned_segment.is_paired = False read = util.Read(mock_aligned_segment, mock_alignment_file) self.assertEquals(None, read.mate_key) mock_aligned_segment.is_paired = True mock_aligned_segment.mate_is_unmapped = True read = util.Read(mock_aligned_segment, mock_alignment_file) self.assertEquals(None, read.mate_key)
def test_key(self): mock_alignment_file = MockAlignmentFile({1: "chr1"}) mock_aligned_segment = MockAlignedSegment(query_name="readA", reference_id=1, reference_start=100, is_reverse=False, is_read1=True) read = util.Read(mock_aligned_segment, mock_alignment_file) expected_key = ("readA", True, "chr1", 100, True) self.assertEquals(expected_key, read.key)
def test_mate_key(self): mock_alignment_file = MockAlignmentFile({2: "chr2"}) mock_aligned_segment = MockAlignedSegment(query_name="readA", is_paired=True, mate_is_unmapped=False, mate_is_reverse=True, next_reference_id=2, next_reference_start=200, is_read1=True) read = util.Read(mock_aligned_segment, mock_alignment_file) expected_key = ("readA", False, "chr2", 200, False) self.assertEquals(expected_key, read.mate_key)
def test_init(self): mock_alignment_file = MockAlignmentFile({1: "chr1"}) mock_aligned_segment = MockAlignedSegment(query_name="readA", reference_id=1, reference_start=100, reference_end=110, cigarstring="10M", is_paired=True) read = util.Read(mock_aligned_segment, mock_alignment_file) self.assertEquals("readA", read.query_name) self.assertEquals("chr1", read.reference_name) self.assertEquals(100, read.reference_start) self.assertEquals(110, read.reference_end) self.assertEquals("10M", read.cigarstring) self.assertEquals(True, read.is_paired)
def test_mutatorsPassThroughToAlignedSegment(self): mock_alignment_file = MockAlignmentFile({1: "chr1"}) mock_aligned_segment = MockAlignedSegment(query_name="read1", reference_id=1, reference_start=100, cigarstring="10M", next_reference_start=150) read = util.Read(mock_aligned_segment, mock_alignment_file) read.reference_start = 142 read.cigarstring = "10S" read.next_reference_start = 200 self.assertEquals(142, mock_aligned_segment.__dict__['reference_start']) self.assertEquals("10S", mock_aligned_segment.__dict__['cigarstring']) self.assertEquals( 200, mock_aligned_segment.__dict__['next_reference_start'])