A Python implementation of the global sequence-alignment algorithm that optimizes DNA / protein alignments with dynamic programming. Supports custom scoring matrices (e.g. BLOSUM 62) or simple match/mismatch schemes, calculates detailed statistics, and exports publication-ready alignments.
The algorithm fills an O(mn) scoring matrix cell by cell. Each cell depends only on its top, left, and top-left neighbors, and the algorithm then traces back from the bottom-right corner to reconstruct the optimal alignment path.
The matrix fills in anti-diagonal wavefronts (the only order that respects each cell's dependencies), then the traceback path lights up from bottom-right to top-left.
O(mn) time/space Needleman-Wunsch matrix with traceback.
Imports any text-matrix (BLOSUM, PAM, DNA identity) or simple match/mismatch values.
Alignment blocks wrapped at 80 chars, plus score, matches, mismatches, gaps & similarity %.