def test_dense_coverage(self): reads = [ self.mock_read(range(0, 5)), self.mock_read(range(0, 5)), self.mock_read(range(1, 6)), self.mock_read(range(2, 7)), self.mock_read(range(3, 8)), self.mock_read(range(1, 8)) ] pileup = _read.pileup(reads) expected = list(zip(range(1, 9), [2, 4, 5, 6, 6, 4, 3, 2])) self.assertEqual(expected, pileup)
def test_filter_reads(self): reads = [ self.mock_read(range(0, 5), mapping_quality=0), self.mock_read(range(0, 5), mapping_quality=0), self.mock_read(range(1, 6), mapping_quality=0), self.mock_read(range(2, 7), mapping_quality=0), self.mock_read(range(3, 8), mapping_quality=10), self.mock_read(range(1, 8), mapping_quality=10), ] pileup = _read.pileup(reads, filter_func=lambda x: True if x.mapping_quality < 1 else False) expected = list(zip(range(2, 9), [1, 1, 2, 2, 2, 2, 2])) assert pileup == expected
def test_sparse_coverage(self): reads = [self.mock_read(range(0, 5)), self.mock_read(range(20, 25))] pileup = _read.pileup(reads) expected = [(r, 1) for r in range(1, 6)] + [(r, 1) for r in range(21, 26)] self.assertEqual(expected, pileup)