def test_summary(self): stat_handler = _FamilySizeStatHandler(self.mock_logger) stat_handler.min = 1 stat_handler.quartile_1 = 2 stat_handler.median = 4 stat_handler.mean = 6.2 stat_handler.quartile_3 = 8 stat_handler.max = 16 self.assertEqual((1, 2, 4, 6.2, 8, 16), stat_handler.summary)
def test_end_median_odd(self): posAfam1 = MicroMock(align_pairs=[1, 1]) posAfam2 = MicroMock(align_pairs=[1, 1, 1]) posBfam1 = MicroMock(align_pairs=[1, 1, 1, 1, 1]) families = [posAfam1, posAfam2, posBfam1] stat_handler = _FamilySizeStatHandler(self.mock_logger) for family in families: stat_handler.handle(family) stat_handler.end() self.assertEqual(3, stat_handler.median)
def test_end_mean(self): posAfam1 = MicroMock(align_pairs=[1] * 1) posAfam2 = MicroMock(align_pairs=[1] * 2) posBfam1 = MicroMock(align_pairs=[1] * 4) posBfam2 = MicroMock(align_pairs=[1] * 8) posBfam3 = MicroMock(align_pairs=[1] * 16) families = [posAfam1, posAfam2, posBfam1, posBfam2, posBfam3] stat_handler = _FamilySizeStatHandler(self.mock_logger) for family in families: stat_handler.handle(family) stat_handler.end() self.assertEqual(6.2, stat_handler.mean)
def test_end_quantiles_even(self): posAfam1 = MicroMock(align_pairs=[1] * 2) posAfam2 = MicroMock(align_pairs=[1] * 3) posBfam1 = MicroMock(align_pairs=[1] * 9) posBfam2 = MicroMock(align_pairs=[1] * 12) families = [posAfam1, posAfam2, posBfam1, posBfam2] stat_handler = _FamilySizeStatHandler(self.mock_logger) for family in families: stat_handler.handle(family) stat_handler.end() self.assertEqual(2.75, stat_handler.quartile_1) self.assertEqual(9.75, stat_handler.quartile_3)