Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Dec 11, 2024
1 parent 6835aec commit 9612b64
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
21 changes: 14 additions & 7 deletions src/lib/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::ops::Range;
use crate::color::{color_background, color_head};
use crate::color::{COLOR_BACKGROUND, COLOR_BASES, COLOR_QUALS};
use crate::reverse_complement;
use crate::DNA_BASES;
use crate::AMINO_ACIDS;
use crate::DNA_BASES;
use anyhow::{bail, Context, Result};
use bstr::ByteSlice;
use regex::bytes::{Regex, RegexBuilder, RegexSet, RegexSetBuilder};
Expand Down Expand Up @@ -622,20 +622,27 @@ pub mod tests {
#[rstest]
#[case("AGTGTGATG", false)]
#[case("QRNQRNQRN", true)]
fn test_validate_fixed_pattern_is_ok(
#[case] pattern: &str,
#[case] protein: bool) {
fn test_validate_fixed_pattern_is_ok(#[case] pattern: &str, #[case] protein: bool) {
let result = validate_fixed_pattern(&pattern, protein);
assert!(result.is_ok())
}

#[rstest]
#[case("AXGTGTGATG", false, "Fixed pattern must contain only DNA bases: A .. [X] .. GTGTGATG")]
#[case("QRNQRNZQRN", true, "Fixed pattern must contain only amino acids: QRNQRN .. [Z] .. QRN")]
#[case(
"AXGTGTGATG",
false,
"Fixed pattern must contain only DNA bases: A .. [X] .. GTGTGATG"
)]
#[case(
"QRNQRNZQRN",
true,
"Fixed pattern must contain only amino acids: QRNQRN .. [Z] .. QRN"
)]
fn test_validate_fixed_pattern_error(
#[case] pattern: &str,
#[case] protein: bool,
#[case] msg: &str) {
#[case] msg: &str,
) {
let result = validate_fixed_pattern(&pattern, protein);
let inner = result.unwrap_err().to_string();
assert_eq!(inner, msg);
Expand Down
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ pub mod tests {
let sequence_match = expected_seq == return_sequences;
assert_eq!(sequence_match, expected_bool);
}

// ############################################################################################
//Tests match with protein (not DNA!)
// ############################################################################################
Expand All @@ -819,14 +819,11 @@ pub mod tests {
#[case(vec!["^Q", "^F"], vec!["QFPQFP"])] // unpaired: regex set with two matches
#[case(vec!["^Q", "^A"], vec!["AAAA", "ATAT", "AAAT", "QFPQFP"])] // unpaired: regex set with two matches
#[case(vec!["^M", "^K"], vec![])] // unpaired: regex set with no matches
fn test_protein_ok(
#[case] pattern: Vec<&str>,
#[case] expected_seq: Vec<&str>,
) {
fn test_protein_ok(#[case] pattern: Vec<&str>, #[case] expected_seq: Vec<&str>) {
let dir = TempDir::new().unwrap();
let seqs = vec![
vec!["AAAA", "TTTT", "ATAT", "TATA", "AAAT", "TTTA", "QFPQFP"],
];
let seqs = vec![vec![
"AAAA", "TTTT", "ATAT", "TATA", "AAAT", "TTTA", "QFPQFP",
]];
let out_path = dir.path().join(String::from("output.fq"));
let result_path = &out_path.clone();
let pattern = pattern.iter().map(|&s| s.to_owned()).collect::<Vec<_>>();
Expand Down Expand Up @@ -880,7 +877,7 @@ pub mod tests {
let result = fqgrep_from_opts(&opts);
assert_eq!(result.unwrap(), expected);
}

//
// ############################################################################################
// Tests that an error is returned when protein and reverse_complement are both present
Expand Down

0 comments on commit 9612b64

Please sign in to comment.