Skip to main content

Scoring

Struct Scoring 

Source
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: e is overwritten with g (gap cost is g per base, extend == open).
  • GapMode::Affine: q is overwritten with g and c with e (the second affine layer collapses onto the first).
  • GapMode::Convex: all four gap fields are left as supplied.

Fields§

§m: i8

Match score (spoa’s m_).

§n: i8

Mismatch score (spoa’s n_).

§g: i8

First gap-open penalty (spoa’s g_).

§e: i8

First gap-extend penalty (spoa’s e_); normalized to equal g under GapMode::Linear.

§q: i8

Second (convex) gap-open penalty (spoa’s q_); normalized to equal g under GapMode::Affine.

§c: i8

Second (convex) gap-extend penalty (spoa’s c_); normalized to equal e under GapMode::Affine.

Implementations§

Source§

impl Scoring

Source

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).

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Scoring

Source§

fn clone(&self) -> Scoring

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Scoring

Source§

impl Debug for Scoring

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Scoring

Source§

impl PartialEq for Scoring

Source§

fn eq(&self, other: &Scoring) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Scoring

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.