Skip to content

Commit

Permalink
feat: better error message when barcode length differs from expected
Browse files Browse the repository at this point in the history
 - fixes #31, error message is now more clear
  • Loading branch information
TimD1 committed Jul 9, 2024
1 parent 6ed98a3 commit 3392552
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bin/commands/demux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ pub(crate) struct Demux {

/// The read structure types to write to their own files (Must be one of T, B, or M for
/// template reads, sample barcode reads, and molecular barcode reads).
///
///
/// Multiple output types may be specified as a space-delimited list.
#[clap(long, short='b', default_value="T", num_args = 1.. )]
output_types: Vec<char>,
Expand Down
8 changes: 5 additions & 3 deletions src/lib/barcode_matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const STARTING_CACHE_SIZE: usize = 1_000_000;
/// The struct that contains the info related to the best and next best sample barcode match.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct BarcodeMatch {
/// Index of the best bardcode match in the corresponding BarcodeMatcher struct that generated
/// Index of the best barcode match in the corresponding BarcodeMatcher struct that generated
/// this match.
pub best_match: usize,
/// The number of mismatches to the best matching barcode for the read described by this match.
Expand Down Expand Up @@ -74,7 +74,7 @@ impl BarcodeMatcher {
assert_eq!(
observed_bases.len(),
expected_bases.len(),
"observed_bases: {}, expected_bases: {}",
"Sample barcode length ({}) differs from expected ({}) during barcode matching",
observed_bases.len(),
expected_bases.len()
);
Expand Down Expand Up @@ -223,7 +223,9 @@ mod tests {
}

#[test]
#[should_panic(expected = "observed_bases: 5, expected_bases: 6")]
#[should_panic(
expected = "Sample barcode length (5) differs from expected (6) during barcode matching"
)]
fn find_compare_two_sequences_of_different_length() {
let _mismatches = BarcodeMatcher::count_mismatches("GATTA".as_bytes(), "CTATGT".as_bytes());
}
Expand Down

0 comments on commit 3392552

Please sign in to comment.