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


Python Profile.rowUncertainty方法代码示例

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


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

示例1: test_rowUncertainty

# 需要导入模块: from cogent.core.profile import Profile [as 别名]
# 或者: from cogent.core.profile.Profile import rowUncertainty [as 别名]
    def test_rowUncertainty(self):
        """rowUncertainty: should handle full and empty profiles
        """
        p = Profile(array([[0.25, 0.25, 0.25, 0.25], [0.5, 0.5, 0, 0]]), "ABCD")
        self.assertEqual(p.rowUncertainty(), [2, 1])

        # for empty rows 0 is returned as the uncertainty
        self.assertEqual(self.empty.rowUncertainty().tolist(), [])
        p = Profile(array([[], [], []]), "")
        self.assertEqual(p.rowUncertainty().tolist(), [])
        # doesn't work on 1D array
        self.assertRaises(ProfileError, self.oned.rowUncertainty)
开发者ID:blankenberg,项目名称:pycogent,代码行数:14,代码来源:test_profile.py

示例2: ProfileTests

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

#.........这里部分代码省略.........
    def test_score_profile(self):
        """score: should work correctly for Profile as input
        """
        p1 = Profile(
            array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0.5, 0.5], [0, 0, 0, 1], [0.25, 0.25, 0.25, 0.25]]), "TCAG"
        )
        p2 = Profile(
            array(
                [[0, 1, 0, 0], [0.2, 0, 0.8, 0], [0, 0, 0.5, 0.5], [1 / 3, 1 / 3, 0, 1 / 3], [0.25, 0.25, 0.25, 0.25]]
            ),
            "TCAG",
        )
        p3 = Profile(array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]), "TCAG")
        p4 = Profile(array([[1, 0, 0, 0], [0, 1, 0, 0]]), "TCAG")
        p5 = Profile(array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]), "AGTC")

        # works on normal valid data
        self.assertFloatEqual(self.score2.score(p1, offset=0), [0.55, 1.25, 0.45])
        self.assertFloatEqual(self.score2.score(p2, offset=0), [1.49, 1.043, 0.483], 1e-3)
        # works with different offset
        self.assertFloatEqual(self.score2.score(p1, offset=1), [1.25, 0.45])
        self.assertFloatEqual(self.score2.score(p1, offset=2), [0.45])
        # raises error on invalid offset
        self.assertRaises(ProfileError, self.score2.score, p1, offset=3)
        # works on profile of minimal length
        self.assertFloatEqual(self.score2.score(p3, offset=0), [0.6])
        # raises error when profile is too short
        self.assertRaises(ProfileError, self.score2.score, p4, offset=0)
        # raises error on empty profile
        self.assertRaises(ProfileError, self.empty.score, p1)
        # raises error when character order doesn't match
        self.assertRaises(ProfileError, self.score2.score, p5)

    def test_rowUncertainty(self):
        """rowUncertainty: should handle full and empty profiles
        """
        p = Profile(array([[0.25, 0.25, 0.25, 0.25], [0.5, 0.5, 0, 0]]), "ABCD")
        self.assertEqual(p.rowUncertainty(), [2, 1])

        # for empty rows 0 is returned as the uncertainty
        self.assertEqual(self.empty.rowUncertainty().tolist(), [])
        p = Profile(array([[], [], []]), "")
        self.assertEqual(p.rowUncertainty().tolist(), [])
        # doesn't work on 1D array
        self.assertRaises(ProfileError, self.oned.rowUncertainty)

    def test_columnUncertainty(self):
        """columnUncertainty: should handle full and empty profiles
        """
        p = Profile(array([[0.25, 0.5], [0.25, 0.5], [0.25, 0], [0.25, 0]]), "AB")
        self.assertEqual(p.columnUncertainty(), [2, 1])
        # for empty cols nothing is returned as the uncertainty
        self.assertEqual(self.empty.columnUncertainty().tolist(), [])
        p = Profile(array([[], [], []]), "")
        self.assertEqual(p.columnUncertainty().tolist(), [])
        # doesn't work on 1D array
        self.assertRaises(ProfileError, self.oned.columnUncertainty)

    def test_rowDegeneracy(self):
        """rowDegneracy: should work as expected"""
        p1 = self.consensus
        p2 = self.not_same_value

        self.assertEqual(p1.rowDegeneracy(), [1, 1, 1, 2, 1])
        self.assertEqual(p1.rowDegeneracy(cutoff=0.5), [1, 1, 1, 2, 1])
        self.assertEqual(p1.rowDegeneracy(cutoff=0.75), [1, 2, 1, 3, 2])
开发者ID:blankenberg,项目名称:pycogent,代码行数:70,代码来源:test_profile.py


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