本文整理汇总了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