From 9d83b5172b3a99e9018b927ea13a321b977d09c6 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:54:01 +0100 Subject: [PATCH 1/2] Set parameters in params file, and not config (#3965) | major - Rename workflow_path to workflow_bin_path to make clearer that we are talking about the codebase of the workflow - Renamed config_resources into resources, config_platform into platform - Split config_params into params and config - Building parameters with config_case now has a part with cg-built(or fetched) parameters that is added to the parameter file from servers. Placeholders are used and replaced by the value extracted from the same parameter dictionary, to avoid typos/repeats - Use target_bed_file instead of target_bed because target_bed needs the path to the reference directory that is defined in servers -> target_bed_file is the filename and target_bed in params uses that with the reference path to build the full file path - Removed unused is_params_appended_to_nextflow_config function - Add references are specified in params files from servers and don't need to be read-in and handled by cg --- cg/io/config.py | 15 --- cg/meta/workflow/nf_analysis.py | 99 ++++++++++++------- cg/meta/workflow/nf_handlers.py | 10 +- cg/meta/workflow/raredisease.py | 27 +++-- cg/meta/workflow/rnafusion.py | 23 ++--- cg/meta/workflow/taxprofiler.py | 9 +- cg/meta/workflow/tomte.py | 12 +-- cg/models/cg_config.py | 48 ++++----- cg/models/raredisease/raredisease.py | 3 +- cg/models/rnafusion/rnafusion.py | 4 - .../cli/generate/delivery_report/test_cli.py | 6 +- tests/conftest.py | 41 +++++--- ...e_params.config => pipeline_config.config} | 0 .../analysis/nf-analysis/pipeline_params.yaml | 1 + tests/io/test_io_config.py | 17 ---- 15 files changed, 141 insertions(+), 174 deletions(-) delete mode 100644 cg/io/config.py rename tests/fixtures/analysis/nf-analysis/{pipeline_params.config => pipeline_config.config} (100%) create mode 100644 tests/fixtures/analysis/nf-analysis/pipeline_params.yaml delete mode 100644 tests/io/test_io_config.py diff --git a/cg/io/config.py b/cg/io/config.py deleted file mode 100644 index 71f28e862c..0000000000 --- a/cg/io/config.py +++ /dev/null @@ -1,15 +0,0 @@ -from pathlib import Path -from typing import Any -from cg.constants.symbols import EMPTY_STRING - - -def write_config_nextflow_style(content: dict[str, Any] | None) -> str: - """Write content to stream accepted by Nextflow config files with non-quoted booleans and quoted strings.""" - string: str = EMPTY_STRING - double_quotes: str = '"' - for parameter, value in content.items(): - if isinstance(value, Path): - value: str = value.as_posix() - quotes = double_quotes if type(value) is str else EMPTY_STRING - string += f"params.{parameter} = {quotes}{value}{quotes}\n" - return string diff --git a/cg/meta/workflow/nf_analysis.py b/cg/meta/workflow/nf_analysis.py index d84dc509c5..7677b8397e 100644 --- a/cg/meta/workflow/nf_analysis.py +++ b/cg/meta/workflow/nf_analysis.py @@ -1,4 +1,6 @@ +import copy import logging +import re from datetime import datetime from pathlib import Path from typing import Any, Iterator @@ -20,11 +22,10 @@ from cg.constants.nf_analysis import NfTowerStatus from cg.constants.tb import AnalysisStatus from cg.exc import CgError, HousekeeperStoreError, MetricsQCError -from cg.io.config import write_config_nextflow_style from cg.io.controller import ReadFile, WriteFile from cg.io.json import read_json from cg.io.txt import concat_txt, write_txt -from cg.io.yaml import write_yaml_nextflow_style +from cg.io.yaml import read_yaml, write_yaml_nextflow_style from cg.meta.workflow.analysis import AnalysisAPI from cg.meta.workflow.nf_handlers import NextflowHandler, NfTowerHandler from cg.meta.workflow.utils.genome_build_helpers import get_genome_build @@ -55,14 +56,15 @@ def __init__(self, config: CGConfig, workflow: Workflow): super().__init__(workflow=workflow, config=config) self.workflow: Workflow = workflow self.root_dir: str | None = None - self.nfcore_workflow_path: str | None = None + self.workflow_bin_path: str | None = None self.references: str | None = None self.profile: str | None = None self.conda_env: str | None = None self.conda_binary: str | None = None - self.config_platform: str | None = None - self.config_params: str | None = None - self.config_resources: str | None = None + self.platform: str | None = None + self.params: str | None = None + self.config: str | None = None + self.resources: str | None = None self.tower_binary_path: str | None = None self.tower_workflow: str | None = None self.account: str | None = None @@ -98,11 +100,6 @@ def sample_sheet_headers(self) -> list[str]: """Headers for sample sheet.""" raise NotImplementedError - @property - def is_params_appended_to_nextflow_config(self) -> bool: - """Return True if parameters should be added into the nextflow config file instead of the params file.""" - return False - @property def is_multiqc_pattern_search_exact(self) -> bool: """Return True if only exact pattern search is allowed to collect metrics information from MultiQC file. @@ -131,24 +128,20 @@ def get_workflow_version(self, case_id: str) -> str: """Get workflow version from config.""" return self.revision - def get_workflow_parameters(self, case_id: str) -> WorkflowParameters: + def get_built_workflow_parameters(self, case_id: str) -> WorkflowParameters: """Return workflow parameters.""" raise NotImplementedError def get_nextflow_config_content(self, case_id: str) -> str: """Return nextflow config content.""" config_files_list: list[str] = [ - self.config_platform, - self.config_params, - self.config_resources, + self.platform, + self.config, + self.resources, ] extra_parameters_str: list[str] = [ self.set_cluster_options(case_id=case_id), ] - if self.is_params_appended_to_nextflow_config: - extra_parameters_str.append( - write_config_nextflow_style(self.get_workflow_parameters(case_id=case_id).dict()) - ) return concat_txt( file_paths=config_files_list, str_content=extra_parameters_str, @@ -284,12 +277,12 @@ def verify_deliverables_file_exists(self, case_id: str) -> None: if not Path(self.get_deliverables_file_path(case_id=case_id)).exists(): raise CgError(f"No deliverables file found for case {case_id}") - def write_params_file(self, case_id: str, workflow_parameters: dict = None) -> None: + def write_params_file(self, case_id: str, replaced_workflow_parameters: dict = None) -> None: """Write params-file for analysis.""" LOG.debug("Writing parameters file") - if workflow_parameters: + if replaced_workflow_parameters: write_yaml_nextflow_style( - content=workflow_parameters, + content=replaced_workflow_parameters, file_path=self.get_params_file_path(case_id=case_id), ) else: @@ -330,7 +323,7 @@ def write_trailblazer_config(self, case_id: str, tower_id: str) -> None: file_path=config_path, ) - def create_sample_sheet(self, case_id: str, dry_run: bool): + def create_sample_sheet(self, case_id: str, dry_run: bool) -> None: """Create sample sheet for a case.""" sample_sheet_content: list[list[Any]] = self.get_sample_sheet_content(case_id=case_id) if not dry_run: @@ -340,25 +333,59 @@ def create_sample_sheet(self, case_id: str, dry_run: bool): header=self.sample_sheet_headers, ) - def create_params_file(self, case_id: str, dry_run: bool): + def create_params_file(self, case_id: str, dry_run: bool) -> None: """Create parameters file for a case.""" - LOG.debug("Getting parameters information") - workflow_parameters = None - if not self.is_params_appended_to_nextflow_config: - workflow_parameters: dict | None = self.get_workflow_parameters(case_id=case_id).dict() + LOG.debug("Getting parameters information built on-the-fly") + built_workflow_parameters: dict | None = self.get_built_workflow_parameters( + case_id=case_id + ).model_dump() + LOG.debug("Adding parameters from the pipeline config file if it exist") + + workflow_parameters: dict = built_workflow_parameters | ( + read_yaml(self.params) if hasattr(self, "params") and self.params else {} + ) + replaced_workflow_parameters: dict = self.replace_values_in_params_file( + workflow_parameters=workflow_parameters + ) if not dry_run: - self.write_params_file(case_id=case_id, workflow_parameters=workflow_parameters) + self.write_params_file( + case_id=case_id, replaced_workflow_parameters=replaced_workflow_parameters + ) + + def replace_values_in_params_file(self, workflow_parameters: dict) -> dict: + replaced_workflow_parameters = copy.deepcopy(workflow_parameters) + """Iterate through the dictionary until all placeholders are replaced with the corresponding value from the dictionary""" + while True: + resolved: bool = True + for key, value in replaced_workflow_parameters.items(): + new_value: str | int = self.replace_params_placeholders(value, workflow_parameters) + if new_value != value: + resolved = False + replaced_workflow_parameters[key] = new_value + if resolved: + break + return replaced_workflow_parameters + + def replace_params_placeholders(self, value: str | int, workflow_parameters: dict) -> str: + """Replace values marked as placeholders with values from the given dictionary""" + if isinstance(value, str): + placeholders: list[str] = re.findall(r"{{\s*([^{}\s]+)\s*}}", value) + for placeholder in placeholders: + if placeholder in workflow_parameters: + value = value.replace( + f"{{{{{placeholder}}}}}", str(workflow_parameters[placeholder]) + ) + return value def create_nextflow_config(self, case_id: str, dry_run: bool = False) -> None: """Create nextflow config file.""" if content := self.get_nextflow_config_content(case_id=case_id): LOG.debug("Writing nextflow config file") - if dry_run: - return - write_txt( - content=content, - file_path=self.get_nextflow_config_path(case_id=case_id), - ) + if not dry_run: + write_txt( + content=content, + file_path=self.get_nextflow_config_path(case_id=case_id), + ) def create_gene_panel(self, case_id: str, dry_run: bool) -> None: """Create and write an aggregated gene panel file exported from Scout.""" @@ -402,7 +429,7 @@ def _run_analysis_with_nextflow( LOG.info("Workflow will be executed using Nextflow") parameters: list[str] = NextflowHandler.get_nextflow_run_parameters( case_id=case_id, - workflow_path=self.nfcore_workflow_path, + workflow_bin_path=self.workflow_bin_path, root_dir=self.root_dir, command_args=command_args.dict(), ) diff --git a/cg/meta/workflow/nf_handlers.py b/cg/meta/workflow/nf_handlers.py index c57e916d2f..0a91c138cf 100644 --- a/cg/meta/workflow/nf_handlers.py +++ b/cg/meta/workflow/nf_handlers.py @@ -6,11 +6,7 @@ from cg.apps.slurm.slurm_api import SlurmAPI from cg.constants.constants import FileExtensions, FileFormat -from cg.constants.nextflow import ( - JAVA_MEMORY_HEADJOB, - NXF_JVM_ARGS_ENV, - SlurmHeadJobDefaults, -) +from cg.constants.nextflow import JAVA_MEMORY_HEADJOB, NXF_JVM_ARGS_ENV, SlurmHeadJobDefaults from cg.io.controller import ReadFile from cg.models.slurm.sbatch import Sbatch from cg.utils.utils import build_command_from_dict @@ -116,7 +112,7 @@ def get_variables_to_export() -> dict[str, str]: @classmethod def get_nextflow_run_parameters( - cls, case_id: str, workflow_path: str, root_dir: str, command_args: dict + cls, case_id: str, workflow_bin_path: str, root_dir: str, command_args: dict ) -> list[str]: """Returns a Nextflow run command given a dictionary with arguments.""" @@ -137,7 +133,7 @@ def get_nextflow_run_parameters( ), exclude_true=True, ) - return nextflow_options + ["run", workflow_path] + run_options + return nextflow_options + ["run", workflow_bin_path] + run_options @staticmethod def get_head_job_sbatch_path(case_directory: Path) -> Path: diff --git a/cg/meta/workflow/raredisease.py b/cg/meta/workflow/raredisease.py index 98b62a97d9..35186e082a 100644 --- a/cg/meta/workflow/raredisease.py +++ b/cg/meta/workflow/raredisease.py @@ -49,14 +49,14 @@ def __init__( ): super().__init__(config=config, workflow=workflow) self.root_dir: str = config.raredisease.root - self.nfcore_workflow_path: str = config.raredisease.workflow_path - self.references: str = config.raredisease.references + self.workflow_bin_path: str = config.raredisease.workflow_bin_path self.profile: str = config.raredisease.profile self.conda_env: str = config.raredisease.conda_env self.conda_binary: str = config.raredisease.conda_binary - self.config_platform: str = config.raredisease.config_platform - self.config_params: str = config.raredisease.config_params - self.config_resources: str = config.raredisease.config_resources + self.platform: str = config.raredisease.platform + self.params: str = config.raredisease.params + self.config: str = config.raredisease.config + self.resources: str = config.raredisease.resources self.tower_binary_path: str = config.tower_binary_path self.tower_workflow: str = config.raredisease.tower_workflow self.account: str = config.raredisease.slurm.account @@ -96,31 +96,30 @@ def get_target_bed(self, case_id: str, analysis_type: str) -> str: """ Return the target bed file from LIMS and use default capture kit for WHOLE_GENOME_SEQUENCING. """ - target_bed: str = self.get_target_bed_from_lims(case_id=case_id) - if not target_bed: + target_bed_file: str = self.get_target_bed_from_lims(case_id=case_id) + if not target_bed_file: if analysis_type == AnalysisType.WHOLE_GENOME_SEQUENCING: return DEFAULT_CAPTURE_KIT raise ValueError("No capture kit was found in LIMS") - return target_bed + return target_bed_file def get_germlinecnvcaller_flag(self, analysis_type: str) -> bool: if analysis_type == AnalysisType.WHOLE_GENOME_SEQUENCING: return True return False - def get_workflow_parameters(self, case_id: str) -> RarediseaseParameters: + def get_built_workflow_parameters(self, case_id: str) -> RarediseaseParameters: """Return parameters.""" analysis_type: AnalysisType = self.get_data_analysis_type(case_id=case_id) - target_bed: str = self.get_target_bed(case_id=case_id, analysis_type=analysis_type) + target_bed_file: str = self.get_target_bed(case_id=case_id, analysis_type=analysis_type) skip_germlinecnvcaller = self.get_germlinecnvcaller_flag(analysis_type=analysis_type) outdir = self.get_case_path(case_id=case_id) return RarediseaseParameters( - local_genomes=str(self.references), input=self.get_sample_sheet_path(case_id=case_id), outdir=outdir, analysis_type=analysis_type, - target_bed=Path(self.references, target_bed).as_posix(), + target_bed_file=target_bed_file, save_mapped_as_cram=True, skip_germlinecnvcaller=skip_germlinecnvcaller, vcfanno_extra_resources=f"{outdir}/{ScoutExportFileName.MANAGED_VARIANTS}", @@ -157,10 +156,6 @@ def is_managed_variants_required(self) -> bool: """Return True if a managed variants needs to be exported from Scout.""" return True - @property - def root(self) -> str: - return self.config.raredisease.root - def write_managed_variants(self, case_id: str, content: list[str]) -> None: self._write_managed_variants(out_dir=Path(self.root, case_id), content=content) diff --git a/cg/meta/workflow/rnafusion.py b/cg/meta/workflow/rnafusion.py index 292b4f40bc..14c3da4afe 100644 --- a/cg/meta/workflow/rnafusion.py +++ b/cg/meta/workflow/rnafusion.py @@ -29,14 +29,14 @@ def __init__( ): super().__init__(config=config, workflow=workflow) self.root_dir: str = config.rnafusion.root - self.nfcore_workflow_path: str = config.rnafusion.workflow_path - self.references: str = config.rnafusion.references + self.workflow_bin_path: str = config.rnafusion.workflow_bin_path self.profile: str = config.rnafusion.profile self.conda_env: str = config.rnafusion.conda_env self.conda_binary: str = config.rnafusion.conda_binary - self.config_platform: str = config.rnafusion.config_platform - self.config_params: str = config.rnafusion.config_params - self.config_resources: str = config.rnafusion.config_resources + self.platform: str = config.rnafusion.platform + self.params: str = config.rnafusion.params + self.config: str = config.rnafusion.config + self.resources: str = config.rnafusion.resources self.tower_binary_path: str = config.tower_binary_path self.tower_workflow: str = config.rnafusion.tower_workflow self.account: str = config.rnafusion.slurm.account @@ -50,11 +50,6 @@ def sample_sheet_headers(self) -> list[str]: """Headers for sample sheet.""" return RnafusionSampleSheetEntry.headers() - @property - def is_params_appended_to_nextflow_config(self) -> bool: - """Return True if parameters should be added into the nextflow config file instead of the params file.""" - return False - @property def is_multiple_samples_allowed(self) -> bool: """Return whether the analysis supports multiple samples to be linked to the case.""" @@ -82,21 +77,15 @@ def get_sample_sheet_content_per_sample(self, case_sample: CaseSample) -> list[l ) return sample_sheet_entry.reformat_sample_content() - def get_workflow_parameters( + def get_built_workflow_parameters( self, case_id: str, genomes_base: Path | None = None ) -> RnafusionParameters: """Get Rnafusion parameters.""" return RnafusionParameters( - genomes_base=genomes_base or self.get_references_path(), input=self.get_sample_sheet_path(case_id=case_id), outdir=self.get_case_path(case_id=case_id), ) - def get_references_path(self, genomes_base: Path | None = None) -> Path: - if genomes_base: - return genomes_base.absolute() - return Path(self.references).absolute() - @staticmethod def ensure_mandatory_metrics_present(metrics: list[MetricsBase]) -> None: """Check that all mandatory metrics are present. diff --git a/cg/meta/workflow/taxprofiler.py b/cg/meta/workflow/taxprofiler.py index 9d5f985018..8bcca36c50 100644 --- a/cg/meta/workflow/taxprofiler.py +++ b/cg/meta/workflow/taxprofiler.py @@ -28,7 +28,7 @@ def __init__( ): super().__init__(config=config, workflow=workflow) self.root_dir: str = config.taxprofiler.root - self.nfcore_workflow_path: str = config.taxprofiler.workflow_path + self.workflow_bin_path: str = config.taxprofiler.workflow_bin_path self.conda_env: str = config.taxprofiler.conda_env self.conda_binary: str = config.taxprofiler.conda_binary self.profile: str = config.taxprofiler.profile @@ -47,11 +47,6 @@ def sample_sheet_headers(self) -> list[str]: """Headers for sample sheet.""" return TaxprofilerSampleSheetEntry.headers() - @property - def is_params_appended_to_nextflow_config(self) -> bool: - """Return True if parameters should be added into the nextflow config file instead of the params file.""" - return False - @property def is_multiqc_pattern_search_exact(self) -> bool: """Only exact pattern search is allowed to collect metrics information from multiqc file.""" @@ -82,7 +77,7 @@ def get_sample_sheet_content_per_sample(self, case_sample: CaseSample) -> list[l ) return sample_sheet_entry.reformat_sample_content() - def get_workflow_parameters(self, case_id: str) -> TaxprofilerParameters: + def get_built_workflow_parameters(self, case_id: str) -> TaxprofilerParameters: """Return Taxprofiler parameters.""" return TaxprofilerParameters( cluster_options=f"--qos={self.get_slurm_qos_for_case(case_id=case_id)}", diff --git a/cg/meta/workflow/tomte.py b/cg/meta/workflow/tomte.py index c10c715eea..9eb4aa7df6 100644 --- a/cg/meta/workflow/tomte.py +++ b/cg/meta/workflow/tomte.py @@ -25,14 +25,14 @@ def __init__( ): super().__init__(config=config, workflow=workflow) self.root_dir: str = config.tomte.root - self.nfcore_workflow_path: str = config.tomte.workflow_path - self.references: str = config.tomte.references + self.workflow_bin_path: str = config.tomte.workflow_bin_path self.profile: str = config.tomte.profile self.conda_env: str = config.tomte.conda_env self.conda_binary: str = config.tomte.conda_binary - self.config_platform: str = config.tomte.config_platform - self.config_params: str = config.tomte.config_params - self.config_resources: str = config.tomte.config_resources + self.platform: str = config.tomte.platform + self.params: str = config.tomte.params + self.config: str = config.tomte.config + self.resources: str = config.tomte.resources self.tower_binary_path: str = config.tower_binary_path self.tower_workflow: str = config.tomte.tower_workflow self.account: str = config.tomte.slurm.account @@ -70,7 +70,7 @@ def get_sample_sheet_content_per_sample(self, case_sample: CaseSample) -> list[l ) return sample_sheet_entry.reformat_sample_content - def get_workflow_parameters(self, case_id: str) -> TomteParameters: + def get_built_workflow_parameters(self, case_id: str) -> TomteParameters: """Return parameters.""" return TomteParameters( input=self.get_sample_sheet_path(case_id=case_id), diff --git a/cg/models/cg_config.py b/cg/models/cg_config.py index 3fab14bd92..77af8d2181 100644 --- a/cg/models/cg_config.py +++ b/cg/models/cg_config.py @@ -45,21 +45,13 @@ from cg.services.run_devices.pacbio.housekeeper_service.pacbio_houskeeper_service import ( PacBioHousekeeperService, ) -from cg.services.run_devices.pacbio.metrics_parser.metrics_parser import ( - PacBioMetricsParser, -) -from cg.services.run_devices.pacbio.post_processing_service import ( - PacBioPostProcessingService, -) +from cg.services.run_devices.pacbio.metrics_parser.metrics_parser import PacBioMetricsParser +from cg.services.run_devices.pacbio.post_processing_service import PacBioPostProcessingService from cg.services.run_devices.pacbio.run_data_generator.pacbio_run_data_generator import ( PacBioRunDataGenerator, ) -from cg.services.run_devices.pacbio.run_file_manager.run_file_manager import ( - PacBioRunFileManager, -) -from cg.services.run_devices.pacbio.run_validator.pacbio_run_validator import ( - PacBioRunValidator, -) +from cg.services.run_devices.pacbio.run_file_manager.run_file_manager import PacBioRunFileManager +from cg.services.run_devices.pacbio.run_validator.pacbio_run_validator import PacBioRunValidator from cg.services.run_devices.run_names.pacbio import PacbioRunNamesService from cg.services.sequencing_qc_service.sequencing_qc_service import SequencingQCService from cg.services.slurm_service.slurm_cli_service import SlurmCLIService @@ -223,13 +215,13 @@ class RarediseaseConfig(CommonAppConfig): compute_env: str conda_binary: str | None = None conda_env: str - config_platform: str - config_params: str - config_resources: str + platform: str + params: str + config: str + resources: str launch_directory: str - workflow_path: str + workflow_bin_path: str profile: str - references: str revision: str root: str slurm: SlurmConfig @@ -241,12 +233,12 @@ class TomteConfig(CommonAppConfig): compute_env: str conda_binary: str | None = None conda_env: str - config_platform: str - config_params: str - config_resources: str - workflow_path: str + platform: str + params: str + config: str + resources: str + workflow_bin_path: str profile: str - references: str revision: str root: str slurm: SlurmConfig @@ -258,17 +250,17 @@ class RnafusionConfig(CommonAppConfig): compute_env: str conda_binary: str | None = None conda_env: str - config_platform: str - config_params: str - config_resources: str + platform: str + params: str + config: str + resources: str launch_directory: str profile: str - references: str revision: str root: str slurm: SlurmConfig tower_workflow: str - workflow_path: str + workflow_bin_path: str class TaxprofilerConfig(CommonAppConfig): @@ -278,7 +270,7 @@ class TaxprofilerConfig(CommonAppConfig): compute_env: str databases: str hostremoval_reference: str - workflow_path: str + workflow_bin_path: str profile: str revision: str root: str diff --git a/cg/models/raredisease/raredisease.py b/cg/models/raredisease/raredisease.py index 764b4b4056..1797d6c78c 100644 --- a/cg/models/raredisease/raredisease.py +++ b/cg/models/raredisease/raredisease.py @@ -64,10 +64,9 @@ def list(cls) -> list[str]: class RarediseaseParameters(WorkflowParameters): """Model for Raredisease parameters.""" - target_bed: str + target_bed_file: str analysis_type: str save_mapped_as_cram: bool skip_germlinecnvcaller: bool vcfanno_extra_resources: str - local_genomes: str vep_filters_scout_fmt: str diff --git a/cg/models/rnafusion/rnafusion.py b/cg/models/rnafusion/rnafusion.py index 6c4b1dcd1c..f8bd497677 100644 --- a/cg/models/rnafusion/rnafusion.py +++ b/cg/models/rnafusion/rnafusion.py @@ -1,5 +1,3 @@ -from pathlib import Path - from cg.constants.constants import Strandedness from cg.models.nf_analysis import NextflowSampleSheetEntry, WorkflowParameters from cg.models.qc_metrics import QCMetrics @@ -26,8 +24,6 @@ class RnafusionQCMetrics(QCMetrics): class RnafusionParameters(WorkflowParameters): """Rnafusion parameters.""" - genomes_base: Path - class RnafusionSampleSheetEntry(NextflowSampleSheetEntry): """Rnafusion sample sheet model.""" diff --git a/tests/cli/generate/delivery_report/test_cli.py b/tests/cli/generate/delivery_report/test_cli.py index fa85a23c48..a98d83ea05 100644 --- a/tests/cli/generate/delivery_report/test_cli.py +++ b/tests/cli/generate/delivery_report/test_cli.py @@ -2,10 +2,10 @@ import pytest from _pytest.fixtures import FixtureRequest -from click.testing import Result, CliRunner +from click.testing import CliRunner, Result from cg.cli.generate.delivery_report.base import generate_delivery_report -from cg.constants import Workflow, EXIT_SUCCESS +from cg.constants import EXIT_SUCCESS, Workflow from cg.models.cg_config import CGConfig @@ -33,7 +33,7 @@ def test_generate_delivery_report( @pytest.mark.parametrize("workflow", [Workflow.RAREDISEASE, Workflow.RNAFUSION]) -def test_generate_delivery_report_dry_rum( +def test_generate_delivery_report_dry_run( request: FixtureRequest, workflow: Workflow, cli_runner: CliRunner ) -> None: """Test dry run command to generate delivery report.""" diff --git a/tests/conftest.py b/tests/conftest.py index b3c313e98e..03206c4271 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1900,6 +1900,7 @@ def context_config( nextflow_binary: Path, nf_analysis_platform_config_path: Path, nf_analysis_pipeline_params_path: Path, + nf_analysis_pipeline_config_path: Path, nf_analysis_pipeline_resource_optimisation_path: Path, ) -> dict: """Return a context config.""" @@ -2085,11 +2086,12 @@ def context_config( "compute_env": "nf_tower_compute_env", "conda_binary": conda_binary.as_posix(), "conda_env": "S_raredisease", - "config_platform": str(nf_analysis_platform_config_path), - "config_params": str(nf_analysis_pipeline_params_path), - "config_resources": str(nf_analysis_pipeline_resource_optimisation_path), + "platform": str(nf_analysis_platform_config_path), + "params": str(nf_analysis_pipeline_params_path), + "config": str(nf_analysis_pipeline_config_path), + "resources": str(nf_analysis_pipeline_resource_optimisation_path), "launch_directory": Path("path", "to", "launchdir").as_posix(), - "workflow_path": Path("workflow", "path").as_posix(), + "workflow_bin_path": Path("workflow", "path").as_posix(), "profile": "myprofile", "references": Path("path", "to", "references").as_posix(), "revision": "2.2.0", @@ -2105,10 +2107,11 @@ def context_config( "compute_env": "nf_tower_compute_env", "conda_binary": conda_binary.as_posix(), "conda_env": "S_tomte", - "config_platform": str(nf_analysis_platform_config_path), - "config_params": str(nf_analysis_pipeline_params_path), - "config_resources": str(nf_analysis_pipeline_resource_optimisation_path), - "workflow_path": Path("workflow", "path").as_posix(), + "platform": str(nf_analysis_platform_config_path), + "params": str(nf_analysis_pipeline_params_path), + "config": str(nf_analysis_pipeline_config_path), + "resources": str(nf_analysis_pipeline_resource_optimisation_path), + "workflow_bin_path": Path("workflow", "path").as_posix(), "profile": "myprofile", "references": Path("path", "to", "references").as_posix(), "revision": "2.2.0", @@ -2124,11 +2127,12 @@ def context_config( "compute_env": "nf_tower_compute_env", "conda_binary": conda_binary.as_posix(), "conda_env": "S_RNAFUSION", - "config_platform": str(nf_analysis_platform_config_path), - "config_params": str(nf_analysis_pipeline_params_path), - "config_resources": str(nf_analysis_pipeline_resource_optimisation_path), + "platform": str(nf_analysis_platform_config_path), + "params": str(nf_analysis_pipeline_params_path), + "config": str(nf_analysis_pipeline_config_path), + "resources": str(nf_analysis_pipeline_resource_optimisation_path), "launch_directory": Path("path", "to", "launchdir").as_posix(), - "workflow_path": Path("workflow", "path").as_posix(), + "workflow_bin_path": Path("workflow", "path").as_posix(), "profile": "myprofile", "references": Path("path", "to", "references").as_posix(), "revision": "2.2.0", @@ -2148,7 +2152,7 @@ def context_config( "conda_binary": conda_binary.as_posix(), "conda_env": "S_taxprofiler", "launch_directory": Path("path", "to", "launchdir").as_posix(), - "workflow_path": Path("workflow", "path").as_posix(), + "workflow_bin_path": Path("workflow", "path").as_posix(), "databases": Path("path", "to", "databases").as_posix(), "profile": "myprofile", "hostremoval_reference": Path("path", "to", "hostremoval_reference").as_posix(), @@ -2575,14 +2579,13 @@ def raredisease_parameters_default( return RarediseaseParameters( input=raredisease_sample_sheet_path, outdir=Path(raredisease_dir, raredisease_case_id), - target_bed=bed_version_file_name, + target_bed_file=bed_version_file_name, skip_germlinecnvcaller=False, analysis_type=AnalysisTypes.WES, save_mapped_as_cram=True, vcfanno_extra_resources=str( Path(raredisease_dir, raredisease_case_id + ScoutExportFileName.MANAGED_VARIANTS) ), - local_genomes=Path(raredisease_dir, "references").as_posix(), vep_filters_scout_fmt=str( Path(raredisease_dir, raredisease_case_id + ScoutExportFileName.PANELS) ), @@ -3022,7 +3025,13 @@ def nf_analysis_platform_config_path(nf_analysis_analysis_dir) -> Path: @pytest.fixture(scope="function") def nf_analysis_pipeline_params_path(nf_analysis_analysis_dir) -> Path: """Path to pipeline params file.""" - return Path(nf_analysis_analysis_dir, "pipeline_params").with_suffix(FileExtensions.CONFIG) + return Path(nf_analysis_analysis_dir, "pipeline_params").with_suffix(FileExtensions.YAML) + + +@pytest.fixture(scope="function") +def nf_analysis_pipeline_config_path(nf_analysis_analysis_dir) -> Path: + """Path to pipeline params file.""" + return Path(nf_analysis_analysis_dir, "pipeline_config").with_suffix(FileExtensions.CONFIG) @pytest.fixture(scope="function") diff --git a/tests/fixtures/analysis/nf-analysis/pipeline_params.config b/tests/fixtures/analysis/nf-analysis/pipeline_config.config similarity index 100% rename from tests/fixtures/analysis/nf-analysis/pipeline_params.config rename to tests/fixtures/analysis/nf-analysis/pipeline_config.config diff --git a/tests/fixtures/analysis/nf-analysis/pipeline_params.yaml b/tests/fixtures/analysis/nf-analysis/pipeline_params.yaml new file mode 100644 index 0000000000..a27226f432 --- /dev/null +++ b/tests/fixtures/analysis/nf-analysis/pipeline_params.yaml @@ -0,0 +1 @@ +someparam: "something" diff --git a/tests/io/test_io_config.py b/tests/io/test_io_config.py deleted file mode 100644 index 7521cbe084..0000000000 --- a/tests/io/test_io_config.py +++ /dev/null @@ -1,17 +0,0 @@ -from pathlib import Path - -import pytest - -from cg.io.config import write_config_nextflow_style - - -def test_write_config_nextflow_style(config_dict: Path): - """ - Test output content from stream into nextflow config format. - """ - - # THEN assert a config format is returned - assert ( - write_config_nextflow_style(content=config_dict) - == 'params.input = "input_path"\nparams.output = "output_path"\n' - ) From 9037ced3481d7b08ad67b293cc5c48f882305a14 Mon Sep 17 00:00:00 2001 From: Clinical Genomics Bot Date: Wed, 27 Nov 2024 11:54:28 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Bump=20version:=2064.5.13=20=E2=86=92=2064.?= =?UTF-8?q?5.14=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- cg/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f23b078481..61f5e2b513 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 64.5.13 +current_version = 64.5.14 commit = True tag = True tag_name = v{new_version} diff --git a/cg/__init__.py b/cg/__init__.py index e33450639f..c7ef26cad4 100644 --- a/cg/__init__.py +++ b/cg/__init__.py @@ -1,2 +1,2 @@ __title__ = "cg" -__version__ = "64.5.13" +__version__ = "64.5.14" diff --git a/pyproject.toml b/pyproject.toml index 988b37df4b..2310eed895 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "cg" -version = "64.5.13" +version = "64.5.14" description = "Clinical Genomics command center" authors = ["Clinical Genomics "] readme = "README.md"