@@ -0,0 +1,1210 @@
+from __future__ import division%0A%0Adef load_subs_matrix(matrix_name):%0A    import Bio.SubsMat.MatrixInfo as matrix_info%0A%0A    # Try to get the requested substitution matrix from biopython, and %0A    # complain if no such matrix exists.%0A%0A    try:%0A        half_matrix = getattr(matrix_info, matrix_name)%0A    except AttributeError:%0A        raise ValueError(%22No such substitution matrix '%7B%7D'.%22.format(matrix_name))%0A%0A    # For convenience, make sure the matrix is square (i.e. symmetrical).%0A%0A    full_matrix = %7B%7D%0A%0A    for i, j in half_matrix:%0A        full_matrix%5Bi, j%5D = half_matrix%5Bi, j%5D%0A        full_matrix%5Bj, i%5D = half_matrix%5Bi, j%5D%0A%0A    return full_matrix%0A%0Adef score_gap_free_alignment(seq_1, seq_2, subs_matrix):%0A    if len(seq_1) != len(seq_2):%0A        raise ValueError(%22sequence lengths don't match%22)%0A    if '-' in seq_1 or '-' in seq_2:%0A        raise ValueError(%22sequences with gaps are not supported.%22)%0A%0A    score = 0%0A    max_score = 0%0A%0A    for aa_1, aa_2 in zip(seq_1, seq_2):%0A        score += subs_matrix%5Baa_1, aa_2%5D%0A        max_score += max(subs_matrix%5Baa_1, aa_1%5D, subs_matrix%5Baa_2, aa_2%5D)%0A%0A    # Convert the substitution matrix score into a normalized distance.%0A%0A    return 1 - max(score, 0) / max_score%0A%0A%0A%0A

Add a module for working with PAM, BLOSUM, etc.