This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def smith_waterman(a: str, b: str, alignment_score: float = 1, gap_cost: float = 1) -> float: | |
""" | |
Compute the Smith-Waterman alignment score for two strings. | |
See https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm#Algorithm | |
This implementation has a fixed gap cost (i.e. extending a gap is considered | |
free). In the terminology of the Wikipedia description, W_k = {c, c, c, ...}. | |
This implementation also has a fixed alignment score, awarded if the relevant |