예제 #1
0
def q7():
    x = "ABCABC"
    y = "ABCABC"

    sm = soln.build_scoring_matrix("ABC-", 2, 1, 0)
    print sm

    # global
    am = soln.compute_alignment_matrix(x, y, sm, True)
    print soln.compute_global_alignment(x, y, sm, am)
def check_spelling(checked_word, dist, word_list):
    answer = set()
    letters = list("qwertyuiopasdfghjklzxcvbnm")
    scor_matrix = p.build_scoring_matrix(letters, 2, 1, 0)

    for word in word_list:
        align_matrix = p.compute_alignment_matrix(checked_word, word,
                                                  scor_matrix, True)
        score = p.compute_global_alignment(checked_word, word, scor_matrix,
                                           align_matrix)[0]
        edit_distance = len(word) + len(checked_word) - score
        if edit_distance <= dist:
            answer.add(word)
    return answer
def q7():
    seq_x = "kqistian"
    seq_y = "kristian"
    scor_matrix = p.build_scoring_matrix(
        ["a", "b", "e", "k", "q", "t", "r", "i", "t", "n", "s"], 2, 1, 0)
    #print scor_matrix
    #print ""
    align_matrix = p.compute_alignment_matrix(seq_x, seq_y, scor_matrix, True)
    print align_matrix
    score = p.compute_global_alignment(seq_x, seq_y, scor_matrix, align_matrix)
    print score
    #q7()

    #Question 8
    """
예제 #4
0

def q7():
    x = "ABCABC"
    y = "ABCABC"

    sm = soln.build_scoring_matrix("ABC-", 2, 1, 0)
    print sm

    # global
    am = soln.compute_alignment_matrix(x, y, sm, True)
    print soln.compute_global_alignment(x, y, sm, am)


# scoring matrix for q8
word_sm = soln.build_scoring_matrix("abcdefghijklmnopqrstuvwxyz-", 2, 1, 0)


def check_spelling(checked_word, dist, word_list):
    wordlist = []
    word_len = len(checked_word)

    # global
    for word in word_list:
        am = soln.compute_alignment_matrix(checked_word, word, word_sm, True)
        g_al, dummy_x, dummy_y = soln.compute_global_alignment(checked_word, word, word_sm, am)

        score = word_len + len(word) - g_al

        if score <= dist:
            wordlist.append(word)
def test():
    scoringmatrix = p.build_scoring_matrix(set(["a", "b"]), 10, 4, -6)
    generate_null_distribution("aaaaaaaab", "aabbbbaabbba", scoringmatrix, 500)