This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,10 @@
|
||||
def needleman_wunsch_score(s, t, match, mismatch, gap):
|
||||
m = len(t)
|
||||
prev = [j * gap for j in range(m + 1)]
|
||||
for i in range(1, len(s) + 1):
|
||||
cur = [i * gap] + [0] * m
|
||||
for j in range(1, m + 1):
|
||||
diagonal = prev[j - 1] + (match if s[i - 1] == t[j - 1] else mismatch)
|
||||
cur[j] = max(diagonal, prev[j] + gap, cur[j - 1] + gap)
|
||||
prev = cur
|
||||
return prev[m]
|
||||
Reference in new issue
Block a user