def check_spelling(checked_word, dist, word_list):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    s_m = student.build_scoring_matrix(alphabet, 2, 1, 0)
    result = []
    for word in word_list:
        a_m = student.compute_alignment_matrix(checked_word, word, s_m, True)
        score = student.compute_global_alignment(checked_word, word, s_m, a_m)
        changes = len(checked_word) + len(word) - score[0]
        if changes <= dist:
            result.append(word)
            print score[1], score[2]
    return result
def check_spelling(checked_word, dist, word_list):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    s_m = student.build_scoring_matrix(alphabet, 2, 1, 0)
    result = []
    for word in word_list:
        a_m = student.compute_alignment_matrix(checked_word, word, s_m, True)
        score = student.compute_global_alignment(checked_word, word, s_m, a_m)
        changes = len(checked_word) + len(word) - score[0]
        if changes <= dist:
            result.append(word)
            print score[1], score[2]
    return result
def generate_null_distribution(seq_x, seq_y, scoring_matrix, num_trials):
    scoring_distribution = {}
    for i in xrange(num_trials):
        rand_y = list(seq_y)
        random.shuffle(rand_y)
        a_m = student.compute_alignment_matrix(seq_x, rand_y, scoring_matrix, False)
        alignment = student.compute_local_alignment(seq_x, rand_y, scoring_matrix, a_m)
        score = alignment[0]
        scoring_distribution[score] = scoring_distribution.get(score, 0) + 1
        print i
        #print alignment[1]
        #print alignment[2]
    return scoring_distribution
Example #4
0
def generate_null_distribution(seq_x, seq_y, scoring_matrix, num_trials):
    scoring_distribution = {}
    for i in xrange(num_trials):
        rand_y = list(seq_y)
        random.shuffle(rand_y)
        a_m = student.compute_alignment_matrix(seq_x, rand_y, scoring_matrix,
                                               False)
        alignment = student.compute_local_alignment(seq_x, rand_y,
                                                    scoring_matrix, a_m)
        score = alignment[0]
        scoring_distribution[score] = scoring_distribution.get(score, 0) + 1
        print i
        #print alignment[1]
        #print alignment[2]
    return scoring_distribution
Example #5
0
def distance(word1, word2, s_m):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    a_m = student.compute_alignment_matrix(word1, word2, s_m, True)
    score = student.compute_global_alignment(word1, word2, s_m, a_m)
    changes = len(word1) + len(word2) - score[0]
    return changes
def distance(word1, word2, s_m):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    a_m = student.compute_alignment_matrix(word1, word2, s_m, True)
    score = student.compute_global_alignment(word1, word2, s_m, a_m)
    changes = len(word1) + len(word2) - score[0]
    return changes