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: usizeMaximum number of iterations.
cut: f64Score improvement threshold (fraction of old score). C default is 0.0 (accept only strict improvements).
use_fft: boolWhether 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: f64Floor 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: boolUse 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.
TreeDependentIterationalternates direction: even cycles walkl = 0 .. locnjob-2, odd cycles walk it in reverse (tditeration.c:1641-1648).athreadhands outbranchtable[jobpos]forjobpos = 0 .. nbranch(:728-730), andbranchtableis the identity unlessrandomseed != 0shuffles it (:522, default seed 0) — so the ascending order is used in every cycle. - Convergence.
TreeDependentIterationchecksconverged >= locnjob * 2after every branch andgoto 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 printsConverged.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.
TreeDependentIterationcompares each branch’stscorewith the same branch’s score 2, 4, 6 … cycles earlier and exits immediately (:2345-2372).athreadhas two different checks, both of which stop at the end of the cycle: the worker compares the branch’stscorewith the same branch’s score in every earlier cycle<= iterate-2(step 1,:1217-1230) and raises*finishpt(Converged2.,:636-637); the collector compares thetscoreof the last accepted branch of the cycle (tscorelist[thread],:1184) with the same quantity from cycles1 .. iterate-1(Oscillating?,:609-619). - Skipped branches (
--skipiterate) are not aligned but still recordtscore = mscore(:1064-1067,:1234), so they take part in theConverged2.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
impl Clone for RefinementParams
Source§fn clone(&self) -> RefinementParams
fn clone(&self) -> RefinementParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RefinementParams
impl Debug for RefinementParams
Auto Trait Implementations§
impl Freeze for RefinementParams
impl RefUnwindSafe for RefinementParams
impl Send for RefinementParams
impl Sync for RefinementParams
impl Unpin for RefinementParams
impl UnsafeUnpin for RefinementParams
impl UnwindSafe for RefinementParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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