Пример #1
0
 def test_gtr(self):
     f = [0.23, 0.31, 0.21]
     s = sum(f)
     f.append(1.0-s)
     gtr = RevDiscreteModel(r_upper=[[1.0, 3.0, 1.2], [2.0, 4.1],[0.8]], 
                            equil_freq=f)
     m = gtr.get_probs(0.01)
     assert_mat_eq(self, m, [[0.99204347826086958, 0.0019969565217391304, 0.0040317391304347822, 0.001926086956521739], 
                             [0.0014816129032258064, 0.98928709677419346, 0.0026880645161290323, 0.0065419354838709672], 
                             [0.0044157142857142858, 0.0039680952380952384, 0.9903238095238095, 0.0012942857142857144], 
                             [0.0017719999999999999, 0.0081119999999999994, 0.0010872, 0.98902800000000002]])
Пример #2
0
 def test_set_q_mat(self):
     a = RevDiscreteModel(r_upper=[[1.0, 1.0, 1.0], [1.0, 1.0], [1.0],])
     oth = 1.0/3.0
     assert_list_eq(self, a.state_freqs, [0.25]*4)
     assert_mat_eq(self, a.q_mat, [[-1.0, oth, oth, oth],
                                    [oth, -1.0, oth, oth],
                                    [oth, oth, -1.0, oth],
                                    [oth, oth, oth, -1.0]])
     a.r_upper = [[1.0, 2.0, 1.0], [1.0, 2.0], [1.0],] # kimura kappa=2
     assert_list_eq(self, a.state_freqs, [0.25]*4)
     assert_mat_eq(self, a.q_mat, [[-1.0, .25, .5, .25],
                                   [.25, -1.0, .25, .5],
                                   [.5, .25, -1.0, .25],
                                   [.25, .5, .25, -1.0]])
     a.state_freqs = [0.2, 0.3, 0.15, 0.35]
     assert_list_eq(self, a.state_freqs, [0.2, 0.3, 0.15, 0.35])
     exp = [[-0.9547738, 0.301507, 0.3015075, 0.351758], 
            [0.20100502, -1.05527638, 0.15075376, 0.7035175], 
            [0.40201005, 0.301507537, -1.05527638, 0.35175879], 
            [0.2010050, 0.603015075, 0.150753768, -0.954773869]]
     assert_mat_eq(self, a.q_mat, exp)