Skip to content

Commit

Permalink
test: fix failing unit test
Browse files Browse the repository at this point in the history
The unit test `pads_missing_left()` is failing: https://github.com/nextstrain/nextclade/blob/cc9e817b2195ccc39c1094800857f512ed6ad82f/packages_rs/nextclade/src/align/score_matrix.rs#L241-L294
with this error:
https://github.com/nextstrain/nextclade/actions/runs/7477824073/job/20351461502?pr=1377#step:7:398
Probably due to retying on the previous default value of the "gap alignment side" parameter ("right").

So I decided to make 2 tests instead of this one:
 - `pads_missing_left()` using the default "left" value for  "gap alignment side"  now got the new expectations. I copied them from the actual result, so they need to be scientifically checked.
 - `pads_missing_left_with_alignment_gap_right()` retained previous expectations, but is now using "right" in the  "gap alignment side".

Both tests are passing, but the expectations for the `pads_missing_left()` need to be checked by hand.
  • Loading branch information
ivan-aksamentov committed Jan 12, 2024
1 parent cc9e817 commit f77cd51
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions packages_rs/nextclade/src/align/score_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,63 @@ mod tests {
],
);

#[rustfmt::skip]
let expected_paths = Band2d::<i8>::with_data(
&stripes,
&[
0, 10, 10, 10,
20, 1, 9, 9, 41,
20, 17, 17, 25, 9,
20, 1, 25, 1, 25, 34, 42,
20, 17, 1, 25, 4, 9, 2, 10,
20, 17, 25, 2, 25, 12, 9, 2,
20, 17, 4, 25, 18, 25, 12, 9,
20, 17, 25, 4, 17, 18, 26, 12,
52, 17, 4, 17, 18, 28,
52, 20, 20, 4, 17, 18,
20, 20, 20, 4, 1,
],
);

assert_eq!(expected_scores, result.scores);
assert_eq!(expected_paths, result.paths);

Ok(())
}

#[rstest]
fn pads_missing_left_with_alignment_gap_right(mut ctx: Context) -> Result<(), Report> {
let qry_seq = to_nuc_seq("CTCGCTG")?;
let ref_seq = to_nuc_seq("ACGCTCGCTG")?;

let band_width = 5;
let mean_shift = 2;

let mut stripes = simple_stripes(mean_shift, band_width, ref_seq.len(), qry_seq.len());
stripes[2].end = stripes[2].end - 1;
stripes[8].begin = stripes[8].begin + 1;

ctx.params.gap_alignment_side = GapAlignmentSide::Right;
let result = score_matrix(&qry_seq, &ref_seq, &ctx.gap_open_close, &stripes, &ctx.params);

#[rustfmt::skip]
let expected_scores = Band2d::<i32>::with_data(
&stripes,
&[
0, 0, 0, 0,
0, -1, -1, -1, -1,
0, 3, -2, 2, -2,
0, -1, 2, -3, 5, -1, -1,
0, 3, -2, 5, -1, 8, 2, 2,
0, -1, 6, 0, 4, 2, 11, 5,
0, 3, 0, 9, 3, 7, 5, 10,
0, -1, 2, 3, 12, 6, 6, 10,
0, 5, 6, 15, 9, 10,
0, 3, 6, 9, 18, 12,
3, 6, 9, 12, 21,
],
);

#[rustfmt::skip]
let expected_paths = Band2d::<i8>::with_data(
&stripes,
Expand All @@ -278,8 +335,8 @@ mod tests {
20, 17, 17, 25, 9,
20, 1, 25, 1, 25, 34, 42,
20, 17, 1, 25, 2, 9, 2, 10,
20, 17, 25, 2, 25, 12, 9, 2,
20, 17, 4, 25, 18, 25, 12, 9,
20, 17, 25, 2, 25, 12, 9, 2,
20, 17, 4, 25, 18, 25, 12, 9,
20, 17, 25, 4, 17, 18, 25, 12,
52, 17, 4, 17, 18, 28,
52, 20, 20, 4, 17, 18,
Expand Down

0 comments on commit f77cd51

Please sign in to comment.