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


Python Profile.toLogOddsMatrix方法代码示例

本文整理汇总了Python中cogent.core.profile.Profile.toLogOddsMatrix方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.toLogOddsMatrix方法的具体用法?Python Profile.toLogOddsMatrix怎么用?Python Profile.toLogOddsMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cogent.core.profile.Profile的用法示例。


在下文中一共展示了Profile.toLogOddsMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_toLogOddsMatrix

# 需要导入模块: from cogent.core.profile import Profile [as 别名]
# 或者: from cogent.core.profile.Profile import toLogOddsMatrix [as 别名]
 def test_toLogOddsMatrix(self):
     """toLogOddsMatrix: should work as expected"""
     # This test can be short, because it mainly depends on toOddsMatrix
     # for which everything has been tested
     p = Profile(
         array(
             [
                 [0.1, 0.3, 0.5, 0.1],
                 [0.25, 0.25, 0.25, 0.25],
                 [0.05, 0.8, 0.05, 0.1],
                 [0.7, 0.1, 0.1, 0.1],
                 [0.6, 0.15, 0.05, 0.2],
             ]
         ),
         Alphabet="ACTG",
     )
     p_exp = Profile(
         array(
             [
                 [-1.322, 0.263, 1.0, -1.322],
                 [0.0, 0.0, 0.0, 0.0],
                 [-2.322, 1.678, -2.322, -1.322],
                 [1.485, -1.322, -1.322, -1.322],
                 [1.263, -0.737, -2.322, -0.322],
             ]
         ),
         Alphabet="ACTG",
     )
     self.assertFloatEqual(p.toLogOddsMatrix().Data, p_exp.Data, eps=1e-3)
     # works on empty matrix
     self.assertEqual(self.empty.toLogOddsMatrix().Data.tolist(), [[]])
开发者ID:blankenberg,项目名称:pycogent,代码行数:33,代码来源:test_profile.py

示例2: ProfileTests

# 需要导入模块: from cogent.core.profile import Profile [as 别名]
# 或者: from cogent.core.profile.Profile import toLogOddsMatrix [as 别名]

#.........这里部分代码省略.........
        p = Profile(
            array(
                [
                    [0.1, 0.3, 0.5, 0.1],
                    [0.25, 0.25, 0.25, 0.25],
                    [0.05, 0.8, 0.05, 0.1],
                    [0.7, 0.1, 0.1, 0.1],
                    [0.6, 0.15, 0.05, 0.2],
                ]
            ),
            Alphabet="ACTG",
        )
        p_exp = Profile(
            array([[0.4, 1.2, 2, 0.4], [1, 1, 1, 1], [0.2, 3.2, 0.2, 0.4], [2.8, 0.4, 0.4, 0.4], [2.4, 0.6, 0.2, 0.8]]),
            Alphabet="ACTG",
        )
        self.assertEqual(p.toOddsMatrix().Data, p_exp.Data)
        assert p.Alphabet is p.toOddsMatrix().Alphabet
        self.assertEqual(p.toOddsMatrix([0.25, 0.25, 0.25, 0.25]).Data, p_exp.Data)

        # fails if symbol_freqs has wrong size
        self.assertRaises(ProfileError, p.toOddsMatrix, [0.25, 0.25, 0.25, 0.25, 0.25, 0.25])
        self.assertRaises(ProfileError, self.zero_entry.toOddsMatrix, [0.1, 0.2, 0.3])
        # works on empty profile
        self.assertEqual(self.empty.toOddsMatrix().Data.tolist(), [[]])
        # works with different input
        self.assertEqual(self.zero_entry.toOddsMatrix().Data, array([[1.2, 0.8, 0, 2], [0, 0, 3.2, 0.8]]))
        self.assertFloatEqual(
            self.zero_entry.toOddsMatrix([0.1, 0.2, 0.3, 0.4]).Data, array([[3, 1, 0, 1.25], [0, 0, 2.667, 0.5]]), 1e-3
        )
        # fails when one of the background frequencies is 0
        self.assertRaises(ProfileError, self.zero_entry.toOddsMatrix, [0.1, 0.2, 0.3, 0])

    def test_toLogOddsMatrix(self):
        """toLogOddsMatrix: should work as expected"""
        # This test can be short, because it mainly depends on toOddsMatrix
        # for which everything has been tested
        p = Profile(
            array(
                [
                    [0.1, 0.3, 0.5, 0.1],
                    [0.25, 0.25, 0.25, 0.25],
                    [0.05, 0.8, 0.05, 0.1],
                    [0.7, 0.1, 0.1, 0.1],
                    [0.6, 0.15, 0.05, 0.2],
                ]
            ),
            Alphabet="ACTG",
        )
        p_exp = Profile(
            array(
                [
                    [-1.322, 0.263, 1.0, -1.322],
                    [0.0, 0.0, 0.0, 0.0],
                    [-2.322, 1.678, -2.322, -1.322],
                    [1.485, -1.322, -1.322, -1.322],
                    [1.263, -0.737, -2.322, -0.322],
                ]
            ),
            Alphabet="ACTG",
        )
        self.assertFloatEqual(p.toLogOddsMatrix().Data, p_exp.Data, eps=1e-3)
        # works on empty matrix
        self.assertEqual(self.empty.toLogOddsMatrix().Data.tolist(), [[]])

    def test__score_indices(self):
开发者ID:blankenberg,项目名称:pycogent,代码行数:70,代码来源:test_profile.py


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