From b2f830ee879cfd0c0de3906a14b6c7ca233f1202 Mon Sep 17 00:00:00 2001 From: Marco van Zwetselaar Date: Sat, 4 Jan 2025 14:54:49 +0300 Subject: [PATCH 1/3] Make Mykrobe hamronizer accept empty JSON --- hAMRonization/MykrobeIO.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hAMRonization/MykrobeIO.py b/hAMRonization/MykrobeIO.py index 2913de3..550e544 100644 --- a/hAMRonization/MykrobeIO.py +++ b/hAMRonization/MykrobeIO.py @@ -75,6 +75,8 @@ def parse(self, handle): data = json.load(handle) sample_names = list(data.keys()) + if len(sample_names) == 0: + return # take an empty JSON object as a success but with no results assert len(sample_names) == 1, "can only parse output with a single " "sample currently, found {}".format(len(sample_names)) sample_name = sample_names[0] From f15821a745fcf524be33bd8a5850d8be5b4d46f4 Mon Sep 17 00:00:00 2001 From: Marco van Zwetselaar Date: Sat, 4 Jan 2025 15:28:12 +0300 Subject: [PATCH 2/3] Add test for empty Mykrobe JSON --- hAMRonization/MykrobeIO.py | 2 +- test/data/dummy/mykrobe/empty.json | 1 + test/test_parsing_validity.py | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/data/dummy/mykrobe/empty.json diff --git a/hAMRonization/MykrobeIO.py b/hAMRonization/MykrobeIO.py index 550e544..50e2fbf 100644 --- a/hAMRonization/MykrobeIO.py +++ b/hAMRonization/MykrobeIO.py @@ -76,7 +76,7 @@ def parse(self, handle): sample_names = list(data.keys()) if len(sample_names) == 0: - return # take an empty JSON object as a success but with no results + return # take an empty JSON object as a success but with no results assert len(sample_names) == 1, "can only parse output with a single " "sample currently, found {}".format(len(sample_names)) sample_name = sample_names[0] diff --git a/test/data/dummy/mykrobe/empty.json b/test/data/dummy/mykrobe/empty.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/data/dummy/mykrobe/empty.json @@ -0,0 +1 @@ +{} diff --git a/test/test_parsing_validity.py b/test/test_parsing_validity.py index 74c7cf2..e989e88 100644 --- a/test/test_parsing_validity.py +++ b/test/test_parsing_validity.py @@ -823,6 +823,15 @@ def test_tbprofiler(): assert result.reference_gene_stop is None +def test_mykrobe_empty(): + metadata = {} + parsed_report = hAMRonization.parse( + "data/dummy/mykrobe/empty.json", metadata, "mykrobe" + ) + for result in parsed_report: + assert False # there should be none + + def test_mykrobe(): metadata = {} parsed_report = hAMRonization.parse( From 507d8d72b5c99bac7180dfaa1760cc32c1379f01 Mon Sep 17 00:00:00 2001 From: Marco van Zwetselaar Date: Sat, 4 Jan 2025 15:28:43 +0300 Subject: [PATCH 3/3] Bump version to 1.1.9 - With support for all current tool versions --- hAMRonization/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hAMRonization/__init__.py b/hAMRonization/__init__.py index df48ee9..33d5eed 100644 --- a/hAMRonization/__init__.py +++ b/hAMRonization/__init__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -__version__ = "1.1.8" +__version__ = "1.1.9" from hAMRonization import AbricateIO from hAMRonization import AmrFinderPlusIO