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


Python Profile.randomSequence方法代碼示例

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


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

示例1: test_randomSequence

# 需要導入模塊: from cogent.core.profile import Profile [as 別名]
# 或者: from cogent.core.profile.Profile import randomSequence [as 別名]
    def test_randomSequence(self):
        """randomSequence: 99% of new frequencies should be within 3*SD"""
        r_num, c_num = 100, 20
        num_elements = r_num * c_num
        alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        r = random([r_num, c_num])
        p = Profile(r, alpha[:c_num])
        p.normalizePositions()
        d = p.Data
        n = 1000

        # Test only works on normalized profile, b/c of 1-d below
        means = n * d
        three_stds = sqrt(d * (1 - d) * n) * 3

        a = Alignment([p.randomSequence() for x in range(n)])

        def absoluteProfile(alignment, char_order):
            f = a.columnFreqs()
            res = zeros([len(f), len(char_order)])
            for row, freq in enumerate(f):
                for i in freq:
                    col = char_order.index(i)
                    res[row, col] = freq[i]
            return res

        ap = absoluteProfile(a, p.CharOrder)
        failure = abs(ap - means) > three_stds
        assert sum(sum(failure)) / num_elements <= 0.01
開發者ID:blankenberg,項目名稱:pycogent,代碼行數:31,代碼來源:test_profile.py


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