本文整理匯總了Python中cogent.core.profile.Profile.randomIndices方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.randomIndices方法的具體用法?Python Profile.randomIndices怎麽用?Python Profile.randomIndices使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cogent.core.profile.Profile
的用法示例。
在下文中一共展示了Profile.randomIndices方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_randomIndices
# 需要導入模塊: from cogent.core.profile import Profile [as 別名]
# 或者: from cogent.core.profile.Profile import randomIndices [as 別名]
def test_randomIndices(self):
"""randomIndices: 99% of new frequencies should be within 3*SD
"""
r_num, c_num = 100, 20
num_elements = r_num * c_num
r = random([r_num, c_num])
p = Profile(r, "A" * 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
result = [p.randomIndices() for x in range(n)]
a = Alignment(transpose(result))
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:
res[row, ord(i)] = freq[i]
return res
ap = absoluteProfile(a, p.CharOrder)
failure = abs(ap - means) > three_stds
assert sum(sum(failure)) / num_elements <= 0.01