Add FrequentWords and FrequencyMap functions
This commit is contained in:
parent
51b9d935f4
commit
4fa3efbb2b
20
Code/FrequentWords.py
Normal file
20
Code/FrequentWords.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
def FrequentWords(Text, k):
|
||||||
|
words = []
|
||||||
|
freq = FrequencyMap(Text, k)
|
||||||
|
m = max(freq.values())
|
||||||
|
for key in freq:
|
||||||
|
if freq[key] == m:
|
||||||
|
words.append(key)
|
||||||
|
return words
|
||||||
|
|
||||||
|
|
||||||
|
def FrequencyMap(Text, k):
|
||||||
|
freq = {}
|
||||||
|
n = len(Text)
|
||||||
|
for i in range(n - k + 1):
|
||||||
|
Pattern = Text[i:i + k]
|
||||||
|
freq[Pattern] = 0
|
||||||
|
for i in range(n - k + 1):
|
||||||
|
Pattern = Text[i:i + k]
|
||||||
|
freq[Pattern] += 1
|
||||||
|
return freq
|
@ -22,3 +22,4 @@
|
|||||||
|
|
||||||
*** Vocabulary
|
*** Vocabulary
|
||||||
- k-mer: subsquences of length /k/ in a biological sequence
|
- k-mer: subsquences of length /k/ in a biological sequence
|
||||||
|
- Frequency map: sequence --> frequency of the sequence
|
||||||
|
Loading…
Reference in New Issue
Block a user