def frequent_words_with_mismatch(text, kmers, d):
    count_dict = dict()
    max_count = 0
    visited_kmers = set()
    for kmer in kmers:
        app = approx_pattern_count(text, kmer, d) + approx_pattern_count(text, reverse_dna(kmer), d)
        if app > 0 and kmer not in visited_kmers:
            if kmer not in count_dict:
                count_dict[kmer] = 0
            count_dict[kmer] += app
            if count_dict[kmer] > max_count:
                max_count = count_dict[kmer]

    result = [key for key in count_dict if count_dict[key] == max_count]
    return result, max_count
Example #2
0
def frequent_words_with_mismatch(text, kmers, d):
    count_dict = dict()
    max_count = 0
    visited_kmers = set()
    for kmer in kmers:
        app = approx_pattern_count(text, kmer, d) + approx_pattern_count(
            text, reverse_dna(kmer), d)
        if app > 0 and kmer not in visited_kmers:
            if kmer not in count_dict:
                count_dict[kmer] = 0
            count_dict[kmer] += app
            if count_dict[kmer] > max_count:
                max_count = count_dict[kmer]

    result = [key for key in count_dict if count_dict[key] == max_count]
    return result, max_count
def frequent_words_with_mismatch(text, kmers, d):
    count_dict = dict()
    max_count = 0
    for kmer in kmers:
        app = approx_pattern_count(text, kmer, d)
        if app > 0:
            if kmer not in count_dict:
                count_dict[kmer] = 0
            count_dict[kmer] += app
            if count_dict[kmer] > max_count:
                max_count = count_dict[kmer]

    result = [key for key in count_dict if count_dict[key] == max_count]
    return result, max_count
def frequent_words_with_mismatch(text, kmers, d):
    count_dict = dict()
    max_count = 0
    for kmer in kmers:
        app = approx_pattern_count(text, kmer, d)
        if app > 0:
            if kmer not in count_dict:
                count_dict[kmer] = 0
            count_dict[kmer] += app
            if count_dict[kmer] > max_count:
                max_count = count_dict[kmer]

    result = [key for key in count_dict if count_dict[key] == max_count]
    return result, max_count