-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclump_finder.py
32 lines (23 loc) · 2.67 KB
/
clump_finder.py
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
import textwrap
def ClumpFinding(dna, length_of_k_mer, length_of_chunk_to_search_in, total_number_of_occurrence):
motifs = {}
most_repeated_motifs = {}
chunks_of_dna = []
number_of_chunk = 1
for chunk in textwrap.wrap(dna, length_of_chunk_to_search_in):
chunks_of_dna.append(chunk)
for chunk in chunks_of_dna:
for i in range(0, len(chunk)):
motif_frq = chunk[i:i + length_of_k_mer]
if len(motif_frq) == length_of_k_mer:
if motif_frq in motifs:
motifs[motif_frq] += 1
else:
motifs[motif_frq] = 1
for key, val in motifs.items():
if motifs[key] >= total_number_of_occurrence:
most_repeated_motifs[key] = val
number_of_chunk += 1
return f'{[x for x in most_repeated_motifs]} is\\are the most repeated {length_of_k_mer}-mer in chunk of length {length_of_chunk_to_search_in}'
dna = 'TACCGAACGTACATTGACTGCGACGCTAGGTTGGATAGTAGGCTGCTAACAGGCGCAGTGTGGCGCACGAGTCTTACACTACATGTATGCTTAAGATAGTGTATGAGACTCCAGGCCACTATGGGTGCAGCGAAACCTCGAGAGATCAGATCAGATCCTGGATAGATGACACGTAATCCAACTTCCTGATATATTGTAAATTGTAACTTACTTTACGAAACCTAGGGTGAGGGTGATTAGGGTGATGACCTTTAGATCTTTCCTAGCCTGGCCAACGCCCGAGGTACACATGGTGGTTCCGTTAAACCATGGATTCTCAACCTGGAACCGGCTCATTGGCATTCTTCACTGCAAGAACGGAAGTGCCCGCCTTGAGACGAAGCGTCACTCGTCGGGTTTTGCGTATGTATTGTTGTTGCGTATTGACGCCGCGGATTACCGTCCTCCCTATATGTTCTCGGGGGACGAAACGCGACCACGCGCAGGGCAACGCGGCAAACCGGGGTACACCGCGGAATTATCTAGTCTAGGGGGACCGGGACCAGCCGGGACCAGGTTTTACTCTCCGTGCCGCGACAGATAGTTAGCCAAAGGCGCACATGGTGCTAGGACCCTCTGTGAGGCTCCGCGCATTCAGGGCGGTCGGGCGTGATACAGTGGATTTGAGTTGTAGTCGACACCTAGGGTGTTCAATTGAACAGGTGACTCTCCACAGTTCCCATCGAGCCTTGGGGTAAAACGCAGGTCTTATAAAACTTGTGCTGTATAGTTAGGGAATGTAACACGTGTCTTAGCTCAGAGAGCCCTAGTCCCATCGGTTGGGGAATATACTATCCACGCGTAGCCTAAAGACCCCGCCGGGAATTATAAAATTCTCTTGTCACCACAGATTGCTGGAGGGCGGACTCTGATACCCCAGACCGGGACTACGGACTACCACCCCACCAGACAACTAACGACATACCTGTTAGAGTGGTGCTCTATGTGGGGAACAGTAGATCCATTCCATCAAACATACTGTCTTGTAGCTTACATTTGCTCTCCTATGAAAGCACGCATGAGAGTAGATTCTTGTTTCGCTTTGCCGTCTTGCTTCTTGCTTTGCTCTTGCTTATGCGGTGTGTGTAAAAAAAAGTGTAAAACTGGCGTATCGCTTACTTTAAACACTTACCGCTGTTTGACCGCAGGCCTGTGCGGTCCGTACTTGCACAAAAGTGGCACTGTTAGGCACTCCTTTAGCTCTGATAGTAGGTGAACCCGGGGTCACTTGAAAGAACTGTACTAACCATCCTCTCGAGGCGGGTTCGGTTGCCATGCTGCAGCATGTTATCCTCTCCGTAATCTCTCCGTAAAAAAGCGGTAAAGCGGTTTACTCGGACCAGGTGCACTTCCAGCGTCTCCCTAGTCTAATTTTACGCTGATCACTACACAGATACACCGCCGGCACTGACTGTTGCATACCCTCGGTTGCCGAATTGCCTATCGCAACAACACCACCCCTACAACACCTCGGAGCATCTCCGTGCAGCGTTAGGCTGCTTCATATTGACTACTAGCCACTGTTAGACCATCTGCTGTGAGACACACACGTACACGGATCTACCTTGGGGTAGTTGGAAAGGGATTGGATTGGTACCGCGTGCTTCGGTCGTGCTTCCTGCTTCTCCCGATTGGCCGTAACACAGGCAGAACCCCCGTTGGCGTGACCGGAGGGCAATATGGAGCATGGATGGAGCTCTTGGAGCT'
print(ClumpFinding(dna, 6, 25, 5))