コード例 #1
0
def LevDistCorrect (token, suggestions):
   temp = StringMatcher.distance(token, suggestions[0])
   corrected_token = suggestions[0]

   for word in suggestions[1:]:
      dist = StringMatcher.distance(token, word)

      if (dist < temp):
         corrected_token = word

   return corrected_token
コード例 #2
0
ファイル: find.py プロジェクト: hanzz/bioscripts
    print i + 1, "/", seq_count, "( matched =", len(matched), ")"
    d = ""
    h = ""
    ind = 0
    for line in lines:
        if line.startswith(">"):
            ind = ind + 1
            h = line[:-1]
        else:
            d = line[10:-11]
            d_r = reverse_complement(d)
            if index(matched, ind):
                continue
            sm.set_seqs(data, d)
            found = sm.distance() <= int(sys.argv[2])
            sm.set_seqs(data, d_r)
            found = found or sm.distance() <= int(sys.argv[2])
            if found:
                pairs[i + 1].append(ind)
                matched.append(ind)
                matched.sort()
                output += h + "\n" + d + "\n"

    if not index(matched, i + 1):
        matched.append(i + 1)
        matched.sort()

    f = open(sys.argv[1] + "_result/" + str(i + 1) + (8 - len(str(i + 1))) * "_" + str(len(pairs[i + 1])), "w")
    f.write(output)
    f.close()