Exemplo n.º 1
0
def patterncount_with_mismatchs(text, pattern,d):
    count = 0
    for i in range(0, len(text)-len(pattern)+1):
        if text[i : i+len(pattern)]  == pattern:
            count = count + 1
        elif compute_hd(text[i : i+len(pattern)],pattern) <= d:
            count = count + 1
    return count
Exemplo n.º 2
0
def neighbors(pattern,d):
    if d == 0:
        return pattern
    elif len(pattern) == 1:
        return ["A","C","G","T"]
    neighborhood = []
    suffix_neighbors = neighbors(suffix(pattern),d)
    for text in suffix_neighbors:
        if compute_hd(suffix(pattern), text) < d:
            for n in "ACGT" :
                neighborhood.append(n+text)
        else:
            neighborhood.append(pattern[0]+text)
    return neighborhood
Exemplo n.º 3
0
def score(motifs,consensus):
    score = 0
    for motif in motifs:
        score += compute_hd(motif,consensus)
    return score