-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedianString.py
More file actions
46 lines (45 loc) · 1.07 KB
/
Copy pathMedianString.py
File metadata and controls
46 lines (45 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
a = int(input(""))
dna = []
while True:
dn = input()
if dn:
dna.append(dn)
else:
break
def countMismatch(a, b):
count = 0
for le in range(len(a)):
if(a[le]!=b[le]):
count = count + 1
return count
apatterns = ["A", "T", "C", "G"]
patterns = []
for m in range(a-1):
addQueue = []
for lol in apatterns:
addQueue.append(lol+"A")
addQueue.append(lol+"T")
addQueue.append(lol+"C")
addQueue.append(lol+"G")
for each in addQueue:
apatterns.append(each)
if(len(each)==a):
patterns.append(each)
dictionary = {}
for sad in patterns:
sumDistance = 0
for lul in dna:
minDistance = 9999999
for wee in range(len(lul)-a):
x = countMismatch(lul[wee:wee+a], sad)
if(x<minDistance):
minDistance = x
sumDistance = sumDistance + minDistance
dictionary[sad] = sumDistance
minimum = 999999
ans = ""
for l in dictionary:
if(dictionary[l]<minimum):
minimum = dictionary[l]
ans = l
print(ans)