def PatternMatchWithMis(pattern, text, d): startingIndex = [] for i in range(len(text)-len(pattern)+1): pattern2 = text[i:i+len(pattern)] if hamming(pattern, pattern2) <= d: startingIndex.append(i) return startingIndex
def Neighbors(pattern, d): if d == 0: return pattern if len(pattern) == 1: return ['A', 'C', 'G', 'T'] Neighborhood = [] SuffixNeighbors = Neighbors(pattern[1:], d) for text in SuffixNeighbors : if hamming(pattern[1:], text) < d : for nt in ['A', 'C', 'G', 'T']: Neighborhood.append(nt+text) else : Neighborhood.append(pattern[0]+text) return Neighborhood