01 ‘GATCCAGATCCCCATAC‘, 计算这串数列中两个出现最高的频率。
t = ‘GATCCAGATCCCCATAC‘
L = [ ]
for i in range(len(t)-1):
L.append(t[i:i+2])
x = reduce(lambda x,y: x if L.count(x)>L.count(y) else y, L)
# reduce(function, iterable[, initializer])
print x, ‘appeared‘, L.count(x), ‘times! It is the most frequent 2-mer.‘
原文:http://www.cnblogs.com/think-and-do/p/7249648.html