admin管理员组

文章数量:1403355

This is my code for the Gap Alignment/Traceback. I need help to fix it.

The input is GATTACA,GTCGACGCA

The expected output is :

GATTAC--A GTCGACGCA -3

But I keep getting:

GATTA--CA GTCGACGCA -3

I don't know how to fix it.

while i> 0 or j> 0 :
            curr_score = matrix[i,j]
           
            match_score = 0
            if i > 0 and j > 0 :
                 if (sequence1[i-1] == sequence2[j-1]):
                     match_score = Reward_match
                 else:
                     match_score = Penality_mismatch
                 if curr_score ==  matrix[i-1, j-1] + match_score:
                    alg1= sequence1[i-1] + alg1
                    alg2 = sequence2[j-1]+alg2
                    i-=1
                    j-=1
                    
                    continue
                
            if (i > 0):
                if (curr_score == matrix[i-1,j] + Gap_penality):
                    alg1 = sequence1[i-1] + alg1
                    alg2 = "-" + alg2
                    i-=1
                    continue
            if(j > 0):
                alg1 ="-" +alg1
                alg2 = sequence2[j-1] + alg2
                j-= 1
                    
        
return alg1, alg2, int(matrix[sequence1_Length, sequence2_Length])

本文标签: NeedlemanWunsch Algorithm AlignmentStack Overflow