From 3096bcc5a988ce615d27d99c9202ae653a9e322c Mon Sep 17 00:00:00 2001 From: "Arjan Draisma (wur)" <74908173+adraismawur@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:26:08 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Cunliang Geng --- src/nplinker/genomics/bigscape/runbigscape.py | 8 ++++---- tests/unit/genomics/test_runbigscape.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nplinker/genomics/bigscape/runbigscape.py b/src/nplinker/genomics/bigscape/runbigscape.py index 0d43bd58..bf8173b1 100644 --- a/src/nplinker/genomics/bigscape/runbigscape.py +++ b/src/nplinker/genomics/bigscape/runbigscape.py @@ -15,7 +15,7 @@ def run_bigscape( antismash_path: str | PathLike, output_path: str | PathLike, extra_params: str, - version: int = 1, + version: Literal[1, 2] = 1, ) -> bool: """Runs BiG-SCAPE to cluster BGCs. @@ -34,7 +34,7 @@ def run_bigscape( antismash_path: Path to the antismash output directory. output_path: Path to the output directory where BiG-SCAPE will write its results. extra_params: Additional parameters to pass to BiG-SCAPE. - version: The version of BiG-SCAPE to run. Can be 1 or 2. + version: The version of BiG-SCAPE to run. Must be 1 or 2. Returns: True if BiG-SCAPE ran successfully, False otherwise. @@ -45,13 +45,13 @@ def run_bigscape( elif version == 2: bigscape_py_path = "bigscape-v2.py" else: - raise ValueError("Unexpected BiG-SCAPE version number specified") + raise ValueError("Invalid BiG-SCAPE version number. Expected: 1 or 2.") try: subprocess.run([bigscape_py_path, "-h"], capture_output=True, check=True) except Exception as e: raise FileNotFoundError( - f"Failed to find/run bigscape.py (path={bigscape_py_path}, err={e})" + f"Failed to find/run BiG-SCAPE executable program (path={bigscape_py_path}, err={e})" ) from e if not os.path.exists(antismash_path): diff --git a/tests/unit/genomics/test_runbigscape.py b/tests/unit/genomics/test_runbigscape.py index 30833dc9..e8c6e0ab 100644 --- a/tests/unit/genomics/test_runbigscape.py +++ b/tests/unit/genomics/test_runbigscape.py @@ -27,7 +27,7 @@ def test_run_bigscape_v2(tmp_path): def test_run_bigscape_small_dataset_v1(tmp_path): result = bigscape.run_bigscape( - antismash_path=DATA_DIR / "bigscape/minimal_dataset", + antismash_path=DATA_DIR / "bigscape" / "minimal_dataset", output_path=tmp_path, extra_params="", version=1, @@ -38,7 +38,7 @@ def test_run_bigscape_small_dataset_v1(tmp_path): def test_run_bigscape_small_dataset_v2(tmp_path): result = bigscape.run_bigscape( - antismash_path=DATA_DIR / "bigscape/minimal_dataset", + antismash_path=DATA_DIR / "bigscape" / "minimal_dataset", output_path=tmp_path, extra_params="", version=2,