Skip to main content

align

Function align 

Source
pub fn align(
    a: &[Step],
    b: &[Step],
    cost_model: &impl CostModel,
    params: &AlignParams,
) -> Result<Vec<Move>, ParamError>
Expand description

Globally align reference a against observed b, minimizing total cost.

Returns the full move-typed alignment in run order. Every step of a appears exactly once across sync/model moves and every step of b exactly once across sync/log moves, both in increasing index order.

Move fields: a sync move’s cost is the cost-model value for the pair and its confidence is 1 - cost (the similarity itself). A gap move’s cost is the gap penalty it actually paid (open or extend), and its confidence is the minimum cost between the gapped step and any step on the other side — “even the closest counterpart looks this different” — or 1.0 when the other side is empty.

§Errors

ParamError::StepsExceedMax when either side is longer than AlignParams::max_steps — refused here, in the engine itself, so no boundary can forget the guard and walk into the O(n·m) allocation below.