def test_probs_for_vars_mut_wts(self): mut_wt, mut_max = 0.10, 0.50 hvb = preprocess.HapVarBaseMatrix(self.ref, self.phy, mut_wt, mut_max) obs_I = zip(range(9), "GAAAAAAAA") self.assertEqual(str(hvb.prob_for_vars('I', obs_I)), str(math.log((0.9**7) * (0.8**2)))) self.assertEqual(str(hvb.prob_for_vars('C', obs_I)), str(math.log((0.9**5) * (0.8**2) * ((0.1 / 3)**2))))
def test_probs_for_vars(self): mut_wt, mut_max = 0.10, 0.10 hvb = preprocess.HapVarBaseMatrix(self.ref, self.phy, mut_wt, mut_max) obs_I = list(zip(list(range(9)), "GAAAAAAAA")) self.assertAlmostEqual(hvb.prob_for_vars('I', obs_I), math.log(0.9 ** 9)) self.assertAlmostEqual(hvb.prob_for_vars('C', obs_I), math.log((0.9 ** 7) * ((0.1 / 3) ** 2))) self.assertAlmostEqual(hvb.prob_for_vars('D', obs_I), math.log((0.9 ** 5) * ((0.1 / 3) ** 4)))
def test_probs(self): mut_wt, mut_max = 0.10, 0.10 hvb = preprocess.HapVarBaseMatrix(self.ref, self.phy, mut_wt, mut_max) # hits self.assertEqual(hvb._prob(hvb.markers['I'], 0, 'G'), 1.0 - 0.1) self.assertEqual(hvb._prob(hvb.markers['I'], 4, 'A'), 1.0 - 0.1) self.assertEqual(hvb._prob(hvb.markers['I'], 3, 'A'), 1.0 - 0.1) # misses self.assertEqual(hvb._prob(hvb.markers['I'], 0, 'A'), 0.1 / 3.0) self.assertEqual(hvb._prob(hvb.markers['I'], 4, 'T'), 0.1 / 3.0) self.assertEqual(hvb._prob(hvb.markers['I'], 3, 'T'), 0.1 / 3.0)
def test_hapvarbasematrix_init(self): mut_wt, mut_max = 0.02, 0.6 hvb = preprocess.HapVarBaseMatrix(self.ref, self.phy, mut_wt, mut_max) self.assertEqual(hvb.refseq, self.ref) self.assertEqual(hvb.phylo, self.phy) self.assertEqual(hvb.mut_wt, mut_wt) self.assertEqual(hvb.mut_max, mut_max) markers = {'A':{1:'T', 3:'T', 0:'G'}, 'B':{0:'G', 2:'T', 4:'T', 5:'T', 7:'T'}, 'C':{0:'G', 2:'T', 5:'T'}, 'D':{0:'G', 2:'T', 4:'T', 6:'T', 8:'T'}, 'E':{0:'G', 2:'T', 3:'T', 4:'T', 6:'T'}, 'F':{0:'G', 2:'T', 4:'T', 5:'T'}, 'G':{0:'G', 2:'T', 4:'T', 6:'T'}, 'H':{0:'G', 2:'T', 4:'T'}, 'I':{0:'G'}} self.assertEqual(hvb.markers, markers)