I am attempting to implement the Dynamic Programming Table Needleman-Wunsch Algorithm in Python:
My code is inspired by this.
The far left column and top row need to start from 0, decrementing downwards
Note: this works perfectly fine if I limit the 2 sequences to just 100 characters long each. So maybe it's because the data is too big?
m, n = len(seqA), len(seqB) # let m, n denote the lengths of two sequences
score_matrix = tasks.empty_matrix(m+1, n+1)
for i in range(0, m+1):
score_matrix[i][0] = i * -1
for j in range(0, n+1):
score_matrix[0][j] = j * -1
Error:
for j in range(0, n+1):
score_matrix[0][j] = j * -1
IndexError: list assignment index out of range
Note: my DNA sequences are all ~10,000 characters long. So, 10K * 10K
DP table.
the error simply means your matrix has the wrong dimensions, you accessing an index that does not exist
that being said I don't think you can make a 10K x 10K nested list in python,
use a numpy array instead