Skip to main content

cyanea_align/
xdrop.rs

1//! X-drop and Z-drop seed extension alignment.
2//!
3//! Implements banded extension alignment with early termination for
4//! efficient seed-and-extend workflows. X-drop terminates when all
5//! active cells fall below `best - x_drop`. Z-drop tracks the best
6//! score per anti-diagonal and is more permissive.
7
8use cyanea_core::{CyaneaError, Result};
9
10use crate::scoring::ScoringScheme;
11use crate::types::{AlignmentResult, CigarOp};
12
13// ---------------------------------------------------------------------------
14// Parameters
15// ---------------------------------------------------------------------------
16
17/// Parameters for X-drop extension alignment.
18#[derive(Debug, Clone)]
19pub struct XDropParams {
20    /// Drop threshold: terminate when all active cells score < best - x_drop (default: 50).
21    pub x_drop: i32,
22    /// Maximum bandwidth around the diagonal (default: 100).
23    pub bandwidth: usize,
24}
25
26impl Default for XDropParams {
27    fn default() -> Self {
28        Self {
29            x_drop: 50,
30            bandwidth: 100,
31        }
32    }
33}
34
35/// Parameters for Z-drop extension alignment.
36#[derive(Debug, Clone)]
37pub struct ZDropParams {
38    /// Drop threshold per anti-diagonal (default: 200).
39    pub z_drop: i32,
40    /// Maximum bandwidth (default: 500).
41    pub bandwidth: usize,
42}
43
44impl Default for ZDropParams {
45    fn default() -> Self {
46        Self {
47            z_drop: 200,
48            bandwidth: 500,
49        }
50    }
51}
52
53/// Result of an extension alignment.
54#[derive(Debug, Clone)]
55pub struct ExtensionResult {
56    /// Best alignment score achieved.
57    pub score: i32,
58    /// Number of query bases consumed.
59    pub query_len: usize,
60    /// Number of target bases consumed.
61    pub target_len: usize,
62    /// CIGAR operations describing the alignment.
63    pub cigar: Vec<CigarOp>,
64    /// Whether the extension was terminated by the drop condition.
65    pub dropped: bool,
66}
67
68// ---------------------------------------------------------------------------
69// CIGAR helper
70// ---------------------------------------------------------------------------
71
72fn push_cigar(cigar: &mut Vec<CigarOp>, op: CigarOp) {
73    if let Some(last) = cigar.last_mut() {
74        match (last, &op) {
75            (CigarOp::Match(n), CigarOp::Match(m)) => {
76                *n += m;
77                return;
78            }
79            (CigarOp::Mismatch(n), CigarOp::Mismatch(m)) => {
80                *n += m;
81                return;
82            }
83            (CigarOp::Insertion(n), CigarOp::Insertion(m)) => {
84                *n += m;
85                return;
86            }
87            (CigarOp::Deletion(n), CigarOp::Deletion(m)) => {
88                *n += m;
89                return;
90            }
91            _ => {}
92        }
93    }
94    cigar.push(op);
95}
96
97// ---------------------------------------------------------------------------
98// Core DP engine
99// ---------------------------------------------------------------------------
100
101/// Drop mode: X-drop vs Z-drop
102enum DropMode {
103    XDrop(i32),
104    ZDrop(i32),
105}
106
107const NEG_INF: i32 = i32::MIN / 2;
108
109/// Core banded extension DP.
110///
111/// Extends from position (0,0) in the given query/target slices.
112/// Returns the extension result with traceback.
113fn extend_dp(
114    query: &[u8],
115    target: &[u8],
116    scoring: &ScoringScheme,
117    bandwidth: usize,
118    drop: DropMode,
119) -> ExtensionResult {
120    let m = query.len();
121    let n = target.len();
122
123    if m == 0 || n == 0 {
124        return ExtensionResult {
125            score: 0,
126            query_len: 0,
127            target_len: 0,
128            cigar: Vec::new(),
129            dropped: false,
130        };
131    }
132
133    let gap_open = scoring.gap_open();
134    let gap_extend = scoring.gap_extend();
135    let bw = bandwidth;
136
137    // DP with affine gaps: H (match), E (gap in target/insertion), F (gap in query/deletion)
138    // Use row-by-row storage, banded
139    // Traceback: 0=diag(match/mismatch), 1=left(insertion from E), 2=up(deletion from F)
140    // Store full matrix for traceback (bounded by bw)
141
142    // For simplicity with bandwidth, we store full rows but only compute within band
143    let cols = n + 1;
144    let rows = m + 1;
145
146    // Full DP (for correctness with traceback) — bounded by bandwidth
147    let mut h = vec![vec![NEG_INF; cols]; rows];
148    let mut e = vec![vec![NEG_INF; cols]; rows];
149    let mut f = vec![vec![NEG_INF; cols]; rows];
150    // Traceback: 0=diag, 1=ins(E), 2=del(F)
151    let mut tb = vec![vec![0u8; cols]; rows];
152
153    h[0][0] = 0;
154    // First row: gaps in target (deletions)
155    for j in 1..=n.min(bw) {
156        f[0][j] = gap_open + gap_extend * j as i32;
157        h[0][j] = f[0][j];
158        tb[0][j] = 2;
159    }
160    // First column: gaps in query (insertions)
161    for i in 1..=m.min(bw) {
162        e[i][0] = gap_open + gap_extend * i as i32;
163        h[i][0] = e[i][0];
164        tb[i][0] = 1;
165    }
166
167    let mut best_score = 0i32;
168    let mut best_i = 0usize;
169    let mut best_j = 0usize;
170    let mut dropped = false;
171
172    // For z-drop: track best score on each anti-diagonal
173    let max_ad = m + n;
174    let mut best_per_ad = vec![NEG_INF; max_ad + 1];
175    best_per_ad[0] = 0;
176
177    for i in 1..=m {
178        let j_center = i; // diagonal
179        let j_lo = if j_center > bw { j_center - bw } else { 1 };
180        let j_hi = (j_center + bw).min(n);
181
182        let mut row_max = NEG_INF;
183
184        for j in j_lo..=j_hi {
185            // E: insertion (gap in target, consumes query)
186            let e_open = h[i - 1][j].saturating_add(gap_open + gap_extend);
187            let e_ext = e[i - 1][j].saturating_add(gap_extend);
188            e[i][j] = e_open.max(e_ext);
189
190            // F: deletion (gap in query, consumes target)
191            let f_open = h[i][j - 1].saturating_add(gap_open + gap_extend);
192            let f_ext = f[i][j - 1].saturating_add(gap_extend);
193            f[i][j] = f_open.max(f_ext);
194
195            // H: match/mismatch
196            let sub = scoring.score_pair(query[i - 1], target[j - 1]);
197            let diag = h[i - 1][j - 1].saturating_add(sub);
198
199            let h_val = diag.max(e[i][j]).max(f[i][j]);
200            h[i][j] = h_val;
201
202            if h_val == diag {
203                tb[i][j] = 0;
204            } else if h_val == e[i][j] {
205                tb[i][j] = 1;
206            } else {
207                tb[i][j] = 2;
208            }
209
210            row_max = row_max.max(h_val);
211
212            if h_val > best_score {
213                best_score = h_val;
214                best_i = i;
215                best_j = j;
216            }
217
218            let ad = i + j;
219            if ad <= max_ad {
220                best_per_ad[ad] = best_per_ad[ad].max(h_val);
221            }
222        }
223
224        // Check drop condition
225        match drop {
226            DropMode::XDrop(x) => {
227                if row_max < best_score - x {
228                    dropped = true;
229                    break;
230                }
231            }
232            DropMode::ZDrop(z) => {
233                let ad = i + (i.min(n)); // current anti-diagonal
234                if ad <= max_ad && best_score - best_per_ad[ad] > z {
235                    dropped = true;
236                    break;
237                }
238            }
239        }
240    }
241
242    // Traceback from (best_i, best_j)
243    let mut cigar = Vec::new();
244    let mut ci = best_i;
245    let mut cj = best_j;
246
247    while ci > 0 && cj > 0 {
248        match tb[ci][cj] {
249            0 => {
250                // diagonal
251                let op =
252                    if query[ci - 1].to_ascii_uppercase() == target[cj - 1].to_ascii_uppercase() {
253                        CigarOp::Match(1)
254                    } else {
255                        CigarOp::Mismatch(1)
256                    };
257                push_cigar(&mut cigar, op);
258                ci -= 1;
259                cj -= 1;
260            }
261            1 => {
262                // insertion (gap in target)
263                push_cigar(&mut cigar, CigarOp::Insertion(1));
264                ci -= 1;
265            }
266            2 => {
267                // deletion (gap in query)
268                push_cigar(&mut cigar, CigarOp::Deletion(1));
269                cj -= 1;
270            }
271            _ => break,
272        }
273    }
274
275    // Handle remaining bases at start
276    while ci > 0 {
277        push_cigar(&mut cigar, CigarOp::Insertion(1));
278        ci -= 1;
279    }
280    while cj > 0 {
281        push_cigar(&mut cigar, CigarOp::Deletion(1));
282        cj -= 1;
283    }
284
285    cigar.reverse();
286
287    ExtensionResult {
288        score: best_score,
289        query_len: best_i,
290        target_len: best_j,
291        cigar,
292        dropped,
293    }
294}
295
296// ---------------------------------------------------------------------------
297// X-drop public API
298// ---------------------------------------------------------------------------
299
300/// Extend alignment to the right using X-drop.
301///
302/// Aligns `query` against `target` starting from position 0, terminating
303/// when all active cells fall below `best_score - x_drop`.
304///
305/// # Errors
306///
307/// Returns an error if either sequence is empty.
308pub fn xdrop_extend_right(
309    query: &[u8],
310    target: &[u8],
311    scoring: &ScoringScheme,
312    params: &XDropParams,
313) -> Result<ExtensionResult> {
314    if query.is_empty() || target.is_empty() {
315        return Err(CyaneaError::InvalidInput(
316            "query and target must be non-empty".into(),
317        ));
318    }
319    Ok(extend_dp(
320        query,
321        target,
322        scoring,
323        params.bandwidth,
324        DropMode::XDrop(params.x_drop),
325    ))
326}
327
328/// Extend alignment to the left using X-drop.
329///
330/// Reverses both sequences, runs forward extension, then reverses the CIGAR.
331///
332/// # Errors
333///
334/// Returns an error if either sequence is empty.
335pub fn xdrop_extend_left(
336    query: &[u8],
337    target: &[u8],
338    scoring: &ScoringScheme,
339    params: &XDropParams,
340) -> Result<ExtensionResult> {
341    if query.is_empty() || target.is_empty() {
342        return Err(CyaneaError::InvalidInput(
343            "query and target must be non-empty".into(),
344        ));
345    }
346    let rev_q: Vec<u8> = query.iter().rev().copied().collect();
347    let rev_t: Vec<u8> = target.iter().rev().copied().collect();
348    let mut result = extend_dp(
349        &rev_q,
350        &rev_t,
351        scoring,
352        params.bandwidth,
353        DropMode::XDrop(params.x_drop),
354    );
355    result.cigar.reverse();
356    Ok(result)
357}
358
359/// Seed-and-extend alignment using X-drop.
360///
361/// Given a seed match at `(query_pos, target_pos)` of length `seed_len`,
362/// extends left and right, combines into a full alignment result.
363///
364/// # Errors
365///
366/// Returns an error if positions are out of bounds.
367pub fn xdrop_seed_extend(
368    query: &[u8],
369    target: &[u8],
370    query_pos: usize,
371    target_pos: usize,
372    seed_len: usize,
373    scoring: &ScoringScheme,
374    params: &XDropParams,
375) -> Result<AlignmentResult> {
376    seed_extend_impl(
377        query,
378        target,
379        query_pos,
380        target_pos,
381        seed_len,
382        scoring,
383        params.bandwidth,
384        DropMode::XDrop(params.x_drop),
385    )
386}
387
388// ---------------------------------------------------------------------------
389// Z-drop public API
390// ---------------------------------------------------------------------------
391
392/// Extend alignment to the right using Z-drop.
393///
394/// Z-drop tracks the best score per anti-diagonal and is more permissive
395/// than X-drop, allowing brief score dips.
396///
397/// # Errors
398///
399/// Returns an error if either sequence is empty.
400pub fn zdrop_extend_right(
401    query: &[u8],
402    target: &[u8],
403    scoring: &ScoringScheme,
404    params: &ZDropParams,
405) -> Result<ExtensionResult> {
406    if query.is_empty() || target.is_empty() {
407        return Err(CyaneaError::InvalidInput(
408            "query and target must be non-empty".into(),
409        ));
410    }
411    Ok(extend_dp(
412        query,
413        target,
414        scoring,
415        params.bandwidth,
416        DropMode::ZDrop(params.z_drop),
417    ))
418}
419
420/// Extend alignment to the left using Z-drop.
421///
422/// # Errors
423///
424/// Returns an error if either sequence is empty.
425pub fn zdrop_extend_left(
426    query: &[u8],
427    target: &[u8],
428    scoring: &ScoringScheme,
429    params: &ZDropParams,
430) -> Result<ExtensionResult> {
431    if query.is_empty() || target.is_empty() {
432        return Err(CyaneaError::InvalidInput(
433            "query and target must be non-empty".into(),
434        ));
435    }
436    let rev_q: Vec<u8> = query.iter().rev().copied().collect();
437    let rev_t: Vec<u8> = target.iter().rev().copied().collect();
438    let mut result = extend_dp(
439        &rev_q,
440        &rev_t,
441        scoring,
442        params.bandwidth,
443        DropMode::ZDrop(params.z_drop),
444    );
445    result.cigar.reverse();
446    Ok(result)
447}
448
449/// Seed-and-extend alignment using Z-drop.
450///
451/// # Errors
452///
453/// Returns an error if positions are out of bounds.
454pub fn zdrop_seed_extend(
455    query: &[u8],
456    target: &[u8],
457    query_pos: usize,
458    target_pos: usize,
459    seed_len: usize,
460    scoring: &ScoringScheme,
461    params: &ZDropParams,
462) -> Result<AlignmentResult> {
463    seed_extend_impl(
464        query,
465        target,
466        query_pos,
467        target_pos,
468        seed_len,
469        scoring,
470        params.bandwidth,
471        DropMode::ZDrop(params.z_drop),
472    )
473}
474
475// ---------------------------------------------------------------------------
476// Shared seed-extend
477// ---------------------------------------------------------------------------
478
479fn seed_extend_impl(
480    query: &[u8],
481    target: &[u8],
482    query_pos: usize,
483    target_pos: usize,
484    seed_len: usize,
485    scoring: &ScoringScheme,
486    bandwidth: usize,
487    drop: DropMode,
488) -> Result<AlignmentResult> {
489    if query_pos + seed_len > query.len() || target_pos + seed_len > target.len() {
490        return Err(CyaneaError::InvalidInput(
491            "seed position + length exceeds sequence bounds".into(),
492        ));
493    }
494
495    // Score the seed
496    let mut seed_score = 0i32;
497    let mut seed_cigar = Vec::new();
498    for k in 0..seed_len {
499        let s = scoring.score_pair(query[query_pos + k], target[target_pos + k]);
500        seed_score += s;
501        let op = if query[query_pos + k].to_ascii_uppercase()
502            == target[target_pos + k].to_ascii_uppercase()
503        {
504            CigarOp::Match(1)
505        } else {
506            CigarOp::Mismatch(1)
507        };
508        push_cigar(&mut seed_cigar, op);
509    }
510
511    // Extend left
512    let left = if query_pos > 0 && target_pos > 0 {
513        let lq: Vec<u8> = query[..query_pos].iter().rev().copied().collect();
514        let lt: Vec<u8> = target[..target_pos].iter().rev().copied().collect();
515        let drop_left = match &drop {
516            DropMode::XDrop(x) => DropMode::XDrop(*x),
517            DropMode::ZDrop(z) => DropMode::ZDrop(*z),
518        };
519        let mut r = extend_dp(&lq, &lt, scoring, bandwidth, drop_left);
520        r.cigar.reverse();
521        r
522    } else {
523        ExtensionResult {
524            score: 0,
525            query_len: 0,
526            target_len: 0,
527            cigar: Vec::new(),
528            dropped: false,
529        }
530    };
531
532    // Extend right
533    let right_q_start = query_pos + seed_len;
534    let right_t_start = target_pos + seed_len;
535    let right = if right_q_start < query.len() && right_t_start < target.len() {
536        let drop_right = match &drop {
537            DropMode::XDrop(x) => DropMode::XDrop(*x),
538            DropMode::ZDrop(z) => DropMode::ZDrop(*z),
539        };
540        extend_dp(
541            &query[right_q_start..],
542            &target[right_t_start..],
543            scoring,
544            bandwidth,
545            drop_right,
546        )
547    } else {
548        ExtensionResult {
549            score: 0,
550            query_len: 0,
551            target_len: 0,
552            cigar: Vec::new(),
553            dropped: false,
554        }
555    };
556
557    // Combine
558    let total_score = left.score + seed_score + right.score;
559    let q_start = query_pos - left.query_len;
560    let q_end = query_pos + seed_len + right.query_len;
561    let t_start = target_pos - left.target_len;
562    let t_end = target_pos + seed_len + right.target_len;
563
564    let mut combined_cigar = left.cigar;
565    for op in seed_cigar {
566        push_cigar(&mut combined_cigar, op);
567    }
568    for op in right.cigar {
569        push_cigar(&mut combined_cigar, op);
570    }
571
572    // Build aligned sequences
573    let mut aligned_query = Vec::new();
574    let mut aligned_target = Vec::new();
575    let mut qi = q_start;
576    let mut ti = t_start;
577
578    for op in &combined_cigar {
579        match op {
580            CigarOp::Match(n) | CigarOp::Mismatch(n) => {
581                for _ in 0..*n {
582                    aligned_query.push(query[qi]);
583                    aligned_target.push(target[ti]);
584                    qi += 1;
585                    ti += 1;
586                }
587            }
588            CigarOp::Insertion(n) => {
589                for _ in 0..*n {
590                    aligned_query.push(query[qi]);
591                    aligned_target.push(b'-');
592                    qi += 1;
593                }
594            }
595            CigarOp::Deletion(n) => {
596                for _ in 0..*n {
597                    aligned_query.push(b'-');
598                    aligned_target.push(target[ti]);
599                    ti += 1;
600                }
601            }
602            _ => {}
603        }
604    }
605
606    Ok(AlignmentResult {
607        score: total_score,
608        aligned_query,
609        aligned_target,
610        query_start: q_start,
611        query_end: q_end,
612        target_start: t_start,
613        target_end: t_end,
614        cigar: combined_cigar,
615    })
616}
617
618// ---------------------------------------------------------------------------
619// Tests
620// ---------------------------------------------------------------------------
621
622#[cfg(test)]
623mod tests {
624    use super::*;
625    use crate::scoring::ScoringMatrix;
626
627    fn dna_scheme() -> ScoringScheme {
628        ScoringScheme::Simple(ScoringMatrix::dna_default())
629    }
630
631    #[test]
632    fn identical_sequences() {
633        let result = xdrop_extend_right(
634            b"ACGTACGT",
635            b"ACGTACGT",
636            &dna_scheme(),
637            &XDropParams::default(),
638        )
639        .unwrap();
640        assert_eq!(result.score, 16); // 8 matches * 2
641        assert_eq!(result.query_len, 8);
642        assert_eq!(result.target_len, 8);
643        assert!(!result.dropped);
644    }
645
646    #[test]
647    fn early_termination() {
648        // Good match followed by many mismatches
649        let query = b"ACGTACGTTTTTTTTTTTTTTTTTTT";
650        let target = b"ACGTACGTAAAAAAAAAAAAAAAAAAA";
651        let params = XDropParams {
652            x_drop: 10,
653            bandwidth: 100,
654        };
655        let result = xdrop_extend_right(query, target, &dna_scheme(), &params).unwrap();
656        // Should terminate before reaching the end
657        assert!(result.dropped || result.query_len < query.len());
658    }
659
660    #[test]
661    fn matches_sw_for_short() {
662        // For short identical sequences, should match SW
663        let result =
664            xdrop_extend_right(b"ACGT", b"ACGT", &dna_scheme(), &XDropParams::default()).unwrap();
665        assert_eq!(result.score, 8); // 4 * 2
666    }
667
668    #[test]
669    fn empty_error() {
670        let result = xdrop_extend_right(b"", b"ACGT", &dna_scheme(), &XDropParams::default());
671        assert!(result.is_err());
672        let result = xdrop_extend_right(b"ACGT", b"", &dna_scheme(), &XDropParams::default());
673        assert!(result.is_err());
674    }
675
676    #[test]
677    fn single_base() {
678        let result =
679            xdrop_extend_right(b"A", b"A", &dna_scheme(), &XDropParams::default()).unwrap();
680        assert_eq!(result.score, 2);
681        assert_eq!(result.query_len, 1);
682    }
683
684    #[test]
685    fn left_extension_reversal() {
686        let result = xdrop_extend_left(
687            b"ACGTACGT",
688            b"ACGTACGT",
689            &dna_scheme(),
690            &XDropParams::default(),
691        )
692        .unwrap();
693        assert_eq!(result.score, 16);
694        assert_eq!(result.query_len, 8);
695    }
696
697    #[test]
698    fn seed_extend_combine() {
699        let query = b"AAAACGTACGTAAAA";
700        let target = b"AAAACGTACGTAAAA";
701        let result = xdrop_seed_extend(
702            query,
703            target,
704            4,
705            4,
706            7,
707            &dna_scheme(),
708            &XDropParams::default(),
709        )
710        .unwrap();
711        assert_eq!(result.score, 30); // 15 * 2
712        assert_eq!(result.query_start, 0);
713        assert_eq!(result.query_end, 15);
714    }
715
716    #[test]
717    fn seed_extend_out_of_bounds() {
718        let result = xdrop_seed_extend(
719            b"ACGT",
720            b"ACGT",
721            3,
722            3,
723            5,
724            &dna_scheme(),
725            &XDropParams::default(),
726        );
727        assert!(result.is_err());
728    }
729
730    #[test]
731    fn zdrop_extend() {
732        let result = zdrop_extend_right(
733            b"ACGTACGT",
734            b"ACGTACGT",
735            &dna_scheme(),
736            &ZDropParams::default(),
737        )
738        .unwrap();
739        assert_eq!(result.score, 16);
740        assert!(!result.dropped);
741    }
742
743    #[test]
744    fn zdrop_more_permissive() {
745        // Z-drop should extend further than X-drop for same threshold
746        let query = b"ACGTACGTTTACGTACGT";
747        let target = b"ACGTACGTAAACGTACGT";
748        let x_params = XDropParams {
749            x_drop: 5,
750            bandwidth: 100,
751        };
752        let z_params = ZDropParams {
753            z_drop: 5,
754            bandwidth: 100,
755        };
756        let x_result = xdrop_extend_right(query, target, &dna_scheme(), &x_params).unwrap();
757        let z_result = zdrop_extend_right(query, target, &dna_scheme(), &z_params).unwrap();
758        // Z-drop should generally score at least as well
759        assert!(
760            z_result.score >= x_result.score,
761            "z_drop score {} should be >= x_drop score {}",
762            z_result.score,
763            x_result.score
764        );
765    }
766
767    #[test]
768    fn zdrop_seed_extend_combine() {
769        let query = b"AAAACGTACGTAAAA";
770        let target = b"AAAACGTACGTAAAA";
771        let result = super::zdrop_seed_extend(
772            query,
773            target,
774            4,
775            4,
776            7,
777            &dna_scheme(),
778            &ZDropParams::default(),
779        )
780        .unwrap();
781        assert_eq!(result.score, 30);
782    }
783
784    #[test]
785    fn dropped_flag_set() {
786        let query = b"ACGTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";
787        let target = b"ACGTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
788        let params = XDropParams {
789            x_drop: 5,
790            bandwidth: 100,
791        };
792        let result = xdrop_extend_right(query, target, &dna_scheme(), &params).unwrap();
793        assert!(result.dropped, "should have dropped");
794    }
795}
796
797#[cfg(test)]
798mod proptests {
799    use super::*;
800    use crate::scoring::ScoringMatrix;
801    use proptest::prelude::*;
802
803    fn dna_scheme() -> ScoringScheme {
804        ScoringScheme::Simple(ScoringMatrix::dna_default())
805    }
806
807    fn dna_seq(max_len: usize) -> impl Strategy<Value = Vec<u8>> {
808        proptest::collection::vec(
809            prop_oneof![Just(b'A'), Just(b'C'), Just(b'G'), Just(b'T')],
810            1..=max_len,
811        )
812    }
813
814    proptest! {
815        #[test]
816        fn xdrop_deterministic(q in dna_seq(30), t in dna_seq(30)) {
817            let r1 = xdrop_extend_right(&q, &t, &dna_scheme(), &XDropParams::default()).unwrap();
818            let r2 = xdrop_extend_right(&q, &t, &dna_scheme(), &XDropParams::default()).unwrap();
819            prop_assert_eq!(r1.score, r2.score);
820        }
821    }
822}