-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq14.py
More file actions
38 lines (25 loc) · 669 Bytes
/
q14.py
File metadata and controls
38 lines (25 loc) · 669 Bytes
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
from itertools import product
f = open('rosalind_kmer.txt','r')
l = f.readlines()
s = ''
string = [] # to strip '\n' from the list elements contaning.or use rstrip()
d = {}
for a in l:
a = a.strip()
string.append(a)
for i in range(1,len(string)):
s = s + string[i]
print s
list1 = list(product('TAGC',repeat = 4)) #to create the cartesian product of TAGC
stringcp = (map(''.join,list1))
stringcp.sort()
print stringcp
stringlist = []
for i in range(0,len(s)-3):
stringlist.append(s[i:i+4])
print stringlist
d= {}
for i in stringcp:
d[i]=stringlist.count(i)
for key,value in sorted(d.items()):
print value,