Minsu Kim/python/Rosalind / problem8
def mmm(sample):
countt = 0
for i in range(len(seq)-len(sample)+1):
count = 0
for j in range(len(sample)):
if seq[i+j]!=sample[j]:
count += 1
if count <= d:
countt += 1
return countt
f = open('rosalind_ba1i.txt', 'r')
lines = f.readlines()
f.close()
seq = lines[0].strip()
k = int(lines[1].split()[0])
d = int(lines[1].split()[1])
p = ['A','C','G','T']
ans = []
m = 0
solution = open('solution1.txt', 'w')
for turn in range(k**4):
num = []
st = ''
left = turn
for x in range(k):
num.append(left%4)
left = int(left / 4)
for x in range(k):
st += p[num[x]]
temp = mmm(st)
ans.append([st, temp])
if temp>m:
m = temp
for x in range(len(ans)):
if ans[x][1]==m:
solution.write(ans[x][0])
solution.write("\n")
solution.close()