We say that pattern $$p$$ is a most frequent $$k$$-mer in string $$s$$ if it maximizes PatternCount($$s$$, $$p$$) among all $$k$$-mers. For example, ACTAT is a most frequent 5-mer in ACAACTATGCATCACTATCGGGAACTATCCT, and ATA is a most frequent 3-mer of CGATATATCCATAG.
In the following interactive session, we assume the FASTA file data.fna1 to be located in the current directory.
>>> most_frequent_kmers('ACAACTATGCATCACTATCGGGAACTATCCT', 5) {'ACTAT'} >>> most_frequent_kmers('CGATATATCCATAG', 3) {'ATA'} >>> from Bio import SeqIO >>> most_frequent_kmers(*SeqIO.parse('data.fna', 'fasta'), 4) {'CATG', 'GCAT'}