1. 程式人生 > >002 生信基礎題

002 生信基礎題

it is cti ble 數列 ini mes tcc pen true

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.‘

  

002 生信基礎題