Files
obitools4/autodoc/docmd/pkg/obialign/backtracking.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

1.5 KiB
Raw Blame History

Semantic Description of obialign Backtracking Module

The _Backtracking function implements a traceback algorithm for sequence alignment, reconstructing the optimal path through an alignment matrix.

Core Functionality

  • Input:

    • pathMatrix: Encodes alignment decisions (match/mismatch/gap) as integers.
    • lseqA, lseqB: Lengths of sequences A and B.
    • path: Pre-allocated slice to store the traceback path.
  • Output: A compact representation of alignment steps, alternating between:

    • Diagonal moves (ldiag): Matches/mismatches (one step in both sequences).
    • Horizontal/vertical moves (lleft or lup): Gaps in sequence B (horizontal) or A (vertical).

Algorithm Highlights

  • Reverse traversal from (lseqA1, lseqB1) to origin.
  • Batching logic: Consecutive gaps in same direction are aggregated (e.g., lleft += step) to compress run-length encoding.
  • Path reconstruction: Steps are pushed backwards into the path slice using a moving pointer p.
  • Memory efficiency: Uses slices.Grow() to preallocate space and logs resizing for debugging.

Encoded Path Semantics

Each pair in the returned slice encodes:

  • [diag_count, move_type], where move_type is either a gap length (lleft > 0: horizontal, or lup < 0: vertical) or zero (end of diagonal run).

Use Case

Enables efficient reconstruction and serialization of alignment paths—ideal for tools requiring low-level control over dynamic programming backtracking (e.g., pairwise aligners, edit-distance decompositions).