Skip to content

Commit 9023a3c

Browse files
Stop Smith-Waterman traceback at zero-score cells
1 parent 6e03a48 commit 9023a3c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎dynamic_programming/smith_waterman.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def traceback(score: list[list[int]], query: str, subject: str) -> str:
162162
# guard against empty query or subject
163163
if i == 0 or j == 0:
164164
return ""
165-
while i > 0 and j > 0:
165+
while i > 0 and j > 0 and score[i][j] > 0:
166166
if score[i][j] == score[i - 1][j - 1] + score_function(
167167
query[i - 1], subject[j - 1]
168168
):

0 commit comments

Comments
 (0)