diff --git a/cg/constants/scout.py b/cg/constants/scout.py index ef2bec36b9..39f22145a4 100644 --- a/cg/constants/scout.py +++ b/cg/constants/scout.py @@ -14,6 +14,11 @@ class ScoutExportFileName(StrEnum): PANELS: str = f"gene_panels{FileExtensions.BED}" +class UploadTrack(StrEnum): + RARE_DISEASE: str = "rare" + CANCER: str = "cancer" + + class ScoutCustomCaseReportTags(StrEnum): DELIVERY: str = "delivery_report" CNV: str = "cnv_report" diff --git a/cg/meta/report/balsamic.py b/cg/meta/report/balsamic.py index 25b496c512..e88f531b1f 100644 --- a/cg/meta/report/balsamic.py +++ b/cg/meta/report/balsamic.py @@ -156,10 +156,10 @@ def get_variant_caller_version(var_caller_name: str, var_caller_versions: dict) return versions[0] return None - def get_report_accreditation( + def is_report_accredited( self, samples: list[SampleModel], analysis_metadata: BalsamicAnalysis ) -> bool: - """Checks if the report is accredited or not.""" + """Check if the Balsamic report is accredited.""" if analysis_metadata.config.analysis.sequencing_type == "targeted" and next( ( panel diff --git a/cg/meta/report/mip_dna.py b/cg/meta/report/mip_dna.py index a3763e420c..215daf9b48 100644 --- a/cg/meta/report/mip_dna.py +++ b/cg/meta/report/mip_dna.py @@ -79,10 +79,10 @@ def get_genome_build(self, analysis_metadata: MipAnalysis) -> str: """Return build version of the genome reference of a specific case.""" return analysis_metadata.genome_build - def get_report_accreditation( + def is_report_accredited( self, samples: list[SampleModel], analysis_metadata: MipAnalysis = None ) -> bool: - """Checks if the report is accredited or not by evaluating each of the sample process accreditations.""" + """Check if the MIP-DNA report is accredited by evaluating each of the sample process accreditations.""" for sample in samples: if not sample.application.accredited: return False diff --git a/cg/meta/report/report_api.py b/cg/meta/report/report_api.py index 9ca2057b10..974c282625 100644 --- a/cg/meta/report/report_api.py +++ b/cg/meta/report/report_api.py @@ -174,7 +174,7 @@ def get_report_data(self, case_id: str, analysis_date: datetime) -> ReportModel: version=self.get_report_version(analysis=analysis), date=datetime.today(), case=case_model, - accredited=self.get_report_accreditation( + accredited=self.is_report_accredited( samples=case_model.samples, analysis_metadata=analysis_metadata ), ) @@ -407,10 +407,10 @@ def get_variant_callers(self, _analysis_metadata: AnalysisModel) -> list: """Return list of variant-calling filters used during analysis.""" return [] - def get_report_accreditation( + def is_report_accredited( self, samples: list[SampleModel], analysis_metadata: AnalysisModel ) -> bool: - """Checks if the report is accredited or not.""" + """Check if the report is accredited.""" raise NotImplementedError def get_required_fields(self, case: CaseModel) -> dict: diff --git a/cg/meta/report/rnafusion.py b/cg/meta/report/rnafusion.py index 91a86e700b..4f2eeaaa99 100644 --- a/cg/meta/report/rnafusion.py +++ b/cg/meta/report/rnafusion.py @@ -79,10 +79,10 @@ def get_genome_build(self, analysis_metadata: AnalysisModel) -> str: """Return build version of the genome reference of a specific case.""" return GenomeVersion.hg38.value - def get_report_accreditation( + def is_report_accredited( self, samples: list[SampleModel], analysis_metadata: AnalysisModel ) -> bool: - """Checks if the report is accredited or not. Rnafusion is an accredited workflow.""" + """Check if the report is accredited. Rnafusion is an accredited workflow.""" return True def get_template_name(self) -> str: diff --git a/cg/meta/upload/scout/balsamic_config_builder.py b/cg/meta/upload/scout/balsamic_config_builder.py index b85e25ff5e..9906292db8 100644 --- a/cg/meta/upload/scout/balsamic_config_builder.py +++ b/cg/meta/upload/scout/balsamic_config_builder.py @@ -4,7 +4,8 @@ from cg.apps.lims import LimsAPI from cg.constants.constants import SampleType -from cg.constants.scout import BALSAMIC_CASE_TAGS, BALSAMIC_SAMPLE_TAGS +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG +from cg.constants.scout import BALSAMIC_CASE_TAGS, BALSAMIC_SAMPLE_TAGS, UploadTrack from cg.constants.subject import PhenotypeStatus from cg.meta.upload.scout.hk_tags import CaseTags, SampleTags from cg.meta.upload.scout.scout_config_builder import ScoutConfigBuilder @@ -22,7 +23,10 @@ def __init__(self, hk_version_obj: Version, analysis_obj: Analysis, lims_api: Li ) self.case_tags: CaseTags = CaseTags(**BALSAMIC_CASE_TAGS) self.sample_tags: SampleTags = SampleTags(**BALSAMIC_SAMPLE_TAGS) - self.load_config: BalsamicLoadConfig = BalsamicLoadConfig(track="cancer") + self.load_config: BalsamicLoadConfig = BalsamicLoadConfig( + track=UploadTrack.CANCER.value, + delivery_report=self.get_file_from_hk({HK_DELIVERY_REPORT_TAG}), + ) def include_case_files(self): LOG.info("Including BALSAMIC specific case level files") @@ -34,7 +38,6 @@ def include_case_files(self): ) self.include_cnv_report() self.include_multiqc_report() - self.include_delivery_report() def include_sample_files(self, config_sample: ScoutCancerIndividual) -> None: LOG.info("Including BALSAMIC specific sample level files.") diff --git a/cg/meta/upload/scout/balsamic_umi_config_builder.py b/cg/meta/upload/scout/balsamic_umi_config_builder.py index a816eede6f..b288417330 100644 --- a/cg/meta/upload/scout/balsamic_umi_config_builder.py +++ b/cg/meta/upload/scout/balsamic_umi_config_builder.py @@ -3,13 +3,11 @@ from housekeeper.store.models import Version from cg.apps.lims import LimsAPI -from cg.constants.scout import BALSAMIC_UMI_CASE_TAGS, BALSAMIC_UMI_SAMPLE_TAGS +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG +from cg.constants.scout import BALSAMIC_UMI_CASE_TAGS, BALSAMIC_UMI_SAMPLE_TAGS, UploadTrack from cg.meta.upload.scout.balsamic_config_builder import BalsamicConfigBuilder from cg.meta.upload.scout.hk_tags import CaseTags, SampleTags -from cg.models.scout.scout_load_config import ( - BalsamicUmiLoadConfig, - ScoutCancerIndividual, -) +from cg.models.scout.scout_load_config import BalsamicUmiLoadConfig, ScoutCancerIndividual from cg.store.models import Analysis, Sample LOG = logging.getLogger(__name__) @@ -22,12 +20,14 @@ def __init__(self, hk_version_obj: Version, analysis_obj: Analysis, lims_api: Li ) self.case_tags: CaseTags = CaseTags(**BALSAMIC_UMI_CASE_TAGS) self.sample_tags: SampleTags = SampleTags(**BALSAMIC_UMI_SAMPLE_TAGS) - self.load_config: BalsamicUmiLoadConfig = BalsamicUmiLoadConfig(track="cancer") + self.load_config: BalsamicUmiLoadConfig = BalsamicUmiLoadConfig( + track=UploadTrack.CANCER.value, + delivery_report=self.get_file_from_hk({HK_DELIVERY_REPORT_TAG}), + ) def include_sample_files(self, config_sample: ScoutCancerIndividual) -> None: LOG.info("Including BALSAMIC specific sample level files") def get_balsamic_analysis_type(self, sample: Sample) -> str: - """Returns a formatted balsamic analysis type""" - + """Returns a formatted balsamic analysis type.""" return "panel-umi" diff --git a/cg/meta/upload/scout/mip_config_builder.py b/cg/meta/upload/scout/mip_config_builder.py index 071abaee25..1e0d9bcaaa 100644 --- a/cg/meta/upload/scout/mip_config_builder.py +++ b/cg/meta/upload/scout/mip_config_builder.py @@ -6,17 +6,14 @@ from cg.apps.lims import LimsAPI from cg.apps.madeline.api import MadelineAPI -from cg.constants.scout import MIP_CASE_TAGS, MIP_SAMPLE_TAGS +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG +from cg.constants.scout import MIP_CASE_TAGS, MIP_SAMPLE_TAGS, UploadTrack from cg.constants.subject import RelationshipStatus from cg.meta.upload.scout.hk_tags import CaseTags, SampleTags from cg.meta.upload.scout.scout_config_builder import ScoutConfigBuilder from cg.meta.workflow.mip import MipAnalysisAPI from cg.models.mip.mip_analysis import MipAnalysis -from cg.models.scout.scout_load_config import ( - MipLoadConfig, - ScoutLoadConfig, - ScoutMipIndividual, -) +from cg.models.scout.scout_load_config import MipLoadConfig, ScoutLoadConfig, ScoutMipIndividual from cg.store.models import Analysis, Case, CaseSample LOG = logging.getLogger(__name__) @@ -36,7 +33,10 @@ def __init__( ) self.case_tags: CaseTags = CaseTags(**MIP_CASE_TAGS) self.sample_tags: SampleTags = SampleTags(**MIP_SAMPLE_TAGS) - self.load_config: MipLoadConfig = MipLoadConfig(track="rare") + self.load_config: MipLoadConfig = MipLoadConfig( + track=UploadTrack.RARE_DISEASE.value, + delivery_report=self.get_file_from_hk({HK_DELIVERY_REPORT_TAG}), + ) self.mip_analysis_api: MipAnalysisAPI = mip_analysis_api self.lims_api: LimsAPI = lims_api self.madeline_api: MadelineAPI = madeline_api @@ -116,7 +116,6 @@ def include_case_files(self): self.load_config.vcf_sv = self.get_file_from_hk(self.case_tags.sv_vcf) self.load_config.vcf_sv_research = self.get_file_from_hk(self.case_tags.sv_research_vcf) self.include_multiqc_report() - self.include_delivery_report() def include_sample_files(self, config_sample: ScoutMipIndividual) -> None: """Include sample level files that are optional for mip samples""" diff --git a/cg/meta/upload/scout/rnafusion_config_builder.py b/cg/meta/upload/scout/rnafusion_config_builder.py index b536d5bec1..0bd369ea78 100644 --- a/cg/meta/upload/scout/rnafusion_config_builder.py +++ b/cg/meta/upload/scout/rnafusion_config_builder.py @@ -4,7 +4,8 @@ from cg.apps.lims import LimsAPI from cg.constants.constants import PrepCategory -from cg.constants.scout import RNAFUSION_CASE_TAGS, RNAFUSION_SAMPLE_TAGS, GenomeBuild +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG +from cg.constants.scout import RNAFUSION_CASE_TAGS, RNAFUSION_SAMPLE_TAGS, GenomeBuild, UploadTrack from cg.meta.upload.scout.hk_tags import CaseTags, SampleTags from cg.meta.upload.scout.scout_config_builder import ScoutConfigBuilder from cg.models.scout.scout_load_config import ( @@ -26,7 +27,10 @@ def __init__(self, hk_version_obj: Version, analysis_obj: Analysis, lims_api: Li ) self.case_tags: CaseTags = CaseTags(**RNAFUSION_CASE_TAGS) self.sample_tags: SampleTags = SampleTags(**RNAFUSION_SAMPLE_TAGS) - self.load_config: RnafusionLoadConfig = RnafusionLoadConfig(track="cancer") + self.load_config: RnafusionLoadConfig = RnafusionLoadConfig( + track=UploadTrack.CANCER.value, + delivery_report=self.get_file_from_hk({HK_DELIVERY_REPORT_TAG}), + ) def build_load_config(self) -> None: """Build a rnafusion-specific load config for uploading a case to scout.""" diff --git a/cg/meta/upload/scout/scout_config_builder.py b/cg/meta/upload/scout/scout_config_builder.py index 1b095889a4..a50d14c205 100644 --- a/cg/meta/upload/scout/scout_config_builder.py +++ b/cg/meta/upload/scout/scout_config_builder.py @@ -6,12 +6,14 @@ from cg.apps.housekeeper.hk import HousekeeperAPI from cg.apps.lims import LimsAPI +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG from cg.meta.upload.scout.hk_tags import CaseTags, SampleTags from cg.models.scout.scout_load_config import ScoutIndividual, ScoutLoadConfig from cg.store.models import Analysis, CaseSample, Sample LOG = logging.getLogger(__name__) + # Maps keys that are used in scout load config on tags that are used in scout @@ -24,7 +26,9 @@ def __init__(self, hk_version_obj: Version, analysis_obj: Analysis, lims_api: Li self.lims_api: LimsAPI = lims_api self.case_tags: CaseTags self.sample_tags: SampleTags - self.load_config: ScoutLoadConfig = ScoutLoadConfig() + self.load_config: ScoutLoadConfig = ScoutLoadConfig( + delivery_report=self.get_file_from_hk({HK_DELIVERY_REPORT_TAG}) + ) def add_common_info_to_load_config(self) -> None: """Add the mandatory common information to a scout load config object""" @@ -137,12 +141,6 @@ def include_multiqc_report(self) -> None: hk_tags=self.case_tags.multiqc_report, latest=True ) - def include_delivery_report(self) -> None: - LOG.info("Include delivery report to case") - self.load_config.delivery_report = self.get_file_from_hk( - hk_tags=self.case_tags.delivery_report, latest=True - ) - def include_sample_alignment_file(self, config_sample: ScoutIndividual) -> None: """Include the alignment file for a sample diff --git a/cg/models/scout/scout_load_config.py b/cg/models/scout/scout_load_config.py index 3e275aad02..de6415cdfa 100644 --- a/cg/models/scout/scout_load_config.py +++ b/cg/models/scout/scout_load_config.py @@ -5,6 +5,7 @@ from pydantic import BaseModel, BeforeValidator, ConfigDict from typing_extensions import Annotated, Literal +from cg.constants.scout import UploadTrack from cg.models.scout.validators import field_not_none @@ -91,12 +92,13 @@ class ScoutLoadConfig(BaseModel): sv_rank_model_version: str | None = None analysis_date: datetime | None = None samples: list[ScoutIndividual] = [] - - delivery_report: str | None = None + delivery_report: str coverage_qc_report: str | None = None cnv_report: str | None = None multiqc: str | None = None - track: Literal["rare", "cancer"] = "rare" + track: Literal[ + UploadTrack.RARE_DISEASE.value, UploadTrack.CANCER.value + ] = UploadTrack.RARE_DISEASE.value model_config = ConfigDict(validate_assignment=True) diff --git a/tests/apps/scout/test_scout_load_config.py b/tests/apps/scout/test_scout_load_config.py index b97a613233..f732dc0193 100644 --- a/tests/apps/scout/test_scout_load_config.py +++ b/tests/apps/scout/test_scout_load_config.py @@ -1,4 +1,5 @@ -"""Tests for the models in scout load config""" +"""Tests for the models in Scout load config.""" +from pathlib import Path from typing import Any import pytest @@ -11,8 +12,10 @@ @pytest.mark.parametrize("key, value", list(SCOUT_INDIVIDUAL.items())) def test_validate_scout_individual_attributes(scout_individual: dict, key: str, value: Any): - """Test to validate that all attributes of a ScoutMipIndividual are correctly set.""" + """Test that all attributes of a ScoutMipIndividual are correctly set.""" + # GIVEN some sample information + # WHEN instantiating a ScoutMipIndividual ind_obj: ScoutMipIndividual = scout_load_config.ScoutMipIndividual(**scout_individual) @@ -20,26 +23,29 @@ def test_validate_scout_individual_attributes(scout_individual: dict, key: str, assert getattr(ind_obj, key) == value -def test_instantiate_empty_mip_config(): - """Tests whether a MipLoadConfig can be instantiate without arguments.""" - # GIVEN nothing +def test_instantiate_empty_mip_config(delivery_report_html: Path): + """Tests whether a MipLoadConfig can be instantiated only with mandatory arguments.""" + + # GIVEN a delivery report file - # WHEN instantiating a empty mip load config - config: MipLoadConfig = scout_load_config.MipLoadConfig() + # WHEN instantiating an empty MIP load config + config: MipLoadConfig = scout_load_config.MipLoadConfig( + delivery_report=delivery_report_html.as_posix() + ) - # THEN assert it is possible to instantiate without any information + # THEN assert it is possible to instantiate without any not mandatory information assert isinstance(config, scout_load_config.ScoutLoadConfig) -def test_set_mandatory_to_none(): - """The scout load config object should validate fields as they are set. +def test_set_mandatory_to_none(delivery_report_html: Path): + """Test that a value error is raised when a mandatory field is set to None.""" - This test will check that a value error is raised when a mandatory field is set to None. - """ # GIVEN a load config object - config: MipLoadConfig = scout_load_config.MipLoadConfig() + config: MipLoadConfig = scout_load_config.MipLoadConfig( + delivery_report=delivery_report_html.as_posix() + ) # WHEN setting a mandatory field to None with pytest.raises(ValidationError): - # THEN assert a validation error was raised + # THEN a validation error should be raised config.vcf_snv = None diff --git a/tests/cli/upload/conftest.py b/tests/cli/upload/conftest.py index 3bac71741b..d3ad48b1dd 100644 --- a/tests/cli/upload/conftest.py +++ b/tests/cli/upload/conftest.py @@ -28,12 +28,6 @@ from cg.models.scout.scout_load_config import ScoutLoadConfig from cg.store import Store from cg.store.models import Analysis -from tests.cli.workflow.mip.conftest import ( - mip_case_id, - mip_case_ids, - mip_dna_context, - mip_rna_context, -) from tests.meta.upload.scout.conftest import mip_load_config from tests.mocks.hk_mock import MockHousekeeperAPI from tests.mocks.madeline import MockMadelineAPI @@ -248,7 +242,9 @@ def __init__(self, **kwargs): self.housekeeper = None self.madeline_api = MockMadelineAPI() self.analysis = MockAnalysisApi() - self.config = ScoutLoadConfig() + self.config = ScoutLoadConfig( + delivery_report=Path("path", "to", "delivery-report.html").as_posix() + ) self.file_exists = False self.lims = MockLims() self.missing_mandatory_field = False diff --git a/tests/conftest.py b/tests/conftest.py index bc3f593a77..7031d7c179 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,6 +30,7 @@ from cg.constants import FileExtensions, Pipeline, SequencingFileTag from cg.constants.constants import CaseActions, FileFormat, Strandedness from cg.constants.demultiplexing import BclConverter, DemultiplexingDirsAndFiles +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG from cg.constants.nanopore_files import NanoporeDirsAndFiles from cg.constants.priority import SlurmQos from cg.constants.sequencing import SequencingPlatform @@ -1895,6 +1896,7 @@ def hk_bundle_sample_path(sample_id: str, timestamp: datetime) -> Path: def hk_bundle_data( case_id: str, bed_file: Path, + delivery_report_html: Path, timestamp_yesterday: datetime, sample_id: str, father_sample_id: str, @@ -1910,7 +1912,12 @@ def hk_bundle_data( "path": bed_file.as_posix(), "archive": False, "tags": ["bed", sample_id, father_sample_id, mother_sample_id, "coverage"], - } + }, + { + "path": delivery_report_html.as_posix(), + "archive": False, + "tags": [HK_DELIVERY_REPORT_TAG], + }, ], } diff --git a/tests/meta/report/test_balsamic_api.py b/tests/meta/report/test_balsamic_api.py index 2fc3954873..191b4e95ff 100644 --- a/tests/meta/report/test_balsamic_api.py +++ b/tests/meta/report/test_balsamic_api.py @@ -95,8 +95,8 @@ def test_get_variant_caller_version(report_api_balsamic, case_id): assert version == expected_version -def test_get_report_accreditation(report_api_balsamic, case_id): - """Tests report accreditation for a specific BALSAMIC analysis.""" +def test_is_report_accredited(report_api_balsamic, case_id): + """Test report accreditation for a specific BALSAMIC analysis.""" # GIVEN a mock metadata object and an accredited one balsamic_metadata = report_api_balsamic.analysis_api.get_latest_metadata(case_id) @@ -105,10 +105,8 @@ def test_get_report_accreditation(report_api_balsamic, case_id): balsamic_accredited_metadata.config.panel.capture_kit = "gmsmyeloid" # WHEN performing the accreditation validation - unaccredited_report = report_api_balsamic.get_report_accreditation(None, balsamic_metadata) - accredited_report = report_api_balsamic.get_report_accreditation( - None, balsamic_accredited_metadata - ) + unaccredited_report = report_api_balsamic.is_report_accredited(None, balsamic_metadata) + accredited_report = report_api_balsamic.is_report_accredited(None, balsamic_accredited_metadata) # THEN verify that only the panel "gmsmyeloid" reports are validated assert not unaccredited_report diff --git a/tests/meta/report/test_mip_dna_api.py b/tests/meta/report/test_mip_dna_api.py index c423c81434..e0f3c5e5dc 100644 --- a/tests/meta/report/test_mip_dna_api.py +++ b/tests/meta/report/test_mip_dna_api.py @@ -44,22 +44,22 @@ def test_get_sample_coverage(report_api_mip_dna, sample_store, helpers: StoreHel assert sample_coverage == {"mean_coverage": 37.342, "mean_completeness": 97.1} -def test_get_report_accreditation(report_api_mip_dna, mip_analysis_api, case_mip_dna): - """Verifies the report accreditation extraction workflow.""" +def test_is_report_accredited(report_api_mip_dna, mip_analysis_api, case_mip_dna): + """Test report accreditation extraction workflow.""" # GIVEN a list of accredited samples mip_metadata = mip_analysis_api.get_latest_metadata(case_mip_dna.internal_id) samples = report_api_mip_dna.get_samples_data(case_mip_dna, mip_metadata) # WHEN retrieving the report accreditation - accredited = report_api_mip_dna.get_report_accreditation(samples) + accredited = report_api_mip_dna.is_report_accredited(samples) # THEN check that the report is accredited assert accredited -def test_get_report_accreditation_false(report_api_mip_dna, mip_analysis_api, case_mip_dna): - """Verifies that the report is not accredited if it contains a sample application that is not accredited.""" +def test_is_report_accredited_false(report_api_mip_dna, mip_analysis_api, case_mip_dna): + """Test that the report is not accredited if it contains a sample application that is not accredited.""" # GIVEN a list of samples when one of them is not accredited mip_metadata = mip_analysis_api.get_latest_metadata(case_mip_dna.internal_id) @@ -67,7 +67,7 @@ def test_get_report_accreditation_false(report_api_mip_dna, mip_analysis_api, ca samples[0].application.accredited = False # WHEN retrieving the report accreditation - accredited = report_api_mip_dna.get_report_accreditation(samples) + accredited = report_api_mip_dna.is_report_accredited(samples) # THEN check that the report is not accredited assert not accredited diff --git a/tests/meta/upload/scout/conftest.py b/tests/meta/upload/scout/conftest.py index b0be71f190..b4f2f1e86b 100644 --- a/tests/meta/upload/scout/conftest.py +++ b/tests/meta/upload/scout/conftest.py @@ -1,5 +1,4 @@ """Fixtures for the upload Scout API tests.""" - import logging from datetime import datetime from pathlib import Path @@ -10,6 +9,8 @@ from cg.constants import DataDelivery, Pipeline from cg.constants.constants import FileFormat, PrepCategory +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG +from cg.constants.scout import UploadTrack from cg.constants.sequencing import SequencingMethod from cg.io.controller import ReadFile from cg.meta.upload.scout.balsamic_config_builder import BalsamicConfigBuilder @@ -241,6 +242,7 @@ def mip_dna_analysis_hk_bundle_data( sv_vcf_file: str, snv_research_vcf_file: str, sv_research_vcf_file: str, + delivery_report_html: Path, ) -> dict: """Return MIP DNA bundle data for Housekeeper.""" return { @@ -415,7 +417,7 @@ def balsamic_analysis_hk_bundle_data( @pytest.fixture(scope="function") def rnafusion_analysis_hk_bundle_data( - case_id: str, timestamp: datetime, rnafusion_analysis_dir: Path + case_id: str, timestamp: datetime, rnafusion_analysis_dir: Path, delivery_report_html: Path ) -> dict: """Get some bundle data for housekeeper.""" return { @@ -433,6 +435,11 @@ def rnafusion_analysis_hk_bundle_data( "archive": False, "tags": ["fusionreport", "research"], }, + { + "path": delivery_report_html.as_posix(), + "archive": False, + "tags": [HK_DELIVERY_REPORT_TAG], + }, ], } @@ -588,14 +595,19 @@ def balsamic_config_builder( @pytest.fixture(name="mip_load_config") def mip_load_config( - mip_dna_analysis_dir: Path, case_id: str, customer_id: str, snv_vcf_file: str + mip_dna_analysis_dir: Path, + case_id: str, + customer_id: str, + snv_vcf_file: str, + delivery_report_html: Path, ) -> MipLoadConfig: """Return a valid MIP load_config.""" return MipLoadConfig( owner=customer_id, family=case_id, vcf_snv=Path(mip_dna_analysis_dir, snv_vcf_file).as_posix(), - track="rare", + track=UploadTrack.RARE_DISEASE.value, + delivery_report=delivery_report_html.as_posix(), ) diff --git a/tests/meta/upload/scout/test_meta_upload_scoutapi.py b/tests/meta/upload/scout/test_meta_upload_scoutapi.py index d0e2f65aa0..7131f03317 100644 --- a/tests/meta/upload/scout/test_meta_upload_scoutapi.py +++ b/tests/meta/upload/scout/test_meta_upload_scoutapi.py @@ -9,7 +9,9 @@ from cg.models.scout.scout_load_config import MipLoadConfig, ScoutLoadConfig -def test_unlinked_family_is_linked(mip_config_builder: MipConfigBuilder): +def test_unlinked_family_is_linked( + mip_config_builder: MipConfigBuilder, delivery_report_html: Path +): """Test that is_family check fails when samples are not linked""" # GIVEN a upload scout api and case data for a case without linked individuals family_data: MipLoadConfig = MipLoadConfig( @@ -17,7 +19,8 @@ def test_unlinked_family_is_linked(mip_config_builder: MipConfigBuilder): "samples": [ {"sample_id": "ADM2", "father": "0", "mother": "0"}, {"sample_id": "ADM3", "father": "0", "mother": "0"}, - ] + ], + "delivery_report": delivery_report_html.as_posix(), } ) # WHEN running the check if case is linked @@ -26,7 +29,7 @@ def test_unlinked_family_is_linked(mip_config_builder: MipConfigBuilder): assert res is False -def test_family_is_linked(mip_config_builder: MipConfigBuilder): +def test_family_is_linked(mip_config_builder: MipConfigBuilder, delivery_report_html: Path): """Test that is_family returns true when samples are linked""" # GIVEN a upload scout api and case data for a linked case family_data: MipLoadConfig = MipLoadConfig( @@ -35,7 +38,8 @@ def test_family_is_linked(mip_config_builder: MipConfigBuilder): {"sample_id": "ADM1", "father": "ADM2", "mother": "ADM3"}, {"sample_id": "ADM2", "father": "0", "mother": "0"}, {"sample_id": "ADM3", "father": "0", "mother": "0"}, - ] + ], + "delivery_report": delivery_report_html.as_posix(), } ) # WHEN running the check if case is linked diff --git a/tests/meta/upload/scout/test_scout_config_builder.py b/tests/meta/upload/scout/test_scout_config_builder.py index 811298718a..eb6eae1b08 100644 --- a/tests/meta/upload/scout/test_scout_config_builder.py +++ b/tests/meta/upload/scout/test_scout_config_builder.py @@ -68,20 +68,6 @@ def test_rnafusion_config_builder( assert isinstance(file_handler.case_tags, CaseTags) -def test_include_delivery_report_mip(mip_config_builder: MipConfigBuilder): - """Test include delivery report.""" - # GIVEN a config builder with data - - # GIVEN a config without a delivery report - assert mip_config_builder.load_config.delivery_report is None - - # WHEN including the delivery report - mip_config_builder.include_delivery_report() - - # THEN assert that the delivery report was added - assert mip_config_builder.load_config.delivery_report is not None - - def test_include_synopsis(mip_config_builder: MipConfigBuilder): """Test include synopsis.""" # GIVEN a config builder with some data