def test_filter_builder_multiple(self): transform = MicroMock(primer_pair=MockPrimerPair(is_unmatched=True), is_unmapped=False, is_cigar_valid=False) self.assertEquals(["UNMATCHED_PRIMER_PAIR", "INVALID_CIGAR"], clipper._filter_builder(transform)) transform = MicroMock(primer_pair=MockPrimerPair(is_unmatched=True), is_unmapped=True, is_cigar_valid=False) self.assertEquals(["UNMAPPED_ALIGNMENT"], clipper._filter_builder(transform))
def test_handle(self): read1 = MockRead(is_positive_strand=True) read2 = MockRead(is_positive_strand=True) primer_pair = MockPrimerPair(target_id="target_1", chrom="chr1", sense_start=242) new_reference_start = 102 new_cigar_string = "2S8M" transformation = MicroMock(primer_pair=primer_pair, reference_start=new_reference_start, cigar=new_cigar_string) mate_transformation = None mock_primer_stats = MockPrimerStats() mock_primer_stats_dumper = MockPrimerStatsDumper() handler = readhandler.StatsHandler(mock_primer_stats, mock_primer_stats_dumper) handler.handle(read1, transformation, mate_transformation) handler.handle(read2, transformation, mate_transformation) expected_calls = [(read1, primer_pair), (read2, primer_pair)] self.assertEquals(expected_calls, mock_primer_stats._add_read_primer_calls) handler.end() self.assertEquals([mock_primer_stats], mock_primer_stats_dumper._dump_calls)
def test_handle_addsFiltersWhenPresent(self): #pylint: disable=no-member read = MockRead(reference_start=100, reference_end=110, cigarstring="10M") primer_pair_target = "target_1" primer_pair = MockPrimerPair(target_id=primer_pair_target) transformation = MicroMock(primer_pair=primer_pair, filters=("filter1", "filter2")) mate_transformation = None handler = readhandler.AddTagsReadHandler() handler.handle(read, transformation, mate_transformation) self.assertEquals("X4:Z:" + "filter1,filter2", read._tags["X4"])
def test_handle(self): #pylint: disable=no-member original_reference_start = 100 original_reference_end = 110 original_cigar_string = "10M" read = MockRead(reference_start=original_reference_start, reference_end=original_reference_end, cigarstring=original_cigar_string) primer_pair_target = "target_1" primer_pair = MockPrimerPair(target_id=primer_pair_target) transformation = MicroMock(primer_pair=primer_pair, filters=()) mate_transformation = None handler = readhandler.AddTagsReadHandler() handler.handle(read, transformation, mate_transformation) self.assertEquals("X0:Z:" + primer_pair_target, read._tags["X0"]) self.assertEquals("X1:Z:" + original_cigar_string, read._tags["X1"]) self.assertEquals("X2:i:" + str(original_reference_start), read._tags["X2"]) self.assertEquals("X3:i:" + str(original_reference_end), read._tags["X3"])
def test_filter_builder_invalidCigar(self): transform = MicroMock(primer_pair=MockPrimerPair(is_unmatched=False), is_unmapped=False, is_cigar_valid=False) self.assertEquals(["INVALID_CIGAR"], clipper._filter_builder(transform))
def test_filter_builder_unmappedAlignment(self): transform = MicroMock(primer_pair=MockPrimerPair(is_unmatched=False), is_unmapped=True, is_cigar_valid=True) self.assertEquals(["UNMAPPED_ALIGNMENT"], clipper._filter_builder(transform))
def test_filter_builder_unmatchedPrimerPair(self): transform = MicroMock(primer_pair=MockPrimerPair(is_unmatched=True), is_unmapped=False, is_cigar_valid=True) self.assertEquals(["UNMATCHED_PRIMER_PAIR"], clipper._filter_builder(transform))
def test_filter_builder_noFilters(self): transform = MicroMock(primer_pair=MockPrimerPair(is_unmatched=False), is_unmapped=False, is_cigar_valid=True) self.assertEquals([], clipper._filter_builder(transform))