I have an empty list and should append any keys to the list words if the key's corresponding value in freq
is equal to m
.
I have the inputs ACGTTGCATGTCGCATGATGCATGAGAGCT
(for text) and 4
(for k).
What I need to do is check where something is in the list:
>>>> words = [ ]
The above has a frequency value equal to the maximum value, and if it does, appends "key" to it.
The output I am supposed to get is CATG GCAT
.
If you are familiar with the genomic data science course from UCSD, you will probably know this problem.
This is the code:
# Input: A string Text and an integer k
# Output: A list containing all most frequent k-mers in Textdef
>>>> FrequentWords(Text, k):
>>>> words = []
>>>> freq = FrequencyMap(Text, k)
>>>> m = max(freq.values())
>>>> for key in freq:
# add each key to words whose corresponding frequency value is equal to m ( this is the part I am struggling with)
>>>> return words