本文整理汇总了Python中messages.Messages._mutation_selection_matrix方法的典型用法代码示例。如果您正苦于以下问题:Python Messages._mutation_selection_matrix方法的具体用法?Python Messages._mutation_selection_matrix怎么用?Python Messages._mutation_selection_matrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messages.Messages
的用法示例。
在下文中一共展示了Messages._mutation_selection_matrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Messages_Test
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import _mutation_selection_matrix [as 别名]
class Messages_Test(unittest.TestCase):
def setUp(self):
self.mutation_matrix = np.array([[ 0.96, 0.02, 0. , 0. , 0. , 0. , 0. , 0.02],
[ 0.02, 0.96, 0.02, 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0.02, 0.96, 0.02, 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0.02, 0.96, 0.02, 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0.02, 0.96, 0.02, 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0.02, 0.96, 0.02, 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0.02, 0.96, 0.02],
[ 0.02, 0. , 0. , 0. , 0. , 0. , 0.02, 0.96]])
pchem_vals = [0.05,0.15,0.24,0.41,0.44,0.51,0.54,0.79,0.83,0.92]
site_ids = range(10)
aa_ids = range(10)
self.site_types = Ring_Site_Types(.25, zip(aa_ids, pchem_vals), zip(site_ids, pchem_vals), [1] * 10)
self.code_matrix = np.ones((8,10)) / 10
self.fitness_contributions = None
self.message = Messages(self.code_matrix, self.site_types.fitness_matrix, self.mutation_matrix)
def test_mutation_selection_matrix(self):
mutation_selection_matrices = [self.message._mutation_selection_matrix(i) for i in xrange(10)]
for i in xrange(10):
self.assertTrue(np.allclose(mutation_selection_matrices[i],
correct_mutation_selection_matrices[i]),
msg="Mutation Selection matrix did not match for site index {}.".format(i))
def test_equilibrium_codon_usage(self):
self.assertTrue(np.allclose(self.message.codon_usage, # Should default to calculating codon usage
correct_equilibrium_codon_usage)) # at equilibrium
def test_equilibrium_fitness_contributions(self):
self.assertTrue(np.allclose(self.message.fitness_contributions, # Should also default to at equilibrium
correct_equilibrium_fitness_contributions))
def test_nonequilibrium_fitness_contributions(self):
self.message.calculate_at_codon_usage(nonequilibrium_codon_usage)
fitness_contributions = self.message.fitness_contributions
self.assertAlmostEqual(correct_nonequilibrium_fitness, np.prod(fitness_contributions))