def _finish_backtrace(sequenceA, sequenceB, ali_seqA, ali_seqB, row, col, gap_char):
 if row:
  ali_seqA += sequenceA[(row - 1)::(-1)]
 if col:
  ali_seqB += sequenceB[(col - 1)::(-1)]
 if (row > col):
  ali_seqB += (gap_char * (len(ali_seqA) - len(ali_seqB)))
 elif (col > row):
  ali_seqA += (gap_char * (len(ali_seqB) - len(ali_seqA)))
 return (ali_seqA, ali_seqB)

def _finish_backtrace ( sequenceA , sequenceB , ali_seqA , ali_seqB , row , col , gap_char ) : if row : ali_seqA += sequenceA [ ( row - 1 ) : : ( - 1 ) ] if col : ali_seqB += sequenceB [ ( col - 1 ) : : ( - 1 ) ] if ( row > col ) : ali_seqB += ( gap_char * ( len ( ali_seqA ) - len ( ali_seqB ) ) ) elif ( col > row ) : ali_seqA += ( gap_char * ( len ( ali_seqB ) - len ( ali_seqA ) ) ) return ( ali_seqA , ali_seqB )
add remaining sequences and fill with gaps if neccessary .