当前位置: 首页>>代码示例>>Python>>正文


Python Messages._mutation_selection_matrix方法代码示例

本文整理汇总了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))
开发者ID:kkauffman,项目名称:tRNAModel,代码行数:44,代码来源:messages_test.py


注:本文中的messages.Messages._mutation_selection_matrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。