pyampact.alignmentUtils.dpcore

pyampact.alignmentUtils.dpcore(M, pen)[source]
Core dynamic programming calculation of best path.

M[r,c] is the array of local costs. Create D[r,c] as the array of costs-of-best-paths to r,c, and phi[r,c] as the indicator of the point preceding [r,c] to allow traceback; 0 = (r-1,c-1), 1 = (r,c-1), 2 = (r-1, c)

Parameters:
  • M (np.ndarray) – A 2D array of local costs, where M[r, c] represents the cost at position (r, c).

  • pen (float) – A penalty value applied for non-diagonal movements in the path.

Returns:

  • D (np.ndarray) – A 2D array of cumulative best costs to each point (r,c), starting from (0,0).

  • phi (np.ndarray) – A 2D array of integers used for traceback, where: - 0 indicates the previous point was (r-1, c-1). - 1 indicates the previous point was (r, c-1). - 2 indicates the previous point was (r-1, c).