just write this function for a recursion trace back, but it become a infinite loop and won't get into the next level of recursion. I cannot find the problem, many thanks! p_value gotten from a matrix outside, tested that and it is OK. status, i, j pass form main and start is (1,5,4).
def traceback_alignment(status, i, j):
alignmentA=""
alignmentB=""
p_value=0
while (i>1 and j>1):
if status==1:
alignmentA=seqA[i-1]+alignmentA
alignmentB=seqB[j-1]+alignmentB
p_value=ptr_matrixM.__getitem__(j, i)
print ("p_value="+str(p_value))
if status==2:
alignmentA=seqA[i-1]+alignmentA
alignmentB="_"+alignmentB
p_value=ptr_matrixIx.__getitem__(j, i)
print ("p_value="+str(p_value))
if status==3:
alignmentA="_"+alignmentA
alignmentB=seqB[j-1]+alignmentB
p_value=ptr_matrixIy.__getitem__(j, i)
print ("p_value="+str(p_value))
if p_value==1:
traceback_alignment(2, i-1, j)
if p_value==2:
traceback_alignment(3, i, j-1)
if p_value==4:
traceback_alignment(1, i-1, j-1)
if p_value==5:
traceback_alignment(2, i-1, j)
traceback_alignment(1, i-1, j-1)
if p_value==6:
traceback_alignment(1, i-1, j-1)
traceback_alignment(3, i, j-1)
if p_value==7:
traceback_alignment(3, i, j-1)
traceback_alignment(2, i-1, j)
traceback_alignment(1, i-1, j-1)
return (alignmentA, alignmentB)