#Frequent Words Problem (1A in book, pg. 7)12#Find the most frequent words in a string.3#Input: A string TEXT and an integer k. -- will be supplied as text file with TEXT on one line; k on next line4#Output: All most frequent k-mers in TEXT.56##Use argparse to read a file specified on the command line789#Associate contents of text file with variable - open the file101112##Read in information from textfile13#Get text string from first line of file into variable text, strip newline1415#Get value for k from second line of file into variable num, strip newline, assign to k161718##Find all kmers and build a dictionary of kmers1920#move through text by each position from 0 to end of text less the value of k (length of kmer) e.g., for index in range(index_0,index_lenghtoftext-k)21#define each kmer by getting substring of text from i to i+k222324##Identify which kmers occur most often in text by looking at number of times each kmer seen in dictionary25#initialize highest total seen to 0262728##Loop through kmer dictionary to find largest number of times a kmer was seen29#OR30##Get all values of kmer dictionary, sort list of values, grab highest total313233##With most frequent total identified, go back through dictionary to get kmers with total matching highest total observed34#define the result variable as null3536#loop through each kmer in the dictionary, obtaining value (times seen) and compare to current highest value seen3738##Print list of most frequently occurring kmers3940414243444546