From d0f5ac4d527a798c55ba2032d604862d7030f7c0 Mon Sep 17 00:00:00 2001 From: nkongenelly Date: Mon, 8 Apr 2024 12:21:05 +0200 Subject: [PATCH] Added index positions (#113) * Differentiated indexed read values from non-indexed reads * Refactor code * Refactored code --- checkQC/__init__.py | 2 +- checkQC/handlers/q30_handler.py | 10 ++++++++-- tests/handlers/test_q30_handler.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/checkQC/__init__.py b/checkQC/__init__.py index d7e0f52..9d7381d 100644 --- a/checkQC/__init__.py +++ b/checkQC/__init__.py @@ -1,2 +1,2 @@ -__version__ = "4.0.1" +__version__ = "4.0.2-rc1" diff --git a/checkQC/handlers/q30_handler.py b/checkQC/handlers/q30_handler.py index 9f4877e..f995de4 100644 --- a/checkQC/handlers/q30_handler.py +++ b/checkQC/handlers/q30_handler.py @@ -28,12 +28,18 @@ def collect(self, signal): def check_qc(self): + index_count = 0 + non_index_count = 0 for error_dict in self.error_results: lane_nbr = int(error_dict["lane"]) - read = error_dict["read"] percent_q30 = error_dict["percent_q30"] - is_index_read = error_dict["percent_q30"] + is_index_read = error_dict.get("is_index_read", False) read_or_index_text = "index read" if is_index_read else "read" + # Differentiate read values for indexed from non-indexed reads + index_count += 1 if is_index_read else 0 + non_index_count += 1 if not is_index_read else 0 + + read = index_count if is_index_read else non_index_count if self.error() != self.UNKNOWN and percent_q30 < self.error(): yield QCErrorFatal( diff --git a/tests/handlers/test_q30_handler.py b/tests/handlers/test_q30_handler.py index e0019d5..6fa6e9b 100644 --- a/tests/handlers/test_q30_handler.py +++ b/tests/handlers/test_q30_handler.py @@ -27,7 +27,7 @@ def test_all_is_fine(self): self.set_qc_config(qc_config) errors_and_warnings = list(self.q30_handler.check_qc()) self.assertIn("index read", f"{errors_and_warnings}") - self.assertEqual(f"{errors_and_warnings}", "[Fatal QC error: %Q30 50.00 was too low on lane: 1 for index read: 3]") + self.assertEqual(f"{errors_and_warnings}", "[Fatal QC error: %Q30 50.00 was too low on lane: 1 for index read: 1]") def test_warning(self): qc_config = {'name': 'Q30Handler', 'error': 70, 'warning': 85}