Skip to content
Prev Previous commit
Next Next commit
descriptive names for the parameters a and b
  • Loading branch information
BAW2501 committed Aug 22, 2023
commit 65b95a62b565ffbb61fee5d7d1c2ac76ba3ea10d
7 changes: 3 additions & 4 deletions dynamic_programming/smith_waterman.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm
# Score constants
"""
Expand All @@ -10,7 +9,7 @@
GAP = -2


def score_function(a: str, b: str) -> int:
def score_function(source_char: str, target_char: str) -> int:
"""
Calculate the score for a character pair based on whether they match or mismatch.
Returns 1 if the characters match, -1 if they mismatch.
Expand All @@ -19,7 +18,7 @@ def score_function(a: str, b: str) -> int:
>>> score_function('A', 'C')
-1
"""
if a == b:
if source_char == target_char:
return MATCH
else:
return MISMATCH
Expand Down Expand Up @@ -87,7 +86,7 @@ def traceback(score: list[list[int]], query: str, subject: str) -> str:
align2 = subject[j - 1] + align2
j -= 1

return f'{align1}\n{align2}'
return f"{align1}\n{align2}"


if __name__ == "__main__":
Expand Down