Changes
Created page with "<p><img alt="" src="/ckfinder/userfiles/images/bandicam%202017-12-12%2021-27-05-884.jpg" style="height:339px; width:1000px" /></p> <p>def mmm(sample):<br /> countt..."
<p><img alt="" src="/ckfinder/userfiles/images/bandicam%202017-12-12%2021-27-05-884.jpg" style="height:339px; width:1000px" /></p>
<p>def mmm(sample):<br />
countt = 0<br />
for i in range(len(seq)-len(sample)+1):<br />
count = 0<br />
for j in range(len(sample)):<br />
if seq[i+j]!=sample[j]:<br />
count += 1<br />
if count <= d:<br />
countt += 1<br />
return countt</p>
<p>f = open('rosalind_ba1i.txt', 'r')<br />
lines = f.readlines()<br />
f.close()</p>
<p>seq = lines[0].strip()<br />
k = int(lines[1].split()[0])<br />
d = int(lines[1].split()[1])</p>
<p>p = ['A','C','G','T']<br />
ans = []<br />
m = 0</p>
<p>solution = open('solution1.txt', 'w')<br />
for turn in range(k**4):<br />
num = []<br />
st = ''<br />
left = turn<br />
for x in range(k):<br />
num.append(left%4)<br />
left = int(left / 4)<br />
for x in range(k):<br />
st += p[num[x]]<br />
temp = mmm(st)<br />
ans.append([st, temp])<br />
if temp>m:<br />
m = temp<br />
for x in range(len(ans)):<br />
if ans[x][1]==m:<br />
f_ft.write(ans[x][0])<br />
f_ft.write("\n")</p>
<p>solution.close()</p>
<p>def mmm(sample):<br />
countt = 0<br />
for i in range(len(seq)-len(sample)+1):<br />
count = 0<br />
for j in range(len(sample)):<br />
if seq[i+j]!=sample[j]:<br />
count += 1<br />
if count <= d:<br />
countt += 1<br />
return countt</p>
<p>f = open('rosalind_ba1i.txt', 'r')<br />
lines = f.readlines()<br />
f.close()</p>
<p>seq = lines[0].strip()<br />
k = int(lines[1].split()[0])<br />
d = int(lines[1].split()[1])</p>
<p>p = ['A','C','G','T']<br />
ans = []<br />
m = 0</p>
<p>solution = open('solution1.txt', 'w')<br />
for turn in range(k**4):<br />
num = []<br />
st = ''<br />
left = turn<br />
for x in range(k):<br />
num.append(left%4)<br />
left = int(left / 4)<br />
for x in range(k):<br />
st += p[num[x]]<br />
temp = mmm(st)<br />
ans.append([st, temp])<br />
if temp>m:<br />
m = temp<br />
for x in range(len(ans)):<br />
if ans[x][1]==m:<br />
f_ft.write(ans[x][0])<br />
f_ft.write("\n")</p>
<p>solution.close()</p>