Open main menu

Biolecture.org β

Minsu Kim/python/Rosalind / problem9

Revision as of 21:35, 12 December 2017 by imported>Minsukim (Created page with "<p><img alt="" src="/ckfinder/userfiles/images/bandicam%202017-12-12%2021-28-32-700.jpg" style="height:439px; width:1100px" /></p> <p> </p> <p>import itertools</p> <p>f =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

 

import itertools

f = open('rosalind_ba1k.txt', 'r')
lines = f.readlines()
seq = lines[0].strip()
k = int(lines[1].strip())
f.close

for i in itertools.product("ACGT", repeat=k):
    point = ''.join(i)
    count = 0
    for j in range(len(seq) - k + 1):
        if seq[j : j + k] == point:
            count += 1
    print(count)