diff --git a/cg/meta/workflow/microsalt/quality_checker.py b/cg/meta/workflow/microsalt/quality_checker.py index 4df7bcbabe..43f0b00099 100644 --- a/cg/meta/workflow/microsalt/quality_checker.py +++ b/cg/meta/workflow/microsalt/quality_checker.py @@ -120,5 +120,5 @@ def is_qc_required(self, case_run_dir: Path | None, case_id: str) -> bool: LOG.info(f"Performing QC on case {case_id}") return True - def sample_total_reads_qc(self, sample: Sample) -> bool: + def sample_total_reads_qc(self, sample_id: str) -> bool: pass \ No newline at end of file diff --git a/cg/meta/workflow/microsalt/utils.py b/cg/meta/workflow/microsalt/utils.py index 8c37aef8d4..e5dfafe026 100644 --- a/cg/meta/workflow/microsalt/utils.py +++ b/cg/meta/workflow/microsalt/utils.py @@ -2,4 +2,4 @@ def is_total_reads_above_failure_threshold(sample_reads: int, target_reads: int) -> bool: - return sample_reads <= target_reads * MicrosaltQC.TARGET_READS_FAIL_THRESHOLD + return sample_reads > target_reads * MicrosaltQC.TARGET_READS_FAIL_THRESHOLD diff --git a/tests/meta/workflow/microsalt/__init__.py b/tests/meta/workflow/microsalt/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/meta/workflow/microsalt/test_quality_control.py b/tests/meta/workflow/microsalt/test_quality_control.py index f9ca1d5a91..800cf84f6e 100644 --- a/tests/meta/workflow/microsalt/test_quality_control.py +++ b/tests/meta/workflow/microsalt/test_quality_control.py @@ -1,30 +1,44 @@ -import pytest - from cg.constants.constants import MicrosaltQC from cg.meta.workflow.microsalt.utils import is_total_reads_above_failure_threshold -TARGET_READS_FAIL_THRESHOLD = MicrosaltQC.TARGET_READS_FAIL_THRESHOLD -test_cases = [ - (TARGET_READS_FAIL_THRESHOLD * 100, 100, False, "sufficient_reads"), - (TARGET_READS_FAIL_THRESHOLD * 100 - 1, 100, True, "just_below_threshold"), - (0, 100, True, "edge_case_no_reads"), - (TARGET_READS_FAIL_THRESHOLD * 100, 0, False, "edge_case_no_target_reads"), -] +def test_sample_total_reads_passing(): + # GIVEN a sample with sufficient reads + sample_reads = 100 + target_reads = 100 + + # WHEN checking if the sample has sufficient reads + passes_reads_threshold = is_total_reads_above_failure_threshold( + sample_reads=sample_reads, target_reads=target_reads + ) + + # THEN it passes + assert passes_reads_threshold + + +def test_sample_total_reads_failing(): + # GIVEN a sample with insufficient reads + sample_reads = 50 + target_reads = 100 + + # WHEN checking if the sample has sufficient reads + passes_reads_threshold = is_total_reads_above_failure_threshold( + sample_reads=sample_reads, target_reads=target_reads + ) + + # THEN it fails + assert not passes_reads_threshold -@pytest.mark.parametrize( - "sample_reads, target_reads, expected_result, test_id", test_cases, ids=lambda x: x[-1] -) -def test_is_total_reads_above_failure_threshold( - sample_reads, target_reads, expected_result, test_id -): - # GIVEN a sample with a number of reads and a target number of reads +def test_sample_total_reads_failing_without_reads(): + # GIVEN a sample without reads + sample_reads = 0 + target_reads = 100 # WHEN checking if the sample has sufficient reads - result = is_total_reads_above_failure_threshold( + passes_reads_threshold = is_total_reads_above_failure_threshold( sample_reads=sample_reads, target_reads=target_reads ) - # THEN the result should be as expected - assert result == expected_result, f"Test failed for {test_id}" + # THEN it fails + assert not passes_reads_threshold