From d930ae0b1873ed99bc163e82f90ef1ac0c758e7a Mon Sep 17 00:00:00 2001 From: peterpru Date: Mon, 13 Jan 2025 21:32:20 +0100 Subject: [PATCH 1/2] add nallo to cg workflow cli --- cg/cli/workflow/base.py | 10 ++++++---- cg/cli/workflow/nallo/__init__.py | 1 + cg/cli/workflow/nallo/base.py | 20 +++++++++++++++++++ cg/meta/workflow/nallo.py | 20 +++++++++++++++++++ .../nf_analysis/test_cli_workflow_base.py | 2 +- tests/conftest.py | 11 ++++++++++ 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 cg/cli/workflow/nallo/__init__.py create mode 100644 cg/cli/workflow/nallo/base.py create mode 100644 cg/meta/workflow/nallo.py diff --git a/cg/cli/workflow/base.py b/cg/cli/workflow/base.py index e159534808..2d1cc1590c 100644 --- a/cg/cli/workflow/base.py +++ b/cg/cli/workflow/base.py @@ -14,6 +14,7 @@ from cg.cli.workflow.mip_dna.base import mip_dna from cg.cli.workflow.mip_rna.base import mip_rna from cg.cli.workflow.mutant.base import mutant +from cg.cli.workflow.nallo.base import nallo from cg.cli.workflow.raredisease.base import raredisease from cg.cli.workflow.rnafusion.base import rnafusion from cg.cli.workflow.taxprofiler.base import taxprofiler @@ -27,16 +28,17 @@ def workflow(): workflow.add_command(balsamic) workflow.add_command(balsamic_qc) -workflow.add_command(balsamic_umi) workflow.add_command(balsamic_pon) +workflow.add_command(balsamic_umi) +workflow.add_command(fluffy) +workflow.add_command(jasen) workflow.add_command(microsalt) workflow.add_command(mip_dna) workflow.add_command(mip_rna) -workflow.add_command(fluffy) -workflow.add_command(jasen) workflow.add_command(mutant) +workflow.add_command(nallo) workflow.add_command(raredisease) +workflow.add_command(raw_data) workflow.add_command(rnafusion) workflow.add_command(taxprofiler) workflow.add_command(tomte) -workflow.add_command(raw_data) diff --git a/cg/cli/workflow/nallo/__init__.py b/cg/cli/workflow/nallo/__init__.py new file mode 100644 index 0000000000..d3a1fde1a8 --- /dev/null +++ b/cg/cli/workflow/nallo/__init__.py @@ -0,0 +1 @@ +"""Init for module""" diff --git a/cg/cli/workflow/nallo/base.py b/cg/cli/workflow/nallo/base.py new file mode 100644 index 0000000000..ed4674e73f --- /dev/null +++ b/cg/cli/workflow/nallo/base.py @@ -0,0 +1,20 @@ +"""CLI support to create config and/or start NALLO.""" + +import logging + +import rich_click as click + +from cg.cli.utils import CLICK_CONTEXT_SETTINGS +from cg.constants.constants import MetaApis +from cg.meta.workflow.analysis import AnalysisAPI +from cg.meta.workflow.nallo import NalloAnalysisAPI + +LOG = logging.getLogger(__name__) + + +@click.group(invoke_without_command=True, context_settings=CLICK_CONTEXT_SETTINGS) +@click.pass_context +def nallo(context: click.Context) -> None: + """gms/nallo analysis workflow.""" + AnalysisAPI.get_help(context) + context.obj.meta_apis[MetaApis.ANALYSIS_API] = NalloAnalysisAPI(config=context.obj) diff --git a/cg/meta/workflow/nallo.py b/cg/meta/workflow/nallo.py new file mode 100644 index 0000000000..dea41f715d --- /dev/null +++ b/cg/meta/workflow/nallo.py @@ -0,0 +1,20 @@ +"""Module for Nallo Analysis API.""" + +import logging +from cg.constants import Workflow +from cg.meta.workflow.nf_analysis import NfAnalysisAPI +from cg.models.cg_config import CGConfig + +LOG = logging.getLogger(__name__) + + +class NalloAnalysisAPI(NfAnalysisAPI): + """Handles communication between NALLO processes + and the rest of CG infrastructure.""" + + def __init__( + self, + config: CGConfig, + workflow: Workflow = Workflow.NALLO, + ): + super().__init__(config=config, workflow=workflow) diff --git a/tests/cli/workflow/nf_analysis/test_cli_workflow_base.py b/tests/cli/workflow/nf_analysis/test_cli_workflow_base.py index c8a127ece7..aa6cdcfc3e 100644 --- a/tests/cli/workflow/nf_analysis/test_cli_workflow_base.py +++ b/tests/cli/workflow/nf_analysis/test_cli_workflow_base.py @@ -10,7 +10,7 @@ @pytest.mark.parametrize( "workflow", - NEXTFLOW_WORKFLOWS + [Workflow.JASEN], + NEXTFLOW_WORKFLOWS + [Workflow.JASEN] + [Workflow.NALLO], ) def test_workflow_no_args(cli_runner: CliRunner, workflow: Workflow, request): """Test to see that workflow is added and prints help when no subcommand is specified.""" diff --git a/tests/conftest.py b/tests/conftest.py index e53ff46ea5..d755624ef4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -44,6 +44,7 @@ from cg.meta.tar.tar import TarAPI from cg.meta.transfer.external_data import ExternalDataAPI from cg.meta.workflow.jasen import JasenAnalysisAPI +from cg.meta.workflow.nallo import NalloAnalysisAPI from cg.meta.workflow.raredisease import RarediseaseAnalysisAPI from cg.meta.workflow.rnafusion import RnafusionAnalysisAPI from cg.meta.workflow.taxprofiler import TaxprofilerAnalysisAPI @@ -2481,6 +2482,16 @@ def sequencing_platform() -> str: return SequencingPlatform.ILLUMINA +# Nallo fixtures +@pytest.fixture(scope="function", name="nallo_context") +def fixture_nallo_context( + cg_context: CGConfig, +) -> CGConfig: + """Context to use in cli.""" + cg_context.meta_apis["analysis_api"] = NalloAnalysisAPI(config=cg_context) + return cg_context + + # Raredisease fixtures @pytest.fixture(scope="function") def raredisease_dir(tmpdir_factory, apps_dir: Path) -> str: From a5b807c8faccf560daeb121e4807c38e45e3b186 Mon Sep 17 00:00:00 2001 From: Peter Pruisscher <57712924+peterpru@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:05:41 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Sebastian Diaz --- cg/cli/workflow/nallo/base.py | 2 +- cg/meta/workflow/nallo.py | 2 +- tests/conftest.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cg/cli/workflow/nallo/base.py b/cg/cli/workflow/nallo/base.py index ed4674e73f..39c27232a0 100644 --- a/cg/cli/workflow/nallo/base.py +++ b/cg/cli/workflow/nallo/base.py @@ -15,6 +15,6 @@ @click.group(invoke_without_command=True, context_settings=CLICK_CONTEXT_SETTINGS) @click.pass_context def nallo(context: click.Context) -> None: - """gms/nallo analysis workflow.""" + """GMS/Nallo analysis workflow.""" AnalysisAPI.get_help(context) context.obj.meta_apis[MetaApis.ANALYSIS_API] = NalloAnalysisAPI(config=context.obj) diff --git a/cg/meta/workflow/nallo.py b/cg/meta/workflow/nallo.py index dea41f715d..ede48ea93e 100644 --- a/cg/meta/workflow/nallo.py +++ b/cg/meta/workflow/nallo.py @@ -9,7 +9,7 @@ class NalloAnalysisAPI(NfAnalysisAPI): - """Handles communication between NALLO processes + """Handles communication between Nallo processes and the rest of CG infrastructure.""" def __init__( diff --git a/tests/conftest.py b/tests/conftest.py index d755624ef4..8d2b9210fe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2483,8 +2483,8 @@ def sequencing_platform() -> str: # Nallo fixtures -@pytest.fixture(scope="function", name="nallo_context") -def fixture_nallo_context( +@pytest.fixture(scope="function") +def nallo_context( cg_context: CGConfig, ) -> CGConfig: """Context to use in cli."""