當前位置: 首頁>>代碼示例>>Python>>正文


Python Profile.columnUncertainty方法代碼示例

本文整理匯總了Python中cogent.core.profile.Profile.columnUncertainty方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.columnUncertainty方法的具體用法?Python Profile.columnUncertainty怎麽用?Python Profile.columnUncertainty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cogent.core.profile.Profile的用法示例。


在下文中一共展示了Profile.columnUncertainty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_columnUncertainty

# 需要導入模塊: from cogent.core.profile import Profile [as 別名]
# 或者: from cogent.core.profile.Profile import columnUncertainty [as 別名]
 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)
開發者ID:blankenberg,項目名稱:pycogent,代碼行數:13,代碼來源:test_profile.py

示例2: ProfileTests

# 需要導入模塊: from cogent.core.profile import Profile [as 別名]
# 或者: from cogent.core.profile.Profile import columnUncertainty [as 別名]

#.........這裏部分代碼省略.........
        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])
        # when a row seems to add up to the cutoff value, it's not
        # always found because of floating point error. E.g. second row
        # in this example
        self.assertEqual(p1.rowDegeneracy(cutoff=1), [2, 4, 1, 4, 2])
        # when the cutoff can't be found, the number of columns in the
        # profile is returned (for each row)
        self.assertEqual(p1.rowDegeneracy(cutoff=1.5), [4, 4, 4, 4, 4])

        self.assertEqual(p2.rowDegeneracy(cutoff=0.95), [4, 2, 4, 1])
        self.assertEqual(p2.rowDegeneracy(cutoff=1.4), [4, 3, 4, 1])

        self.assertEqual(self.empty.rowDegeneracy(), [])
開發者ID:blankenberg,項目名稱:pycogent,代碼行數:69,代碼來源:test_profile.py


注:本文中的cogent.core.profile.Profile.columnUncertainty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。