Пример #1
0
    def test_close_passThroughToBaseWriter(self):
        base_writer = MockAlignWriter()
        writer = samtools.LoggingWriter(base_writer, self.mock_logger)

        writer.close()

        self.assertEqual(True, base_writer._close_was_called)
Пример #2
0
    def test_write_UnplacedAlignWritesFamilyNone(self):
        base_writer = MockAlignWriter()
        writer = samtools.LoggingWriter(base_writer, self.mock_logger)
        fam1 = samtools.LoggingWriter.UNPLACED_FAMILY
        al1A = MicroMock(filter_value = 'foo')

        writer.write(fam1, None, al1A)

        self.assertEqual([(None, al1A)], base_writer._write_calls)
Пример #3
0
    def test_write_passThroughToBaseWriter(self):
        base_writer = MockAlignWriter()
        writer = samtools.LoggingWriter(base_writer, self.mock_logger)
        fam1 = MicroMock(umi_sequence = 1, filter_value=None)
        al1A = MicroMock(filter_value=None)
        al1B = MicroMock(filter_value = 'foo')
        family_aligns = [(fam1, al1A), (fam1, al1B)]

        for family, align in family_aligns:
            writer.write(family, None, align)

        self.assertEqual([(fam1, al1A), (fam1, al1B)],
                         base_writer._write_calls)
Пример #4
0
    def test_close_logsFilterStats(self):
        base_writer = MockAlignWriter()
        writer = samtools.LoggingWriter(base_writer, self.mock_logger)
        fam1 = None
        al1A = MicroMock(filter_value='low mapping qual')
        al1B = MicroMock(filter_value='low mapping qual')
        fam2 = None
        al2A = MicroMock(filter_value='unpaired read')
        al2B = MicroMock(filter_value='unpaired read')
        fam3 = MicroMock(umi_sequence=3, filter_value=None)
        al3A = MicroMock(filter_value='minority CIGAR')
        al3B = MicroMock(filter_value=None)
        fam4 = MicroMock(umi_sequence=4, filter_value=None)
        al4A = MicroMock(filter_value=None)
        al4B = MicroMock(filter_value=None)
        fam5 = MicroMock(umi_sequence=5, filter_value='small family')
        al5A = MicroMock(filter_value=None)
        al5B = MicroMock(filter_value=None)
        family_aligns = [(fam1, al1A), (fam1, al1B),
                         (fam2, al2A), (fam2, al2B),
                         (fam3, al3A), (fam3, al3B),
                         (fam4, al4A), (fam4, al4B),
                         (fam5, al5A), (fam5, al5B)]

        for family, align in family_aligns:
            writer.write(family, None, align)
        writer.close()

        log_lines = self.mock_logger._log_calls['INFO']
        self.assertEqual('70.00% (7/10) alignments unplaced or discarded',
                         log_lines[0])
        self.assertEqual('families discarded: 33.33% (1/3) small family',
                         log_lines[1])
        self.assertEqual('30.00% (3/10) alignments included in 2 families',
                         log_lines[2])
        self.assertEqual('33.33% deduplication rate (1 - 2 families/3 included alignments)',
                         log_lines[3])
        self.assertEqual(4, len(log_lines))

        log_lines = self.mock_logger._log_calls['DEBUG']
        self.assertEqual('alignments unplaced: 20.00% (2/10) low mapping qual',
                         log_lines[0])
        self.assertEqual('alignments unplaced: 20.00% (2/10) unpaired read',
                         log_lines[1])
        self.assertEqual('alignments discarded: 20.00% (2/10) small family',
                         log_lines[2])
        self.assertEqual('alignments discarded: 10.00% (1/10) minority CIGAR',
                         log_lines[3])
        self.assertEqual(4, len(log_lines))
Пример #5
0
    def test_close_whenAllPlaced(self):
        base_writer = MockAlignWriter()
        writer = samtools.LoggingWriter(base_writer, self.mock_logger)
        fam1 = MicroMock(umi_sequence=4, filter_value=None)
        alignA = MicroMock(filter_value=None)
        family_aligns = [(fam1, alignA), (fam1, alignA)]

        for family, align in family_aligns:
            writer.write(family, None, align)
        writer.close()

        log_lines = self.mock_logger._log_calls['INFO']
        self.assertEqual('0.00% (0/2) alignments unplaced or discarded',
                         log_lines[0])
        self.assertEqual('100.00% (2/2) alignments included in 1 families',
                         log_lines[1])
        self.assertEqual('50.00% deduplication rate (1 - 1 families/2 included alignments)',
                         log_lines[2])
        self.assertEqual(3, len(log_lines))

        log_lines = self.mock_logger._log_calls['DEBUG']
        self.assertEqual(0, len(log_lines))