-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrequent words in string.py
16 lines (14 loc) · 1.19 KB
/
frequent words in string.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
string = 'CGTTACTGATCGTGAACTGACCGAACCACCGAACCCTTGGAACGCGTTACTGAACCGAACCTCGTGAACTGACCGAACCACCGAACCTAAATGCCTAAATGCCTAAATGCCCTTGGAACGCTTGGAACGCTTGGAACGCGTTACTGACGTTACTGACTTGGAACGCGTTACTGATAAATGCCTAAATGCCTCGTGAACTGACCGAACCCTTGGAACGTAAATGCCTAAATGCCTAAATGCCACCGAACCTAAATGCCCTTGGAACGTAAATGCCCTTGGAACGCGTTACTGATAAATGCCACCGAACCCGTTACTGATCGTGAACTGCGTTACTGAACCGAACCCTTGGAACGTCGTGAACTGACCGAACCACCGAACCTCGTGAACTGCTTGGAACGTCGTGAACTGCTTGGAACGTAAATGCCCGTTACTGACTTGGAACGTAAATGCCCGTTACTGACTTGGAACGTAAATGCCTAAATGCCCTTGGAACGTCGTGAACTGCGTTACTGACTTGGAACGTCGTGAACTGCTTGGAACGTCGTGAACTGTAAATGCCTAAATGCCCGTTACTGATAAATGCCTAAATGCCACCGAACCTAAATGCCTCGTGAACTGCTTGGAACGTCGTGAACTGACCGAACCCTTGGAACGCTTGGAACGTCGTGAACTGCTTGGAACGACCGAACCCTTGGAACGTAAATGCCTCGTGAACTGCGTTACTGATAAATGCCCTTGGAACGCGTTACTGATCGTGAACTGCGTTACTGACTTGGAACGACCGAACCTCGTGAACTGTAAATGCCTAAATGCCTCGTGAACTGTAAATGCCCTTGGAACGCGTTACTGAACCGAACCCGTTACTGACTTGGAACGACCGAACCTCGTGAACTGTCGTGAACTGCGTTACTGAACCGAACCCTTGGAACGCTTGGAACGTCGTGAACTG'
k = 11
c={}
for i in range(len(string)-k+1):
kmer = string[i:i+k]
if kmer in c:
c[kmer] += 1
else:
c[kmer] = 1
out=[]
for k, v in c.items():
if v == max(c.values()):
out.append(k)
print(' '.join(out))