Skip to main content

RefinementParams

Struct RefinementParams 

Source
pub struct RefinementParams {
    pub max_iterations: usize,
    pub cut: f64,
    pub use_fft: bool,
    pub legacy_gap_cost: bool,
    pub shift: Option<f64>,
    pub unalign_level: f64,
    pub minimum_weight: f64,
    pub bestfirst: bool,
    pub skip_branches: Vec<(bool, bool)>,
    pub per_cycle_convergence: bool,
}
Expand description

Parameters controlling iterative refinement.

Fields§

§max_iterations: usize

Maximum number of iterations.

§cut: f64

Score improvement threshold (fraction of old score). C default is 0.0 (accept only strict improvements).

§use_fft: bool

Whether to use FFT-accelerated alignment during refinement.

§legacy_gap_cost: bool

--leavegappyregion / --legacygappenalty — propagated into the inner GapModel so the profile DP treats every column as fully nongap (legacygapcost = 1, Salignmm.c:1604-1610).

§shift: Option<f64>

--allowshift warp/shift penalty for the refinement DP. C’s dvtditr receives -Q 2.0 → penalty_shift_factor = 2.0 (< 10) → trywarp = 1, so the warp DP fires in refinement with penalty_shift = 2.0 * penalty. None = no warp (default).

§unalign_level: f64

--allowshift specificityconsideration (C dvtditr -s 0.8). When > 0, each refinement branch scores sequence pairs with distance-binned matrices (the _variousdist multi-matrix DP). 0.0 = disabled (single matrix).

§minimum_weight: f64

Floor for per-sequence weights in the intergroup-score accumulation. Mirrors C’s tbfast -W $minimumweight (scripts/mafft:1029 / default 0.00001). Sequences with weight below this floor get clamped up. Set to the C default if not otherwise overridden by --minimumweight.

§bestfirst: bool

--bestfirst parallelisation strategy. C MAFFT’s BAATARI2 (default) walks each branch sequentially in topology order and accepts improvements immediately. BESTFIRST evaluates all branches against the same baseline alignment, picks the one with the largest gain, applies it, repeats. C’s BESTFIRST is deterministic across thread counts (verified –thread 1, 4, 8 produce byte-identical output) — threads only parallelise the per-branch evaluation.

§skip_branches: Vec<(bool, bool)>

Per-(step, side) skip flags for --skipiterate F small-F mode. skip_branches[step_idx] is (skip_left, skip_right) — when a side is true, that branch’s realign attempt is skipped entirely (mirrors C dvtditr.c:999/1004’s skipthisbranch[j][k] = 1). Empty = no skips (default refinement). Populated by the caller from mafft_tree::generate_subalignments_table output.

§per_cycle_convergence: bool

Use C’s athread refinement rules instead of the single-threaded TreeDependentIteration ones.

C picks the refinement implementation on nthread > 0 (tditeration.c:1433). With one worker thread athread is fully deterministic, but it walks the tree and stops by different rules than the single-threaded loop, and every one of them is modelled here:

  • Branch order. TreeDependentIteration alternates direction: even cycles walk l = 0 .. locnjob-2, odd cycles walk it in reverse (tditeration.c:1641-1648). athread hands out branchtable[jobpos] for jobpos = 0 .. nbranch (:728-730), and branchtable is the identity unless randomseed != 0 shuffles it (:522, default seed 0) — so the ascending order is used in every cycle.
  • Convergence. TreeDependentIteration checks converged >= locnjob * 2 after every branch and goto ends immediately, mid-cycle (:2328-2342). athread’s collector checks once per cycle whether any branch gained (maxgain > 0.0, :590); if none did it prints Converged. and sets *collectingpt = -1, which only takes effect at the top of the next cycle (:527-551), so the converging cycle always runs to completion.
  • Oscillation. TreeDependentIteration compares each branch’s tscore with the same branch’s score 2, 4, 6 … cycles earlier and exits immediately (:2345-2372). athread has two different checks, both of which stop at the end of the cycle: the worker compares the branch’s tscore with the same branch’s score in every earlier cycle <= iterate-2 (step 1, :1217-1230) and raises *finishpt (Converged2., :636-637); the collector compares the tscore of the last accepted branch of the cycle (tscorelist[thread], :1184) with the same quantity from cycles 1 .. iterate-1 (Oscillating?, :609-619).
  • Skipped branches (--skipiterate) are not aligned but still record tscore = mscore (:1064-1067, :1234), so they take part in the Converged2. check.

The convergence difference is visible in C’s own output: at maxiterate 2, 22 of 85 segments print Converged. alone (converged in cycle 0, so cycle 1 never starts), 56 print Converged. and Reached 2 (converged in the last cycle, so the loop ended normally), and 7 print Reached 2 alone. The order difference is what separated --thread 1 from C on mtb_cds_120x1400.fa by one gap column in one sequence (s97).

Trait Implementations§

Source§

impl Clone for RefinementParams

Source§

fn clone(&self) -> RefinementParams

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 Debug for RefinementParams

Source§

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

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

impl Default for RefinementParams

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.