I need to solve the follow problem withing O(nm).
n = |T|
m = |P|
where T,P two strings
f is a scoring function.
the algorithm should return a substring T’ of T such that score(P,T’) value is the maximum.
score(A,B) is the max val for alignment A and B according f.
I know I can get it from DIST matrix which is a Monge matrix if f is discrete (meaning the diagonals of the matrix has weights not larger than C which is a constant, and the horizontal and vertical edges is 0 or some other constant), but in this case the f is a general function from (sigma * {-})x(sigma * {-}) to R (where ‘-‘ is a gap).
any ideas?
You’ve noticed that there are several algorithms that compute a shortest path in a graph whose arcs are (i, j) → (i + 1, j), (i + 1, j + 1), (i, j + 1). The most general form of this algorithm would allow every arc length to be specified separately, with the following meanings.
Costs can be negative. To solve your substring problem, make the costs of all of the (i, j) → (i, j + 1) arcs zero so that we can delete from T without penalty.