コード例 #1
0
ファイル: LocalAli.py プロジェクト: Uhha/Assignment2
    newalign_y = ""
    trail = True
    for ith, jth in zip(align_x, align_y):
        if (ith or jth) == "-" and trail == True:
            trail = True
        else:
            newalign_x += ith
            newalign_y += jth
            trail = False '''
        
    oldscore = score 
    score = 0       
    for ith, jth in zip(align_x, align_y):
        score += scoring_matrix[ith][jth]
    #score = alignment_matrix[len(seq_x)][len(seq_y)]  
    print "Oldscore = ", oldscore
      
    print "VALIDANCE = ", oldscore == score    
        
    return (score, align_x, align_y)


pro1 = LoadHelper.read_protein(LoadHelper.HUMAN_EYELESS_URL)
pro2 = LoadHelper.read_protein(LoadHelper.FRUITFLY_EYELESS_URL)
matr = LoadHelper.read_scoring_matrix(LoadHelper.PAM50_URL)

alimat = PR.compute_alignment_matrix(pro1, pro2, matr, False)

print compute_local_alignment(pro1, pro2, matr, alimat)

コード例 #2
0
ファイル: Q7.py プロジェクト: Uhha/Assignment2
import LoadHelper
str1 = "sadness"
str2 = "straw"
#str1 = "kitten"
#str2 = "sitting"

alphabet = list(string.ascii_lowercase)

matrix = PR.build_scoring_matrix(alphabet, 2 ,1, 0)
alig = PR.compute_alignment_matrix(str1, str2, matrix, True)
res = PR.compute_global_alignment(str1, str2, matrix, alig)
#print res

#print "EDIT dist = ", len(str1)+len(str2)-res[0]

word_list = LoadHelper.read_words(LoadHelper.WORD_LIST_URL)
#print "WL = ", word_list

def check_spelling(checked_word, dist, word_list):
    matrix = PR.build_scoring_matrix(alphabet, 2 ,1, 0)
    retlist = []
    str1 = checked_word
    for ith in word_list:
        str2 = ith
        alig = PR.compute_alignment_matrix(str1, str2, matrix, True)
        res = PR.compute_global_alignment(str1, str2, matrix, alig)
        edit_dist = len(str1)+len(str2)-res[0]
        if edit_dist <= dist:
            retlist.append(str2)
    return retlist