pub struct Scoring {
pub m: i8,
pub n: i8,
pub g: i8,
pub e: i8,
pub q: i8,
pub c: i8,
}Expand description
Validated, normalized match/mismatch/gap scoring penalties.
Mirrors the m_, n_, g_, e_, q_, c_ fields threaded through spoa::AlignmentEngine::Create
(alignment_engine.cpp:32-72): m = match score, n = mismatch score, g/e = first
gap-open/gap-extend penalty, q/c = second (convex) gap-open/gap-extend penalty.
Scoring::new validates the non-positive-penalty invariants
(alignment_engine.cpp:46-55) and then normalizes e/q/c per the gap mode
(alignment_engine.cpp:61-66), so that every downstream reader of a Scoring value (in
particular the DP fill in later tasks) can use e/q/c directly without re-deriving the
gap mode first:
GapMode::Linear:eis overwritten withg(gap cost isgper base, extend == open).GapMode::Affine:qis overwritten withgandcwithe(the second affine layer collapses onto the first).GapMode::Convex: all four gap fields are left as supplied.
Fields§
§m: i8Match score (spoa’s m_).
n: i8Mismatch score (spoa’s n_).
g: i8First gap-open penalty (spoa’s g_).
e: i8First gap-extend penalty (spoa’s e_); normalized to equal g under
GapMode::Linear.
q: i8Second (convex) gap-open penalty (spoa’s q_); normalized to equal g under
GapMode::Affine.
c: i8Second (convex) gap-extend penalty (spoa’s c_); normalized to equal e under
GapMode::Affine.
Implementations§
Source§impl Scoring
impl Scoring
Sourcepub fn new(
m: i8,
n: i8,
g: i8,
e: i8,
q: i8,
c: i8,
) -> Result<Scoring, ScoringError>
pub fn new( m: i8, n: i8, g: i8, e: i8, q: i8, c: i8, ) -> Result<Scoring, ScoringError>
Validates and normalizes (m, n, g, e, q, c) into a Scoring.
Mirrors spoa::AlignmentEngine::Create(type, m, n, g, e, q, c)
(alignment_engine.cpp:32-72), minus the type/AlignmentType validation (that lives on
AlignmentType itself in this port, which is a closed Rust enum and so cannot hold an
invalid discriminant).
§Errors
Returns ScoringError::GapOpenPositive if g > 0 || q > 0, or
ScoringError::GapExtendPositive if e > 0 || c > 0 (alignment_engine.cpp:46-55).
Sourcepub fn spoa_default() -> Scoring
pub fn spoa_default() -> Scoring
The spoa/CLI default scoring: m=5, n=-4, g=-8, e=-6, q=-10, c=-4 (a GapMode::Convex
model). A named preset so callers need not hardcode the magic numbers.
Sourcepub fn gap_mode(&self) -> GapMode
pub fn gap_mode(&self) -> GapMode
Returns this scoring’s GapMode.
Re-derives the classification from self’s (already-normalized) fields via
Scoring::classify. This is safe because normalization is a fixed point of
classification: e.g. under GapMode::Linear normalization sets e = g, and
classify(g, g, q, c) still evaluates g >= e (now g >= g) as true, so it still
returns GapMode::Linear; the same holds for GapMode::Affine’s q = g, c = e
normalization and GapMode::Convex’s no-op normalization.
Sourcepub fn worst_case_alignment_score(&self, i: i64, j: i64) -> i64
pub fn worst_case_alignment_score(&self, i: i64, j: i64) -> i64
The worst-case (most negative) score reachable when aligning a length-i sequence
against a length-j graph path, used as an i32 DP-cell overflow guard.
Ports spoa::AlignmentEngine::WorstCaseAlignmentScore (alignment_engine.cpp:101-110)
EXACTLY, including its local gap_score closure. Computed in i64 (matching upstream’s
std::int64_t) to safely evaluate the products before the caller compares the result
against NEG_INF cast up to i64.