From 75cc99e1a5ea3f59d047c2078b4eb5ffec1b74bd Mon Sep 17 00:00:00 2001 From: Henrik Stranneheim Date: Tue, 26 Nov 2024 09:00:55 +0100 Subject: [PATCH] Refactor prep category (#3961) ### Changed - Rename PrpeCategory to SeqLibPrepCategory - Move the class to sequencing.py under constants - Removed implicit import from constant/__init__.py - DRY: Removed SequencingMethod as it is dictated by SeqLibPrepCategory --- cg/apps/gens.py | 5 +- cg/apps/orderform/excel_orderform_parser.py | 2 +- cg/cli/workflow/balsamic/options.py | 2 +- cg/constants/__init__.py | 1 - cg/constants/constants.py | 10 --- cg/constants/observations.py | 7 +- cg/constants/report.py | 2 +- cg/constants/sequencing.py | 19 ++--- cg/meta/delivery_report/balsamic.py | 10 +-- cg/meta/delivery_report/raredisease.py | 7 +- .../observations/mip_dna_observations_api.py | 15 ++-- cg/meta/observations/observations_api.py | 4 +- .../raredisease_observations_api.py | 20 ++--- cg/meta/upload/balsamic/balsamic.py | 4 +- cg/meta/upload/gt.py | 10 ++- cg/meta/upload/scout/uploadscoutapi.py | 20 ++--- cg/meta/workflow/analysis.py | 2 +- cg/meta/workflow/balsamic.py | 2 +- cg/meta/workflow/raredisease.py | 2 +- cg/models/balsamic/metrics.py | 2 +- cg/models/delivery_report/metadata.py | 2 +- cg/models/delivery_report/validators.py | 5 +- cg/models/orders/samples.py | 4 +- .../deliver_files_service_factory.py | 4 +- .../store_fastq_order_service.py | 14 +--- .../quality_checks/utils.py | 4 +- cg/store/crud/read.py | 9 ++- .../filters/status_application_filters.py | 6 +- cg/store/models.py | 14 ++-- .../upload/test_cli_upload_observations.py | 19 +++-- tests/cli/workflow/balsamic/conftest.py | 79 ++++++++++--------- .../balsamic/test_cli_balsamic_config_case.py | 34 ++++---- tests/cli/workflow/balsamic/test_link.py | 4 +- tests/clients/janus/conftest.py | 5 +- tests/conftest.py | 14 ++-- .../observations_input_files_fixtures.py | 6 +- .../sequencing_qc_check_scenario.py | 22 +++--- .../sequencing_qc_fixtures.py | 30 +++---- .../test_mip_dna_observations_api.py | 18 +++-- .../observations/test_observations_api.py | 48 +++++++---- .../test_raredisease_observations_api.py | 18 +++-- tests/meta/upload/balsamic/test_balsamic.py | 8 +- tests/meta/upload/scout/conftest.py | 42 +++++----- .../scout/test_meta_upload_scoutapi_rna.py | 10 +-- tests/models/balsamic/conftest.py | 8 +- .../delivery_report/test_models_validators.py | 22 +++--- .../test_fastq_order_service.py | 8 +- .../test_sequencing_quality_checks_utils.py | 11 +-- tests/store/api/conftest.py | 2 - tests/store/crud/conftest.py | 21 ++--- tests/store/crud/read/test_read.py | 5 +- tests/store/crud/read/test_read_sample.py | 10 +-- .../filters/test_status_cases_filters.py | 6 +- 53 files changed, 343 insertions(+), 315 deletions(-) diff --git a/cg/apps/gens.py b/cg/apps/gens.py index 47a2a85881..a864631c17 100644 --- a/cg/apps/gens.py +++ b/cg/apps/gens.py @@ -2,7 +2,7 @@ import logging -from cg.constants.constants import PrepCategory +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.store.models import Case from cg.utils import Process from cg.utils.dict import get_list_from_dictionary @@ -51,7 +51,8 @@ def load( def is_suitable_for_upload(case: Case) -> bool: """Check if a cancer case supports Gens upload.""" return all( - sample.prep_category == PrepCategory.WHOLE_GENOME_SEQUENCING for sample in case.samples + sample.prep_category == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING + for sample in case.samples ) def __str__(self): diff --git a/cg/apps/orderform/excel_orderform_parser.py b/cg/apps/orderform/excel_orderform_parser.py index 69735ef39b..796150d6c4 100644 --- a/cg/apps/orderform/excel_orderform_parser.py +++ b/cg/apps/orderform/excel_orderform_parser.py @@ -25,7 +25,7 @@ class ExcelOrderformParser(OrderformParser): SHEET_NAMES: list[str] = ["Orderform", "orderform", "order form", "Order Form"] VALID_ORDERFORMS: list[str] = [ f"{Orderform.MIP_DNA}:{Orderform.get_current_orderform_version(Orderform.MIP_DNA)}", # Orderform MIP-DNA, Balsamic, sequencing only, MIP-RNA - f"{Orderform.MICROSALT}:{Orderform.get_current_orderform_version(Orderform.MICROSALT)}", # Microbial WGS + f"{Orderform.MICROSALT}:{Orderform.get_current_orderform_version(Orderform.MICROSALT)}", # Microbial WHOLE_GENOME_SEQUENCING f"{Orderform.RML}:{Orderform.get_current_orderform_version(Orderform.RML)}", # Orderform Ready made libraries (RML) f"{Orderform.METAGENOME}:{Orderform.get_current_orderform_version(Orderform.METAGENOME)}", # Microbial meta genomes f"{Orderform.SARS_COV_2}:{Orderform.get_current_orderform_version(Orderform.SARS_COV_2)}", # Orderform SARS-CoV-2 diff --git a/cg/cli/workflow/balsamic/options.py b/cg/cli/workflow/balsamic/options.py index 4c47c3a0f8..744393ee38 100644 --- a/cg/cli/workflow/balsamic/options.py +++ b/cg/cli/workflow/balsamic/options.py @@ -40,7 +40,7 @@ type=click.Path(exists=True), multiple=True, required=False, - help="VCF paths of clinical and/or cancer SNVs and SVs observations (WGS analysis only). Set this option to " + help="VCF paths of clinical and/or cancer SNVs and SVs observations (WHOLE_GENOME_SEQUENCING analysis only). Set this option to " "override the latest Loqusdb dump files.", ) diff --git a/cg/constants/__init__.py b/cg/constants/__init__.py index 9abb8faa9e..8901dbc8e6 100644 --- a/cg/constants/__init__.py +++ b/cg/constants/__init__.py @@ -9,7 +9,6 @@ STATUS_OPTIONS, DataDelivery, FileExtensions, - PrepCategory, SequencingRunDataAvailability, SexOptions, ) diff --git a/cg/constants/constants.py b/cg/constants/constants.py index 427621b7c7..210449a2c7 100644 --- a/cg/constants/constants.py +++ b/cg/constants/constants.py @@ -102,16 +102,6 @@ class CancerAnalysisType(StrEnum): TUMOR_WGS = auto() -class PrepCategory(StrEnum): - COVID: str = "cov" - MICROBIAL: str = "mic" - READY_MADE_LIBRARY: str = "rml" - TARGETED_GENOME_SEQUENCING: str = "tgs" - WHOLE_EXOME_SEQUENCING: str = "wes" - WHOLE_GENOME_SEQUENCING: str = "wgs" - WHOLE_TRANSCRIPTOME_SEQUENCING: str = "wts" - - class SexOptions(StrEnum): MALE: str = "male" FEMALE: str = "female" diff --git a/cg/constants/observations.py b/cg/constants/observations.py index a2e070e751..61cf6662d0 100644 --- a/cg/constants/observations.py +++ b/cg/constants/observations.py @@ -3,7 +3,7 @@ from enum import Enum, StrEnum from cg.constants.constants import CancerAnalysisType, CustomerId, Workflow -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory LOQUSDB_ID = "_id" LOQUSDB_SUPPORTED_WORKFLOWS = [Workflow.BALSAMIC, Workflow.MIP_DNA, Workflow.RAREDISEASE] @@ -14,7 +14,10 @@ CustomerId.CUST143, CustomerId.CUST147, ] -LOQUSDB_RARE_DISEASE_SEQUENCING_METHODS = [SequencingMethod.WGS, SequencingMethod.WES] +LOQUSDB_RARE_DISEASE_SEQUENCING_METHODS = [ + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, +] LOQUSDB_CANCER_SEQUENCING_METHODS = [ CancerAnalysisType.TUMOR_WGS, CancerAnalysisType.TUMOR_NORMAL_WGS, diff --git a/cg/constants/report.py b/cg/constants/report.py index 7117796536..95a4b5605d 100644 --- a/cg/constants/report.py +++ b/cg/constants/report.py @@ -227,7 +227,7 @@ "mean_length_r1", ] -# WTS metadata required fields (OPTIONAL: "rin", "dv200") +# WHOLE_TRANSCRIPTOME_SEQUENCING metadata required fields (OPTIONAL: "rin", "dv200") _REQUIRED_SAMPLE_METADATA_WTS_FIELDS: list[str] = _REQUIRED_SAMPLE_METADATA_SEQUENCING_FIELDS + [ "bias_5_3", "input_amount", diff --git a/cg/constants/sequencing.py b/cg/constants/sequencing.py index 21d48b643a..e22b9652ab 100644 --- a/cg/constants/sequencing.py +++ b/cg/constants/sequencing.py @@ -47,15 +47,6 @@ class Sequencers(StrEnum): } -class SequencingMethod(StrEnum): - """Sequencing method types.""" - - TGS: str = "tgs" - WES: str = "wes" - WGS: str = "wgs" - WTS: str = "wts" - - class Variants(StrEnum): """Type of variants.""" @@ -71,3 +62,13 @@ class RecordType(StrEnum): class SequencingPlatform(StrEnum): ILLUMINA: str = "ILLUMINA" OXFORD_NANOPORE: str = "OXFORD_NANOPORE" + + +class SeqLibraryPrepCategory(StrEnum): + COVID: str = "cov" + MICROBIAL: str = "mic" + READY_MADE_LIBRARY: str = "rml" + TARGETED_GENOME_SEQUENCING: str = "tgs" + WHOLE_EXOME_SEQUENCING: str = "wes" + WHOLE_GENOME_SEQUENCING: str = "wgs" + WHOLE_TRANSCRIPTOME_SEQUENCING: str = "wts" diff --git a/cg/meta/delivery_report/balsamic.py b/cg/meta/delivery_report/balsamic.py index fb715579ec..238d53ae28 100644 --- a/cg/meta/delivery_report/balsamic.py +++ b/cg/meta/delivery_report/balsamic.py @@ -28,11 +28,7 @@ BalsamicTargetedSampleMetadataModel, BalsamicWGSSampleMetadataModel, ) -from cg.models.delivery_report.report import ( - CaseModel, - ReportRequiredFields, - ScoutVariantsFiles, -) +from cg.models.delivery_report.report import CaseModel, ReportRequiredFields, ScoutVariantsFiles from cg.models.delivery_report.sample import SampleModel from cg.store.models import Bed, BedVersion, Case, Sample @@ -78,7 +74,7 @@ def get_panel_metadata( sample_metrics: BalsamicTargetedQCMetrics, analysis_metadata: BalsamicAnalysis, ) -> BalsamicTargetedSampleMetadataModel: - """Return report metadata for Balsamic TGS analysis.""" + """Return report metadata for Balsamic TARGETED_GENOME_SEQUENCING analysis.""" bed_version: BedVersion = self.status_db.get_bed_version_by_file_name( analysis_metadata.balsamic_config.panel.capture_kit ) @@ -105,7 +101,7 @@ def get_wgs_metadata( passed_initial_qc: bool | None, sample_metrics: BalsamicWGSQCMetrics, ) -> BalsamicWGSSampleMetadataModel: - """Return report metadata for Balsamic WGS analysis.""" + """Return report metadata for Balsamic WHOLE_GENOME_SEQUENCING analysis.""" return BalsamicWGSSampleMetadataModel( duplicates=sample_metrics.percent_duplication if sample_metrics else None, fold_80=sample_metrics.fold_80_base_penalty if sample_metrics else None, diff --git a/cg/meta/delivery_report/raredisease.py b/cg/meta/delivery_report/raredisease.py index 95d2526f75..6de6650bcf 100644 --- a/cg/meta/delivery_report/raredisease.py +++ b/cg/meta/delivery_report/raredisease.py @@ -1,7 +1,6 @@ """Raredisease Delivery Report API.""" from cg.clients.chanjo2.models import CoverageMetrics -from cg.constants.constants import PrepCategory from cg.constants.report import ( REQUIRED_APPLICATION_FIELDS, REQUIRED_CASE_FIELDS, @@ -15,14 +14,15 @@ REQUIRED_SAMPLE_TIMESTAMP_FIELDS, ) from cg.constants.scout import ScoutUploadKey +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.meta.delivery_report.data_validators import get_million_read_pairs from cg.meta.delivery_report.delivery_report_api import DeliveryReportAPI from cg.meta.workflow.raredisease import RarediseaseAnalysisAPI from cg.models.analysis import AnalysisModel, NextflowAnalysis -from cg.models.raredisease.raredisease import RarediseaseQCMetrics from cg.models.delivery_report.metadata import RarediseaseSampleMetadataModel from cg.models.delivery_report.report import CaseModel, ReportRequiredFields, ScoutVariantsFiles from cg.models.delivery_report.sample import SampleModel +from cg.models.raredisease.raredisease import RarediseaseQCMetrics from cg.store.models import Case, Sample @@ -85,7 +85,8 @@ def get_sample_metadata_required_fields(case: CaseModel) -> dict: for sample in case.samples: required_fields = ( REQUIRED_SAMPLE_METADATA_RAREDISEASE_WGS_FIELDS - if PrepCategory.WHOLE_GENOME_SEQUENCING in sample.application.prep_category.lower() + if SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING + in sample.application.prep_category.lower() else REQUIRED_SAMPLE_METADATA_RAREDISEASE_FIELDS ) required_sample_metadata_fields.update({sample.id: required_fields}) diff --git a/cg/meta/observations/mip_dna_observations_api.py b/cg/meta/observations/mip_dna_observations_api.py index 49a01c7063..77c3efc417 100644 --- a/cg/meta/observations/mip_dna_observations_api.py +++ b/cg/meta/observations/mip_dna_observations_api.py @@ -13,7 +13,7 @@ MipDNALoadParameters, MipDNAObservationsAnalysisTag, ) -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import CaseNotFoundError, LoqusdbDuplicateRecordError from cg.meta.observations.observations_api import ObservationsAPI from cg.meta.workflow.mip_dna import MipDNAAnalysisAPI @@ -64,10 +64,12 @@ def is_case_eligible_for_observations_upload(self, case: Case) -> bool: def set_loqusdb_instance(self, case_id: str) -> None: """Return the Loqusdb instance associated to the sequencing method.""" - sequencing_method: SequencingMethod = self.analysis_api.get_data_analysis_type(case_id) - loqusdb_instances: dict[SequencingMethod, LoqusdbInstance] = { - SequencingMethod.WGS: LoqusdbInstance.WGS, - SequencingMethod.WES: LoqusdbInstance.WES, + sequencing_method: SeqLibraryPrepCategory = self.analysis_api.get_data_analysis_type( + case_id + ) + loqusdb_instances: dict[SeqLibraryPrepCategory, LoqusdbInstance] = { + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING: LoqusdbInstance.WGS, + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING: LoqusdbInstance.WES, } self.loqusdb_api = self.get_loqusdb_api(loqusdb_instances[sequencing_method]) @@ -117,7 +119,8 @@ def get_observations_files_from_hk( self.housekeeper_api.files( version=hk_version.id, tags=[MipDNAObservationsAnalysisTag.SV_VCF] ).first() - if self.analysis_api.get_data_analysis_type(case_id) == SequencingMethod.WGS + if self.analysis_api.get_data_analysis_type(case_id) + == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING else None ), "profile_vcf_path": self.housekeeper_api.files( diff --git a/cg/meta/observations/observations_api.py b/cg/meta/observations/observations_api.py index 68671fe35f..bf9c8df0ab 100644 --- a/cg/meta/observations/observations_api.py +++ b/cg/meta/observations/observations_api.py @@ -11,7 +11,7 @@ from cg.constants.constants import CustomerId from cg.constants.observations import LoqusdbInstance from cg.constants.sample_sources import SourceType -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import LoqusdbUploadCaseError from cg.meta.workflow.analysis import AnalysisAPI from cg.models.cg_config import CGConfig, CommonAppConfig @@ -123,7 +123,7 @@ def is_customer_eligible_for_observations_upload(self, customer_id: str) -> bool def is_sequencing_method_eligible_for_observations_upload(self, case_id: str) -> bool: """Return whether a sequencing method is valid for observations upload.""" - sequencing_method: SequencingMethod | None = self.analysis_api.get_data_analysis_type( + sequencing_method: SeqLibraryPrepCategory | None = self.analysis_api.get_data_analysis_type( case_id ) if sequencing_method not in self.loqusdb_sequencing_methods: diff --git a/cg/meta/observations/raredisease_observations_api.py b/cg/meta/observations/raredisease_observations_api.py index dc49e10167..fa3476b9e0 100644 --- a/cg/meta/observations/raredisease_observations_api.py +++ b/cg/meta/observations/raredisease_observations_api.py @@ -13,11 +13,8 @@ RarediseaseLoadParameters, RarediseaseObservationsAnalysisTag, ) -from cg.constants.sequencing import SequencingMethod -from cg.exc import ( - CaseNotFoundError, - LoqusdbDuplicateRecordError, -) +from cg.constants.sequencing import SeqLibraryPrepCategory +from cg.exc import CaseNotFoundError, LoqusdbDuplicateRecordError from cg.meta.observations.observations_api import ObservationsAPI from cg.meta.workflow.raredisease import RarediseaseAnalysisAPI from cg.models.cg_config import CGConfig @@ -67,10 +64,12 @@ def is_case_eligible_for_observations_upload(self, case: Case) -> bool: def set_loqusdb_instance(self, case_id: str) -> None: """Set the Loqusdb instance associated to the sequencing method.""" - sequencing_method: SequencingMethod = self.analysis_api.get_data_analysis_type(case_id) - loqusdb_instances: dict[SequencingMethod, LoqusdbInstance] = { - SequencingMethod.WGS: LoqusdbInstance.WGS, - SequencingMethod.WES: LoqusdbInstance.WES, + sequencing_method: SeqLibraryPrepCategory = self.analysis_api.get_data_analysis_type( + case_id + ) + loqusdb_instances: dict[SeqLibraryPrepCategory, LoqusdbInstance] = { + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING: LoqusdbInstance.WGS, + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING: LoqusdbInstance.WES, } self.loqusdb_api = self.get_loqusdb_api(loqusdb_instances[sequencing_method]) @@ -119,7 +118,8 @@ def get_observations_files_from_hk( self.housekeeper_api.files( version=hk_version.id, tags=[RarediseaseObservationsAnalysisTag.SV_VCF] ).first() - if self.analysis_api.get_data_analysis_type(case_id) == SequencingMethod.WGS + if self.analysis_api.get_data_analysis_type(case_id) + == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING else None ), "profile_vcf_path": self.housekeeper_api.files( diff --git a/cg/meta/upload/balsamic/balsamic.py b/cg/meta/upload/balsamic/balsamic.py index 6af7da9d2f..c9ce637fba 100644 --- a/cg/meta/upload/balsamic/balsamic.py +++ b/cg/meta/upload/balsamic/balsamic.py @@ -12,7 +12,7 @@ from cg.cli.upload.observations import upload_observations_to_loqusdb from cg.cli.upload.scout import upload_to_scout from cg.constants import REPORT_SUPPORTED_DATA_DELIVERY, DataDelivery -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.meta.upload.gt import UploadGenotypesAPI from cg.meta.upload.upload_api import UploadAPI from cg.meta.workflow.balsamic import BalsamicAnalysisAPI @@ -61,7 +61,7 @@ def upload(self, ctx: click.Context, case: Case, restart: bool) -> None: # Observations upload if ( self.analysis_api.get_case_application_type(case_id=case.internal_id) - == SequencingMethod.WGS + == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING ): ctx.invoke(upload_observations_to_loqusdb, case_id=case.internal_id) else: diff --git a/cg/meta/upload/gt.py b/cg/meta/upload/gt.py index 96088b2a22..3e6576e2f9 100644 --- a/cg/meta/upload/gt.py +++ b/cg/meta/upload/gt.py @@ -5,9 +5,10 @@ from cg.apps.gt import GenotypeAPI from cg.apps.housekeeper.hk import HousekeeperAPI -from cg.constants.constants import FileExtensions, FileFormat, PrepCategory, Workflow +from cg.constants.constants import FileExtensions, FileFormat, Workflow from cg.constants.housekeeper_tags import GenotypeAnalysisTag, HkAnalysisMetricsTag from cg.constants.nf_analysis import RAREDISEASE_PREDICTED_SEX_METRIC +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import Sex from cg.io.controller import ReadFile from cg.models.deliverables.metric_deliverables import MetricsBase @@ -69,10 +70,13 @@ def upload(self, genotype_load_config: dict, replace: bool = False): @staticmethod def is_suitable_for_genotype_upload(case: Case) -> bool: - """Returns True if there are any non-tumor WGS samples in the case.""" + """Returns True if there are any non-tumor WHOLE_GENOME_SEQUENCING samples in the case.""" samples: list[Sample] = case.samples return any( - (not sample.is_tumour and PrepCategory.WHOLE_GENOME_SEQUENCING == sample.prep_category) + ( + not sample.is_tumour + and SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING == sample.prep_category + ) for sample in samples ) diff --git a/cg/meta/upload/scout/uploadscoutapi.py b/cg/meta/upload/scout/uploadscoutapi.py index 57d3dc46c1..17ec5b4492 100644 --- a/cg/meta/upload/scout/uploadscoutapi.py +++ b/cg/meta/upload/scout/uploadscoutapi.py @@ -11,13 +11,10 @@ from cg.apps.madeline.api import MadelineAPI from cg.apps.scout.scoutapi import ScoutAPI from cg.constants import HK_MULTIQC_HTML_TAG, Workflow -from cg.constants.constants import FileFormat, GenomeVersion, PrepCategory -from cg.constants.housekeeper_tags import ( - HK_DELIVERY_REPORT_TAG, - AlignmentFileTag, - AnalysisTag, -) +from cg.constants.constants import FileFormat, GenomeVersion +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG, AlignmentFileTag, AnalysisTag from cg.constants.scout import ScoutCustomCaseReportTags +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import CgDataError, HousekeeperBundleVersionMissingError from cg.io.controller import WriteFile from cg.meta.upload.scout.balsamic_config_builder import BalsamicConfigBuilder @@ -27,10 +24,7 @@ from cg.meta.upload.scout.rnafusion_config_builder import RnafusionConfigBuilder from cg.meta.upload.scout.scout_config_builder import ScoutConfigBuilder from cg.meta.workflow.analysis import AnalysisAPI -from cg.meta.workflow.utils.genome_build_helpers import ( - genome_to_scout_format, - get_genome_build, -) +from cg.meta.workflow.utils.genome_build_helpers import genome_to_scout_format, get_genome_build from cg.models.scout.scout_load_config import ScoutLoadConfig from cg.store.models import Analysis, Case, Customer, Sample from cg.store.store import Store @@ -765,9 +759,9 @@ def _get_application_prep_category( for sample in subject_id_samples if sample.prep_category in [ - PrepCategory.WHOLE_GENOME_SEQUENCING.value, - PrepCategory.TARGETED_GENOME_SEQUENCING.value, - PrepCategory.WHOLE_EXOME_SEQUENCING.value, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING.value, + SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING.value, + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING.value, ] ] diff --git a/cg/meta/workflow/analysis.py b/cg/meta/workflow/analysis.py index 9ec1725b31..e64d68db0d 100644 --- a/cg/meta/workflow/analysis.py +++ b/cg/meta/workflow/analysis.py @@ -215,7 +215,7 @@ def get_case_source_type(self, case_id: str) -> str | None: return source_types.pop() def has_case_only_exome_samples(self, case_id: str) -> bool: - """Returns True if the application type for all samples in a case is WES.""" + """Returns True if the application type for all samples in a case is WHOLE_EXOME_SEQUENCING.""" application_type: str = self.get_case_application_type(case_id) return application_type == AnalysisType.WHOLE_EXOME_SEQUENCING diff --git a/cg/meta/workflow/balsamic.py b/cg/meta/workflow/balsamic.py index 0a86cb7003..2c1b465db2 100644 --- a/cg/meta/workflow/balsamic.py +++ b/cg/meta/workflow/balsamic.py @@ -207,7 +207,7 @@ def get_verified_bed(self, panel_bed: str, sample_data: dict) -> str | None: raise BalsamicStartError("Multiple application types found in LIMS") if not application_types.issubset(self.__BALSAMIC_BED_APPLICATIONS): if panel_bed: - raise BalsamicStartError("Cannot set panel_bed for WGS sample!") + raise BalsamicStartError("Cannot set panel_bed for WHOLE_GENOME_SEQUENCING sample!") return None if panel_bed: return panel_bed.as_posix() diff --git a/cg/meta/workflow/raredisease.py b/cg/meta/workflow/raredisease.py index b85dae6782..98b62a97d9 100644 --- a/cg/meta/workflow/raredisease.py +++ b/cg/meta/workflow/raredisease.py @@ -94,7 +94,7 @@ def is_gene_panel_required(self) -> bool: 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 WGS. + 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: diff --git a/cg/models/balsamic/metrics.py b/cg/models/balsamic/metrics.py index c45ece2906..d38de99219 100644 --- a/cg/models/balsamic/metrics.py +++ b/cg/models/balsamic/metrics.py @@ -54,7 +54,7 @@ class BalsamicTargetedQCMetrics(BalsamicQCMetrics): class BalsamicWGSQCMetrics(BalsamicQCMetrics): - """BALSAMIC WGS QC metrics""" + """BALSAMIC WHOLE_GENOME_SEQUENCING QC metrics""" median_coverage: float | None = None pct_15x: float | None = None diff --git a/cg/models/delivery_report/metadata.py b/cg/models/delivery_report/metadata.py index f18e0945fe..4d57103a39 100644 --- a/cg/models/delivery_report/metadata.py +++ b/cg/models/delivery_report/metadata.py @@ -122,7 +122,7 @@ class SequencingSampleMetadataModel(SampleMetadataModel): class WTSSampleMetadataModel(SequencingSampleMetadataModel): - """Metrics and trending data model associated to a WTS sample. + """Metrics and trending data model associated to a WHOLE_TRANSCRIPTOME_SEQUENCING sample. Attributes: bias_5_3: bias is the ratio between read counts; source: workflow diff --git a/cg/models/delivery_report/validators.py b/cg/models/delivery_report/validators.py index 7a89c46406..e37ff3c36f 100644 --- a/cg/models/delivery_report/validators.py +++ b/cg/models/delivery_report/validators.py @@ -13,8 +13,9 @@ REPORT_SEX, YES_FIELD, ) -from cg.constants.constants import PrepCategory, Workflow +from cg.constants.constants import Workflow from cg.constants.report import REPORT_QC_FLAG +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import Sex from cg.models.delivery.delivery import DeliveryFile from cg.models.orders.constants import OrderType @@ -81,7 +82,7 @@ def get_sex_as_string(sex: Sex | None) -> str: return get_report_string(REPORT_SEX.get(sex)) -def get_prep_category_as_string(prep_category: PrepCategory | None) -> str: +def get_prep_category_as_string(prep_category: SeqLibraryPrepCategory | None) -> str: """Return a report validated prep category as string.""" if prep_category == OrderType.RML: LOG.error("The delivery report generation does not support RML samples") diff --git a/cg/models/orders/samples.py b/cg/models/orders/samples.py index c7b4c1c738..66c4d620d8 100644 --- a/cg/models/orders/samples.py +++ b/cg/models/orders/samples.py @@ -257,7 +257,7 @@ class TaxprofilerSample(MetagenomeSample): class MicrobialSample(OrderInSample): - # 1603 Orderform Microbial WGS + # 1603 Orderform Microbial WHOLE_GENOME_SEQUENCING # "These fields are required" organism: constr(max_length=Organism.internal_id.property.columns[0].type.length) reference_genome: constr(max_length=Sample.reference_genome.property.columns[0].type.length) @@ -287,7 +287,7 @@ class MicrobialFastqSample(OrderInSample): class MicrosaltSample(MicrobialSample): _suitable_project = OrderType.MICROSALT - # 1603 Orderform Microbial WGS + # 1603 Orderform Microbial WHOLE_GENOME_SEQUENCING class SarsCov2Sample(MicrobialSample): diff --git a/cg/services/deliver_files/deliver_files_service/deliver_files_service_factory.py b/cg/services/deliver_files/deliver_files_service/deliver_files_service_factory.py index 5b616d67ec..45854fce29 100644 --- a/cg/services/deliver_files/deliver_files_service/deliver_files_service_factory.py +++ b/cg/services/deliver_files/deliver_files_service/deliver_files_service_factory.py @@ -5,7 +5,7 @@ from cg.apps.housekeeper.hk import HousekeeperAPI from cg.apps.tb import TrailblazerAPI from cg.constants import DataDelivery, Workflow -from cg.constants.constants import PrepCategory +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.services.analysis_service.analysis_service import AnalysisService from cg.services.deliver_files.deliver_files_service.deliver_files_service import ( DeliverFilesService, @@ -125,7 +125,7 @@ def _convert_workflow(self, case: Case) -> Workflow: microbial_tags: list[str] = [ application.tag for application in self.store.get_active_applications_by_prep_category( - prep_category=PrepCategory.MICROBIAL + prep_category=SeqLibraryPrepCategory.MICROBIAL ) ] if case.data_analysis == Workflow.RAW_DATA and tag in microbial_tags: diff --git a/cg/services/orders/store_order_services/store_fastq_order_service.py b/cg/services/orders/store_order_services/store_fastq_order_service.py index cea2dee788..8699c7a4b4 100644 --- a/cg/services/orders/store_order_services/store_fastq_order_service.py +++ b/cg/services/orders/store_order_services/store_fastq_order_service.py @@ -2,20 +2,14 @@ from datetime import datetime from cg.constants import DataDelivery, GenePanelMasterList, Priority, Workflow -from cg.constants.constants import CustomerId, PrepCategory +from cg.constants.constants import CustomerId +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import OrderError from cg.models.orders.order import OrderIn from cg.models.orders.sample_base import StatusEnum from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService from cg.services.orders.submitters.order_submitter import StoreOrderService -from cg.store.models import ( - ApplicationVersion, - Case, - CaseSample, - Customer, - Order, - Sample, -) +from cg.store.models import ApplicationVersion, Case, CaseSample, Customer, Order, Sample from cg.store.store import Store LOG = logging.getLogger(__name__) @@ -141,7 +135,7 @@ def store_items_in_status( ) if ( not new_sample.is_tumour - and new_sample.prep_category == PrepCategory.WHOLE_GENOME_SEQUENCING + and new_sample.prep_category == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING ): self.create_maf_case(sample_obj=new_sample, order=status_db_order) case.customer = customer diff --git a/cg/services/sequencing_qc_service/quality_checks/utils.py b/cg/services/sequencing_qc_service/quality_checks/utils.py index ed6e3b03ef..c19aa04cc1 100644 --- a/cg/services/sequencing_qc_service/quality_checks/utils.py +++ b/cg/services/sequencing_qc_service/quality_checks/utils.py @@ -1,7 +1,7 @@ import logging -from cg.constants.constants import PrepCategory from cg.constants.priority import Priority +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.store.models import Case, Sample LOG = logging.getLogger(__name__) @@ -104,7 +104,7 @@ def get_express_reads_threshold_for_sample(sample: Sample) -> int: def is_sample_ready_made_library(sample: Sample) -> bool: - return sample.prep_category == PrepCategory.READY_MADE_LIBRARY + return sample.prep_category == SeqLibraryPrepCategory.READY_MADE_LIBRARY def is_case_ready_made_library(case: Case) -> bool: diff --git a/cg/store/crud/read.py b/cg/store/crud/read.py index 6dbdc85ded..209d0f35d2 100644 --- a/cg/store/crud/read.py +++ b/cg/store/crud/read.py @@ -8,7 +8,8 @@ from sqlalchemy.orm import Query, Session from cg.constants import SequencingRunDataAvailability, Workflow -from cg.constants.constants import CaseActions, CustomerId, PrepCategory, SampleType +from cg.constants.constants import CaseActions, CustomerId, SampleType +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import CaseNotFoundError, CgError, OrderNotFoundError, SampleNotFoundError from cg.models.orders.constants import OrderType from cg.server.dto.samples.collaborator_samples_request import CollaboratorSamplesRequest @@ -601,7 +602,7 @@ def get_ready_made_library_expected_reads(self, case_id: str) -> int: application: Application = self.get_application_by_case(case_id=case_id) - if application.prep_category != PrepCategory.READY_MADE_LIBRARY.value: + if application.prep_category != SeqLibraryPrepCategory.READY_MADE_LIBRARY.value: raise ValueError( f"{case_id} is not a ready made library, found prep category: " f"{application.prep_category}" @@ -863,7 +864,7 @@ def get_current_application_version_by_tag(self, tag: str) -> ApplicationVersion ).first() def get_active_applications_by_prep_category( - self, prep_category: PrepCategory + self, prep_category: SeqLibraryPrepCategory ) -> list[Application]: """Return all active applications by prep category.""" return apply_application_filter( @@ -1583,7 +1584,7 @@ def get_case_ids_for_samples(self, sample_ids: list[int]) -> list[str]: def get_related_samples( self, sample_internal_id: str, - prep_categories: list[PrepCategory], + prep_categories: list[SeqLibraryPrepCategory], collaborators: set[Customer], ) -> list[Sample]: """Returns a list of samples with the same subject_id, tumour status and within the collaborators of a given sample and within the given list of prep categories.""" diff --git a/cg/store/filters/status_application_filters.py b/cg/store/filters/status_application_filters.py index 727f4c00fd..02d0bb0172 100644 --- a/cg/store/filters/status_application_filters.py +++ b/cg/store/filters/status_application_filters.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import Query -from cg.constants import PrepCategory +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.store.models import Application @@ -32,7 +32,7 @@ def filter_applications_has_versions(applications: Query, **kwargs) -> Query: def filter_application_by_prep_categories( - applications: Query, prep_categories: list[PrepCategory], **kwargs + applications: Query, prep_categories: list[SeqLibraryPrepCategory], **kwargs ) -> Query: """Return application corresponding to dna sequencing.""" return applications.filter(Application.prep_category.in_(prep_categories)) @@ -42,7 +42,7 @@ def apply_application_filter( filter_functions: list[Callable], applications: Query, tag: str = None, - prep_categories: list[PrepCategory] = None, + prep_categories: list[SeqLibraryPrepCategory] = None, ) -> Query: """Apply filtering functions to the sample queries and return filtered results.""" diff --git a/cg/store/models.py b/cg/store/models.py index 05192ae430..f2fb0fccc6 100644 --- a/cg/store/models.py +++ b/cg/store/models.py @@ -25,13 +25,13 @@ from cg.constants.constants import ( CaseActions, ControlOptions, - PrepCategory, SequencingQCStatus, SexOptions, StatusOptions, ) from cg.constants.devices import DeviceType from cg.constants.priority import SlurmQos +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.symbols import EMPTY_STRING from cg.models.orders.constants import OrderType @@ -146,7 +146,7 @@ class Application(Base): tag: Mapped[UniqueStr] prep_category: Mapped[str] = mapped_column( - types.Enum(*(category.value for category in PrepCategory)) + types.Enum(*(category.value for category in SeqLibraryPrepCategory)) ) is_external: Mapped[bool] = mapped_column(default=False) description: Mapped[Str256] @@ -211,13 +211,13 @@ def expected_reads(self): @property def analysis_type(self) -> str: - if self.prep_category == PrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING.value: - return PrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING.value + if self.prep_category == SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING.value: + return SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING.value return ( - PrepCategory.WHOLE_GENOME_SEQUENCING.value - if self.prep_category == PrepCategory.WHOLE_GENOME_SEQUENCING.value - else PrepCategory.WHOLE_EXOME_SEQUENCING.value + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING.value + if self.prep_category == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING.value + else SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING.value ) def to_dict(self): diff --git a/tests/cli/upload/test_cli_upload_observations.py b/tests/cli/upload/test_cli_upload_observations.py index 9c9fc0173c..b7a2539843 100644 --- a/tests/cli/upload/test_cli_upload_observations.py +++ b/tests/cli/upload/test_cli_upload_observations.py @@ -7,13 +7,10 @@ from click.testing import CliRunner from cg.cli.upload.observations import upload_observations_to_loqusdb -from cg.cli.upload.observations.utils import ( - get_observations_api, - get_observations_verified_case, -) +from cg.cli.upload.observations.utils import get_observations_api, get_observations_verified_case from cg.constants import EXIT_SUCCESS from cg.constants.constants import Workflow -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import PhenotypeStatus from cg.exc import CaseNotFoundError from cg.meta.observations.mip_dna_observations_api import MipDNAObservationsAPI @@ -34,7 +31,9 @@ def test_observations( # GIVEN a case ready to be uploaded to Loqusdb case: Case = helpers.add_case(store) case.customer.loqus_upload = True - sample: Sample = helpers.add_sample(store, application_type=SequencingMethod.WES) + sample: Sample = helpers.add_sample( + store, application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING + ) link: CaseSample = store.relate_sample(case=case, sample=sample, status=PhenotypeStatus.UNKNOWN) store.session.add(link) @@ -96,7 +95,9 @@ def test_get_observations_api(cg_context: CGConfig, helpers: StoreHelpers): # GIVEN a Loqusdb supported case case: Case = helpers.add_case(store, data_analysis=Workflow.MIP_DNA) - sample: Sample = helpers.add_sample(store, application_type=SequencingMethod.WES) + sample: Sample = helpers.add_sample( + store, application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING + ) link: CaseSample = store.relate_sample(case=case, sample=sample, status=PhenotypeStatus.UNKNOWN) store.session.add(link) @@ -116,7 +117,9 @@ def test_get_observations_api_raredisease(cg_context: CGConfig, helpers: StoreHe # GIVEN a Loqusdb supported case case: Case = helpers.add_case(store, data_analysis=Workflow.RAREDISEASE) - sample: Sample = helpers.add_sample(store, application_type=SequencingMethod.WES) + sample: Sample = helpers.add_sample( + store, application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING + ) case_sample: CaseSample = store.relate_sample( case=case, sample=sample, status=PhenotypeStatus.UNKNOWN ) diff --git a/tests/cli/workflow/balsamic/conftest.py b/tests/cli/workflow/balsamic/conftest.py index cacea02634..907c9de25b 100644 --- a/tests/cli/workflow/balsamic/conftest.py +++ b/tests/cli/workflow/balsamic/conftest.py @@ -8,11 +8,12 @@ from cg.apps.housekeeper.hk import HousekeeperAPI from cg.constants import SequencingFileTag, Workflow -from cg.constants.constants import CaseActions, FileFormat, PrepCategory +from cg.constants.constants import CaseActions, FileFormat +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.io.controller import WriteFile from cg.meta.workflow.balsamic import BalsamicAnalysisAPI from cg.models.cg_config import CGConfig -from cg.store.models import ApplicationVersion, Sample +from cg.store.models import Sample from cg.store.store import Store from tests.mocks.limsmock import MockLimsAPI from tests.mocks.tb_mock import MockTB @@ -309,7 +310,7 @@ def balsamic_context( helpers.ensure_application_version( store=status_db, application_tag="TGSA", - prep_category=PrepCategory.TARGETED_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, target_reads=10, ) @@ -317,7 +318,7 @@ def balsamic_context( helpers.ensure_application_version( store=status_db, application_tag="WESA", - prep_category=PrepCategory.WHOLE_EXOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, target_reads=10, ) @@ -325,7 +326,7 @@ def balsamic_context( helpers.ensure_application_version( store=status_db, application_tag="WGSA", - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, target_reads=10, ) @@ -337,7 +338,7 @@ def balsamic_context( target_reads=10, ) - # Create textbook case for WGS PAIRED with enough reads + # Create textbook case for WHOLE_GENOME_SEQUENCING PAIRED with enough reads case_wgs_paired_enough_reads = helpers.add_case( store=status_db, internal_id="balsamic_case_wgs_paired_enough_reads", @@ -347,7 +348,7 @@ def balsamic_context( ) sample_case_wgs_paired_tumor_enough_reads = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, internal_id="sample_case_wgs_paired_tumor_enough_reads", reads=10, @@ -355,7 +356,7 @@ def balsamic_context( ) sample_case_wgs_paired_normal_enough_reads = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=False, internal_id="sample_case_wgs_paired_normal_enough_reads", reads=10, @@ -372,7 +373,7 @@ def balsamic_context( sample=sample_case_wgs_paired_normal_enough_reads, ) - # Create textbook case for WGS PAIRED + # Create textbook case for WHOLE_GENOME_SEQUENCING PAIRED case_wgs_paired = helpers.add_case( store=status_db, internal_id="balsamic_case_wgs_paired", @@ -382,7 +383,7 @@ def balsamic_context( ) sample_case_wgs_paired_tumor = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, internal_id="sample_case_wgs_paired_tumor", reads=10, @@ -390,7 +391,7 @@ def balsamic_context( ) sample_case_wgs_paired_normal = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=False, internal_id="sample_case_wgs_paired_normal", reads=10, @@ -399,7 +400,7 @@ def balsamic_context( helpers.add_relationship(status_db, case=case_wgs_paired, sample=sample_case_wgs_paired_tumor) helpers.add_relationship(status_db, case=case_wgs_paired, sample=sample_case_wgs_paired_normal) - # Create textbook case for TGS PAIRED without enough reads + # Create textbook case for TARGETED_GENOME_SEQUENCING PAIRED without enough reads case_tgs_paired = helpers.add_case( status_db, internal_id="balsamic_case_tgs_paired", @@ -409,7 +410,7 @@ def balsamic_context( sample_case_tgs_paired_tumor = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=True, internal_id="sample_case_tgs_paired_tumor", reads=10, @@ -418,7 +419,7 @@ def balsamic_context( sample_case_tgs_paired_normal = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=False, internal_id="sample_case_tgs_paired_normal", reads=0, @@ -427,7 +428,7 @@ def balsamic_context( helpers.add_relationship(status_db, case=case_tgs_paired, sample=sample_case_tgs_paired_tumor) helpers.add_relationship(status_db, case=case_tgs_paired, sample=sample_case_tgs_paired_normal) - # Create textbook case for WGS TUMOR ONLY + # Create textbook case for WHOLE_GENOME_SEQUENCING TUMOR ONLY case_wgs_single = helpers.add_case( status_db, internal_id="balsamic_case_wgs_single", @@ -436,7 +437,7 @@ def balsamic_context( ) sample_case_wgs_single_tumor = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, internal_id="sample_case_wgs_single_tumor", reads=100, @@ -444,7 +445,7 @@ def balsamic_context( ) helpers.add_relationship(status_db, case=case_wgs_single, sample=sample_case_wgs_single_tumor) - # Create textbook case for TGS TUMOR ONLY + # Create textbook case for TARGETED_GENOME_SEQUENCING TUMOR ONLY case_tgs_single = helpers.add_case( status_db, internal_id="balsamic_case_tgs_single", @@ -454,14 +455,14 @@ def balsamic_context( sample_case_tgs_single_tumor = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=True, internal_id="sample_case_tgs_single_tumor", last_sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_tgs_single, sample=sample_case_tgs_single_tumor) - # Create ERROR case for TGS NORMAL ONLY + # Create ERROR case for TARGETED_GENOME_SEQUENCING NORMAL ONLY case_tgs_single_error = helpers.add_case( status_db, internal_id="balsamic_case_tgs_single_error", @@ -471,7 +472,7 @@ def balsamic_context( sample_case_tgs_single_normal_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=False, internal_id="sample_case_tgs_single_normal_error", reads=0, @@ -483,7 +484,7 @@ def balsamic_context( sample=sample_case_tgs_single_normal_error, ) - # Create ERROR case for TGS TWO TUMOR ONE NORMAL + # Create ERROR case for TARGETED_GENOME_SEQUENCING TWO TUMOR ONE NORMAL case_tgs_paired_error = helpers.add_case( status_db, internal_id="balsamic_case_tgs_paired_error", @@ -493,7 +494,7 @@ def balsamic_context( sample_case_tgs_paired_tumor_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=True, reads=0, internal_id="sample_case_tgs_paired_tumor_error", @@ -502,7 +503,7 @@ def balsamic_context( sample_case_tgs_paired_tumor2_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=True, reads=0, internal_id="sample_case_tgs_paired_tumor2_error", @@ -511,7 +512,7 @@ def balsamic_context( sample_case_tgs_paired_normal_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=False, reads=0, internal_id="sample_case_tgs_paired_normal_error", @@ -542,7 +543,7 @@ def balsamic_context( ) mixed_sample_case_wgs_paired_tumor_error = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, reads=0, internal_id="mixed_sample_case_wgs_paired_tumor_error", @@ -551,7 +552,7 @@ def balsamic_context( mixed_sample_case_tgs_paired_normal_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=False, reads=0, internal_id="mixed_sample_case_tgs_paired_normal_error", @@ -577,7 +578,7 @@ def balsamic_context( ) mixed_sample_case_wgs_mic_paired_tumor_error = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, internal_id="mixed_sample_case_wgs_mic_paired_tumor_error", reads=0, @@ -613,7 +614,7 @@ def balsamic_context( mixed_sample_case_mixed_bed_paired_tumor_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=True, internal_id="mixed_sample_case_mixed_bed_paired_tumor_error", last_sequenced_at=dt.datetime.now(), @@ -621,7 +622,7 @@ def balsamic_context( mixed_sample_case_mixed_bed_paired_normal_error = helpers.add_sample( status_db, application_tag="TGSA", - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, is_tumour=False, internal_id="mixed_sample_case_mixed_bed_paired_normal_error", reads=0, @@ -638,7 +639,7 @@ def balsamic_context( sample=mixed_sample_case_mixed_bed_paired_normal_error, ) - # Create ERROR case for WGS TUMOR ONLY MIP CLI_OPTION_ANALYSIS ONLY + # Create ERROR case for WHOLE_GENOME_SEQUENCING TUMOR ONLY MIP CLI_OPTION_ANALYSIS ONLY mip_case_wgs_single = helpers.add_case( status_db, internal_id="mip_case_wgs_single", @@ -647,7 +648,7 @@ def balsamic_context( ) mip_sample_case_wgs_single_tumor = helpers.add_sample( status_db, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, internal_id="mip_sample_case_wgs_single_tumor", last_sequenced_at=dt.datetime.now(), @@ -658,7 +659,7 @@ def balsamic_context( sample=mip_sample_case_wgs_single_tumor, ) - # Create ERROR case for WGS ONE TUMOR TWO NORMAL + # Create ERROR case for WHOLE_GENOME_SEQUENCING ONE TUMOR TWO NORMAL case_wgs_paired_two_normal_error = helpers.add_case( status_db, internal_id="balsamic_case_wgs_paired_two_normal_error", @@ -668,7 +669,7 @@ def balsamic_context( sample_case_wgs_paired_two_normal_tumor_error = helpers.add_sample( status_db, application_tag="WGSA", - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, internal_id="sample_case_wgs_paired_two_normal_tumor_error", reads=0, @@ -677,7 +678,7 @@ def balsamic_context( sample_case_wgs_paired_two_normal_normal1_error = helpers.add_sample( status_db, application_tag="WGSA", - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=False, internal_id="sample_case_wgs_paired_two_normal_normal1_error", reads=0, @@ -686,7 +687,7 @@ def balsamic_context( sample_case_wgs_paired_two_normal_normal2_error = helpers.add_sample( status_db, application_tag="WGSA", - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=False, internal_id="sample_case_wgs_paired_two_normal_normal2_error", reads=0, @@ -708,7 +709,7 @@ def balsamic_context( sample=sample_case_wgs_paired_two_normal_normal2_error, ) - # Create WES case with 1 tumor sample + # Create WHOLE_EXOME_SEQUENCING case with 1 tumor sample case_wes_tumor = helpers.add_case( status_db, internal_id="balsamic_case_wes_tumor", @@ -718,14 +719,14 @@ def balsamic_context( sample_case_wes_tumor = helpers.add_sample( status_db, application_tag="WESA", - application_type=PrepCategory.WHOLE_EXOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, is_tumour=True, internal_id="sample_case_wes_tumor", last_sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_wes_tumor, sample=sample_case_wes_tumor) - # Create ERROR case for WES when no panel is found + # Create ERROR case for WHOLE_EXOME_SEQUENCING when no panel is found case_wes_panel_error = helpers.add_case( status_db, internal_id="balsamic_case_wes_panel_error", @@ -735,7 +736,7 @@ def balsamic_context( sample_case_wes_panel_error = helpers.add_sample( status_db, application_tag="WESA", - application_type=PrepCategory.WHOLE_EXOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, is_tumour=True, internal_id="sample_case_wes_panel_error", reads=0, diff --git a/tests/cli/workflow/balsamic/test_cli_balsamic_config_case.py b/tests/cli/workflow/balsamic/test_cli_balsamic_config_case.py index bc8f811702..89eb9c7c57 100644 --- a/tests/cli/workflow/balsamic/test_cli_balsamic_config_case.py +++ b/tests/cli/workflow/balsamic/test_cli_balsamic_config_case.py @@ -117,9 +117,9 @@ def test_target_bed_from_lims( def test_paired_wgs(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture): - """Test with case_id that requires PAIRED WGS analysis.""" + """Test with case_id that requires PAIRED WHOLE_GENOME_SEQUENCING analysis.""" caplog.set_level(logging.INFO) - # GIVEN case_id containing ONE tumor, ONE normal, WGS application + # GIVEN case_id containing ONE tumor, ONE normal, WHOLE_GENOME_SEQUENCING application case_id = "balsamic_case_wgs_paired" # WHEN dry running result = cli_runner.invoke(config_case, [case_id, "--dry-run"], obj=balsamic_context) @@ -133,9 +133,9 @@ def test_paired_wgs(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: L def test_paired_panel(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture): - """Test with case_id that requires PAIRED TGS analysis.""" + """Test with case_id that requires PAIRED TARGETED_GENOME_SEQUENCING analysis.""" caplog.set_level(logging.INFO) - # GIVEN case_id containing ONE tumor, ONE normal, TGS application + # GIVEN case_id containing ONE tumor, ONE normal, TARGETED_GENOME_SEQUENCING application case_id = "balsamic_case_tgs_paired" # WHEN dry running result = cli_runner.invoke(config_case, [case_id, "--dry-run"], obj=balsamic_context) @@ -177,9 +177,9 @@ def test_pon_cnn( def test_single_wgs(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture): - """Test with case_id that requires SINGLE WGS analysis.""" + """Test with case_id that requires SINGLE WHOLE_GENOME_SEQUENCING analysis.""" caplog.set_level(logging.INFO) - # GIVEN case_id containing ONE tumor, WGS application + # GIVEN case_id containing ONE tumor, WHOLE_GENOME_SEQUENCING application case_id = "balsamic_case_wgs_single" # WHEN dry running result = cli_runner.invoke(config_case, [case_id, "--dry-run"], obj=balsamic_context) @@ -194,9 +194,9 @@ def test_single_wgs(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: L def test_single_panel(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture): - """Test with case_id that requires SINGLE TGS analysis.""" + """Test with case_id that requires SINGLE TARGETED_GENOME_SEQUENCING analysis.""" caplog.set_level(logging.INFO) - # GIVEN case_id containing ONE tumor, TGS application + # GIVEN case_id containing ONE tumor, TARGETED_GENOME_SEQUENCING application case_id = "balsamic_case_tgs_single" # WHEN dry running result = cli_runner.invoke(config_case, [case_id, "--dry-run"], obj=balsamic_context) @@ -213,9 +213,9 @@ def test_single_panel(balsamic_context: CGConfig, cli_runner: CliRunner, caplog: def test_error_single_wgs_panel_arg( balsamic_context: CGConfig, cg_dir: Path, cli_runner: CliRunner, caplog: LogCaptureFixture ): - """Test with case_id that requires SINGLE WGS analysis and --panel-bed argument.""" + """Test with case_id that requires SINGLE WHOLE_GENOME_SEQUENCING analysis and --panel-bed argument.""" caplog.set_level(logging.ERROR) - # GIVEN case_id containing ONE tumor, WGS application and panel bed argument + # GIVEN case_id containing ONE tumor, WHOLE_GENOME_SEQUENCING application and panel bed argument case_id = "balsamic_case_wgs_single" panel_bed = Path(cg_dir, "balsamic_bed_1.bed") # WHEN dry running @@ -226,8 +226,8 @@ def test_error_single_wgs_panel_arg( ) # THEN command is NOT generated successfully assert result.exit_code != EXIT_SUCCESS - # THEN log warning not to set panel for WGS should be printed - assert "Cannot set panel_bed for WGS sample" in caplog.text + # THEN log warning not to set panel for WHOLE_GENOME_SEQUENCING should be printed + assert "Cannot set panel_bed for WHOLE_GENOME_SEQUENCING sample" in caplog.text def test_single_normal_only( @@ -255,9 +255,9 @@ def test_single_normal_only( def test_error_two_tumor( balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture ): - """Test with case_id that requires WGS analysis but has TWO tumor ONE normal samples.""" + """Test with case_id that requires WHOLE_GENOME_SEQUENCING analysis but has TWO tumor ONE normal samples.""" caplog.set_level(logging.ERROR) - # GIVEN case_id containing TWO tumor, ONE normal, TGS application + # GIVEN case_id containing TWO tumor, ONE normal, TARGETED_GENOME_SEQUENCING application case_id = "balsamic_case_tgs_paired_error" # WHEN dry running result = cli_runner.invoke(config_case, [case_id, "--dry-run"], obj=balsamic_context) @@ -270,7 +270,7 @@ def test_error_two_tumor( def test_error_mixed_application( balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture ): - """Test with case_id that has ONE tumor ONE normal samples marked for WGS and TGS analysis.""" + """Test with case_id that has ONE tumor ONE normal samples marked for WHOLE_GENOME_SEQUENCING and TARGETED_GENOME_SEQUENCING analysis.""" caplog.set_level(logging.ERROR) case_id = "balsamic_case_mixed_paired_error" # WHEN dry running @@ -284,7 +284,7 @@ def test_error_mixed_application( def test_error_not_balsamic_application( balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture ): - """Test with case_id that has PAIRED samples marked for WGS and MIC analysis.""" + """Test with case_id that has PAIRED samples marked for WHOLE_GENOME_SEQUENCING and MIC analysis.""" caplog.set_level(logging.ERROR) case_id = "balsamic_case_mixed_wgs_mic_paired_error" # WHEN dry running @@ -299,7 +299,7 @@ def test_error_mixed_panel_bed_resque( balsamic_context: CGConfig, cli_runner: CliRunner, caplog: LogCaptureFixture ): """ - Test with case_id marked for PAIRED TGS analysis but different BED files in LIMS + Test with case_id marked for PAIRED TARGETED_GENOME_SEQUENCING analysis but different BED files in LIMS and supplying --panel-bed option should prevent error. """ caplog.set_level(logging.INFO) diff --git a/tests/cli/workflow/balsamic/test_link.py b/tests/cli/workflow/balsamic/test_link.py index 85daee06bf..c2a4bb5302 100644 --- a/tests/cli/workflow/balsamic/test_link.py +++ b/tests/cli/workflow/balsamic/test_link.py @@ -47,9 +47,9 @@ def test_without_samples(cli_runner: CliRunner, balsamic_context: CGConfig, capl def test_single_panel(cli_runner: CliRunner, balsamic_context: CGConfig, caplog): - """Test with case_id that requires SINGLE TGS analysis""" + """Test with case_id that requires SINGLE TARGETED_GENOME_SEQUENCING analysis""" caplog.set_level(logging.INFO) - # GIVEN case_id containing ONE tumor, TGS application + # GIVEN case_id containing ONE tumor, TARGETED_GENOME_SEQUENCING application case_id = "balsamic_case_tgs_single" # WHEN dry running result = cli_runner.invoke(link, [case_id], obj=balsamic_context) diff --git a/tests/clients/janus/conftest.py b/tests/clients/janus/conftest.py index bbf6f79756..a020e8072b 100644 --- a/tests/clients/janus/conftest.py +++ b/tests/clients/janus/conftest.py @@ -10,7 +10,8 @@ FilePathAndTag, WorkflowInfo, ) -from cg.constants import PrepCategory, Workflow +from cg.constants import Workflow +from cg.constants.sequencing import SeqLibraryPrepCategory @pytest.fixture @@ -52,7 +53,7 @@ def collect_qc_request_balsamic_wgs( sample_ids=["test_sample"], files=balsamic_files_wgs, workflow_info=workflow_info, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) diff --git a/tests/conftest.py b/tests/conftest.py index 8c43041d26..b3c313e98e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1405,19 +1405,19 @@ def external_wes_application_tag() -> str: @pytest.fixture def wgs_application_tag() -> str: - """Return the WGS application tag.""" + """Return the WHOLE_GENOME_SEQUENCING application tag.""" return "WGSPCFC030" @pytest.fixture def wts_application_tag() -> str: - """Return a WTS application tag.""" + """Return a WHOLE_TRANSCRIPTOME_SEQUENCING application tag.""" return "RNAPOAR100" @pytest.fixture def microbial_application_tag() -> str: - """Return the WGS microbial application tag.""" + """Return the WHOLE_GENOME_SEQUENCING microbial application tag.""" return "MWRNXTR003" @@ -1520,7 +1520,7 @@ def base_store( store.add_application( tag="WGXCUSC000", prep_category="wgs", - description="External WGS", + description="External WHOLE_GENOME_SEQUENCING", sequencing_depth=0, is_external=True, percent_kth=80, @@ -1530,7 +1530,7 @@ def base_store( store.add_application( tag="EXXCUSR000", prep_category="wes", - description="External WES", + description="External WHOLE_EXOME_SEQUENCING", sequencing_depth=0, is_external=True, percent_kth=80, @@ -1540,7 +1540,7 @@ def base_store( store.add_application( tag="WGSPCFC060", prep_category="wgs", - description="WGS, double", + description="WHOLE_GENOME_SEQUENCING, double", sequencing_depth=30, is_accredited=True, percent_kth=80, @@ -1559,7 +1559,7 @@ def base_store( store.add_application( tag="WGSPCFC030", prep_category="wgs", - description="WGS trio", + description="WHOLE_GENOME_SEQUENCING trio", is_accredited=True, sequencing_depth=30, target_reads=30, diff --git a/tests/fixture_plugins/observations_fixtures/observations_input_files_fixtures.py b/tests/fixture_plugins/observations_fixtures/observations_input_files_fixtures.py index b78274279c..f85ab5f875 100644 --- a/tests/fixture_plugins/observations_fixtures/observations_input_files_fixtures.py +++ b/tests/fixture_plugins/observations_fixtures/observations_input_files_fixtures.py @@ -26,7 +26,7 @@ def balsamic_observations_input_files_raw(case_id: str, filled_file: Path) -> di def balsamic_observations_input_files( balsamic_observations_input_files_raw: dict[str, Path], ) -> BalsamicObservationsInputFiles: - """Return raw observations input files for cancer WGS analysis.""" + """Return raw observations input files for cancer WHOLE_GENOME_SEQUENCING analysis.""" return BalsamicObservationsInputFiles(**balsamic_observations_input_files_raw) @@ -45,7 +45,7 @@ def mip_dna_observations_input_files_raw(case_id: str, filled_file: Path) -> dic def mip_dna_observations_input_files( mip_dna_observations_input_files_raw: dict[str, Path], ) -> MipDNAObservationsInputFiles: - """Return raw observations input files for rare diseases WES analysis.""" + """Return raw observations input files for rare diseases WHOLE_EXOME_SEQUENCING analysis.""" return MipDNAObservationsInputFiles(**mip_dna_observations_input_files_raw) @@ -66,5 +66,5 @@ def raredisease_observations_input_files_raw( def raredisease_observations_input_files( raredisease_observations_input_files_raw: dict[str, Path], ) -> RarediseaseObservationsInputFiles: - """Return raw observations input files for RAREDISEASE WES analysis.""" + """Return raw observations input files for RAREDISEASE WHOLE_EXOME_SEQUENCING analysis.""" return RarediseaseObservationsInputFiles(**raredisease_observations_input_files_raw) diff --git a/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_check_scenario.py b/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_check_scenario.py index 0c9b6cbd14..b3919e70e7 100644 --- a/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_check_scenario.py +++ b/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_check_scenario.py @@ -1,8 +1,8 @@ +from cg.constants.constants import Workflow from cg.constants.priority import Priority -from cg.constants.constants import PrepCategory, Workflow -from cg.store.models import Case, Sample, Application, ApplicationVersion +from cg.constants.sequencing import SeqLibraryPrepCategory +from cg.store.models import Application, ApplicationVersion, Case, Sample from cg.store.store import Store - from tests.conftest import StoreHelpers @@ -13,12 +13,12 @@ def __init__(self, store: Store, helpers: StoreHelpers): def add_sample( self, - prep_category: PrepCategory, + prep_category: SeqLibraryPrepCategory, pass_sequencing_qc: bool, priority: Priority, ) -> Sample: """ - Add a sample to the store with a specified PrepCategory. The sample + Add a sample to the store with a specified SeqLibraryPrepCategory. The sample will have reads if pass_sequencing_qc is True. """ application: Application = self.helpers.ensure_application( @@ -36,12 +36,12 @@ def add_sample( def add_case( self, pass_sequencing_qc: bool, - prep_category: PrepCategory, + prep_category: SeqLibraryPrepCategory, workflow: Workflow, priority: Priority = Priority.standard, ) -> Case: """ - Add a case to the store. The case will have a sample with the specified PrepCategory. The + Add a case to the store. The case will have a sample with the specified SeqLibraryPrepCategory. The sample will have reads if pass_sequencing_qc is True. The case will have the specified workflow. """ @@ -55,11 +55,11 @@ def add_case( return case def get_sample_scenario( - self, priority: Priority, prep_category: PrepCategory, pass_sequencing_qc: bool + self, priority: Priority, prep_category: SeqLibraryPrepCategory, pass_sequencing_qc: bool ) -> Sample: """ Create a sample scenario. The sample will have reads if pass_sequencing_qc is True. The - sample will have the specified PrepCategory. + sample will have the specified SeqLibraryPrepCategory. """ return self.add_sample( prep_category=prep_category, pass_sequencing_qc=pass_sequencing_qc, priority=priority @@ -69,11 +69,11 @@ def get_case_scenario( self, priority: Priority, pass_sequencing_qc: bool, - prep_category: PrepCategory, + prep_category: SeqLibraryPrepCategory, workflow: Workflow, ) -> Case: """ - Create a case scenario. The case will have a sample with the specified PrepCategory. The + Create a case scenario. The case will have a sample with the specified SeqLibraryPrepCategory. The sample will have reads if pass_sequencing_qc is True. The case will have the specified workflow. """ diff --git a/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_fixtures.py b/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_fixtures.py index f8fffb29c7..5d2eae4ba1 100644 --- a/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_fixtures.py +++ b/tests/fixture_plugins/quality_controller_fixtures/sequencing_qc_fixtures.py @@ -1,9 +1,9 @@ import pytest -from cg.store.models import Case, Sample +from cg.constants.constants import Workflow from cg.constants.priority import Priority -from cg.constants.constants import PrepCategory, Workflow - +from cg.constants.sequencing import SeqLibraryPrepCategory +from cg.store.models import Case, Sample from tests.fixture_plugins.quality_controller_fixtures.sequencing_qc_check_scenario import ( SequencingQCCheckScenarios, ) @@ -20,7 +20,7 @@ def ready_made_library_sample_passing_sequencing_qc( ) -> Sample: return sequencing_qc_check_scenarios.get_sample_scenario( priority=Priority.standard, - prep_category=PrepCategory.READY_MADE_LIBRARY, + prep_category=SeqLibraryPrepCategory.READY_MADE_LIBRARY, pass_sequencing_qc=True, ) @@ -31,7 +31,7 @@ def ready_made_library_sample_failing_sequencing_qc( ) -> Sample: return sequencing_qc_check_scenarios.get_sample_scenario( priority=Priority.standard, - prep_category=PrepCategory.READY_MADE_LIBRARY, + prep_category=SeqLibraryPrepCategory.READY_MADE_LIBRARY, pass_sequencing_qc=False, ) @@ -42,7 +42,7 @@ def express_sample_passing_sequencing_qc( ) -> Sample: return sequencing_qc_check_scenarios.get_sample_scenario( priority=Priority.express, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, pass_sequencing_qc=True, ) @@ -53,7 +53,7 @@ def express_sample_failing_sequencing_qc( ) -> Sample: return sequencing_qc_check_scenarios.get_sample_scenario( priority=Priority.express, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, pass_sequencing_qc=False, ) @@ -64,7 +64,7 @@ def sample_passing_sequencing_qc( ) -> Sample: return sequencing_qc_check_scenarios.get_sample_scenario( priority=Priority.standard, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, pass_sequencing_qc=True, ) @@ -75,7 +75,7 @@ def sample_failing_sequencing_qc( ) -> Sample: return sequencing_qc_check_scenarios.get_sample_scenario( priority=Priority.standard, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, pass_sequencing_qc=False, ) @@ -87,7 +87,7 @@ def case_passing_sequencing_qc( return sequencing_qc_check_scenarios.get_case_scenario( priority=Priority.standard, pass_sequencing_qc=True, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, workflow=Workflow.MIP_DNA, ) @@ -99,7 +99,7 @@ def case_failing_sequencing_qc( return sequencing_qc_check_scenarios.get_case_scenario( priority=Priority.standard, pass_sequencing_qc=False, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, workflow=Workflow.MIP_DNA, ) @@ -111,7 +111,7 @@ def express_case_passing_sequencing_qc( return sequencing_qc_check_scenarios.get_case_scenario( priority=Priority.express, pass_sequencing_qc=True, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, workflow=Workflow.MIP_DNA, ) @@ -123,7 +123,7 @@ def express_case_failing_sequencing_qc( return sequencing_qc_check_scenarios.get_case_scenario( priority=Priority.express, pass_sequencing_qc=False, - prep_category=PrepCategory.WHOLE_GENOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, workflow=Workflow.MIP_DNA, ) @@ -135,7 +135,7 @@ def one_sample_in_case_has_reads( return sequencing_qc_check_scenarios.get_case_scenario( priority=Priority.standard, pass_sequencing_qc=True, - prep_category=PrepCategory.MICROBIAL, + prep_category=SeqLibraryPrepCategory.MICROBIAL, workflow=Workflow.MICROSALT, ) @@ -147,6 +147,6 @@ def no_sample_in_case_has_reads( return sequencing_qc_check_scenarios.get_case_scenario( priority=Priority.standard, pass_sequencing_qc=False, - prep_category=PrepCategory.MICROBIAL, + prep_category=SeqLibraryPrepCategory.MICROBIAL, workflow=Workflow.MICROSALT, ) diff --git a/tests/meta/observations/test_mip_dna_observations_api.py b/tests/meta/observations/test_mip_dna_observations_api.py index db7e9e8f85..c2479016b1 100644 --- a/tests/meta/observations/test_mip_dna_observations_api.py +++ b/tests/meta/observations/test_mip_dna_observations_api.py @@ -6,7 +6,7 @@ from _pytest.logging import LogCaptureFixture from pytest_mock import MockFixture -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import LoqusdbDuplicateRecordError from cg.meta.observations.mip_dna_observations_api import MipDNAObservationsAPI from cg.meta.workflow.mip_dna import MipDNAAnalysisAPI @@ -59,7 +59,9 @@ def test_is_case_eligible_for_observations_upload( # GIVEN a MIP-DNA scenario for Loqusdb uploads mocker.patch.object( - MipDNAAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WGS + MipDNAAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) # WHEN checking the upload eligibility for a case @@ -81,7 +83,9 @@ def test_is_case_not_eligible_for_observations_upload( # GIVEN a MIP-DNA scenario for Loqusdb uploads with an invalid sequencing method mocker.patch.object( - MipDNAAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WTS + MipDNAAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, ) # WHEN checking the upload eligibility for a case @@ -110,7 +114,9 @@ def test_load_observations( # GIVEN a MIP-DNA case and a mocked scenario for uploads case: Case = mip_dna_observations_api.store.get_case_by_internal_id(case_id) mocker.patch.object( - MipDNAAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WGS + MipDNAAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) mocker.patch.object( MipDNAObservationsAPI, @@ -143,7 +149,9 @@ def test_load_duplicated_observations( # GIVEN a MIP-DNA case and a mocked scenario for uploads with a case already uploaded case: Case = mip_dna_observations_api.store.get_case_by_internal_id(case_id) mocker.patch.object( - MipDNAAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WGS + MipDNAAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) mocker.patch.object( MipDNAObservationsAPI, diff --git a/tests/meta/observations/test_observations_api.py b/tests/meta/observations/test_observations_api.py index c1b922dc71..00447e3885 100644 --- a/tests/meta/observations/test_observations_api.py +++ b/tests/meta/observations/test_observations_api.py @@ -13,7 +13,7 @@ from cg.constants.constants import CancerAnalysisType, CustomerId, Workflow from cg.constants.observations import LoqusdbInstance, MipDNALoadParameters from cg.constants.sample_sources import SourceType -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import CaseNotFoundError, LoqusdbUploadCaseError from cg.meta.observations.observations_api import ObservationsAPI from cg.meta.workflow.analysis import AnalysisAPI @@ -38,7 +38,7 @@ ( Workflow.MIP_DNA, MipDNAAnalysisAPI, - SequencingMethod.WGS, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, True, "Uploaded {number_of_loaded_variants} variants to Loqusdb", ), @@ -52,14 +52,14 @@ ( Workflow.MIP_DNA, MipDNAAnalysisAPI, - SequencingMethod.WGS, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, False, "Case {case_id} is not eligible for observations upload", ), ( Workflow.RAREDISEASE, RarediseaseAnalysisAPI, - SequencingMethod.WGS, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, False, "Case {case_id} is not eligible for observations upload", ), @@ -132,7 +132,7 @@ def test_get_loqusdb_api( ): """Test Loqusdb API retrieval given a Loqusdb instance.""" - # GIVEN a WES Loqusdb instance and an observations API + # GIVEN a WHOLE_EXOME_SEQUENCING Loqusdb instance and an observations API observations_api: ObservationsAPI = request.getfixturevalue( f"{workflow.replace('-', '_')}_observations_api" ) @@ -144,7 +144,7 @@ def test_get_loqusdb_api( # WHEN calling the Loqusdb API get method loqusdb_api: LoqusdbAPI = observations_api.get_loqusdb_api(loqusdb_instance) - # THEN a WES Loqusdb API should be returned + # THEN a WHOLE_EXOME_SEQUENCING Loqusdb API should be returned assert isinstance(loqusdb_api, LoqusdbAPI) assert loqusdb_api.binary_path == loqusdb_config["binary_path"] assert loqusdb_api.config_path == loqusdb_config["config_path"] @@ -330,8 +330,12 @@ def test_is_customer_not_eligible_for_observations_upload( "workflow, analysis_api, sequencing_method", [ (Workflow.BALSAMIC, BalsamicAnalysisAPI, CancerAnalysisType.TUMOR_WGS), - (Workflow.MIP_DNA, MipDNAAnalysisAPI, SequencingMethod.WGS), - (Workflow.RAREDISEASE, RarediseaseAnalysisAPI, SequencingMethod.WGS), + (Workflow.MIP_DNA, MipDNAAnalysisAPI, SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING), + ( + Workflow.RAREDISEASE, + RarediseaseAnalysisAPI, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + ), ], ) def test_is_sequencing_method_eligible_for_observations_upload( @@ -365,8 +369,16 @@ def test_is_sequencing_method_eligible_for_observations_upload( "workflow, analysis_api, sequencing_method", [ (Workflow.BALSAMIC, BalsamicAnalysisAPI, CancerAnalysisType.TUMOR_PANEL), - (Workflow.MIP_DNA, MipDNAAnalysisAPI, SequencingMethod.WTS), - (Workflow.RAREDISEASE, RarediseaseAnalysisAPI, SequencingMethod.WTS), + ( + Workflow.MIP_DNA, + MipDNAAnalysisAPI, + SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, + ), + ( + Workflow.RAREDISEASE, + RarediseaseAnalysisAPI, + SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, + ), ], ) def test_is_sequencing_method_not_eligible_for_observations_upload( @@ -454,8 +466,12 @@ def test_is_sample_source_not_eligible_for_observations_upload( "workflow, analysis_api, sequencing_method", [ (Workflow.BALSAMIC, BalsamicAnalysisAPI, CancerAnalysisType.TUMOR_WGS), - (Workflow.MIP_DNA, MipDNAAnalysisAPI, SequencingMethod.WGS), - (Workflow.RAREDISEASE, RarediseaseAnalysisAPI, SequencingMethod.WGS), + (Workflow.MIP_DNA, MipDNAAnalysisAPI, SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING), + ( + Workflow.RAREDISEASE, + RarediseaseAnalysisAPI, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + ), ], ) def test_delete_case( @@ -491,8 +507,12 @@ def test_delete_case( "workflow, analysis_api, sequencing_method", [ (Workflow.BALSAMIC, BalsamicAnalysisAPI, CancerAnalysisType.TUMOR_WGS), - (Workflow.MIP_DNA, MipDNAAnalysisAPI, SequencingMethod.WGS), - (Workflow.RAREDISEASE, RarediseaseAnalysisAPI, SequencingMethod.WGS), + (Workflow.MIP_DNA, MipDNAAnalysisAPI, SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING), + ( + Workflow.RAREDISEASE, + RarediseaseAnalysisAPI, + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + ), ], ) def test_delete_case_not_found( diff --git a/tests/meta/observations/test_raredisease_observations_api.py b/tests/meta/observations/test_raredisease_observations_api.py index 92d55f68a5..e0cb6f3471 100644 --- a/tests/meta/observations/test_raredisease_observations_api.py +++ b/tests/meta/observations/test_raredisease_observations_api.py @@ -6,7 +6,7 @@ from _pytest.logging import LogCaptureFixture from pytest_mock import MockFixture -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import LoqusdbDuplicateRecordError from cg.meta.observations.raredisease_observations_api import RarediseaseObservationsAPI from cg.meta.workflow.raredisease import RarediseaseAnalysisAPI @@ -60,7 +60,9 @@ def test_is_case_eligible_for_observations_upload( # GIVEN a RAREDISEASE scenario for Loqusdb uploads mocker.patch.object( - RarediseaseAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WGS + RarediseaseAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) # WHEN checking the upload eligibility for a case @@ -84,7 +86,9 @@ def test_is_case_not_eligible_for_observations_upload( # GIVEN a RAREDISEASE scenario for Loqusdb uploads with an invalid sequencing method mocker.patch.object( - RarediseaseAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WTS + RarediseaseAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, ) # WHEN checking the upload eligibility for a case @@ -113,7 +117,9 @@ def test_load_observations( # GIVEN a RAREDISEASE case and a mocked scenario for uploads case: Case = raredisease_observations_api.store.get_case_by_internal_id(case_id) mocker.patch.object( - RarediseaseAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WGS + RarediseaseAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) mocker.patch.object( RarediseaseObservationsAPI, @@ -146,7 +152,9 @@ def test_load_duplicated_observations( # GIVEN a RAREDISEASE case and a mocked scenario for uploads with a case already uploaded case: Case = raredisease_observations_api.store.get_case_by_internal_id(case_id) mocker.patch.object( - RarediseaseAnalysisAPI, "get_data_analysis_type", return_value=SequencingMethod.WGS + RarediseaseAnalysisAPI, + "get_data_analysis_type", + return_value=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, ) mocker.patch.object( RarediseaseObservationsAPI, diff --git a/tests/meta/upload/balsamic/test_balsamic.py b/tests/meta/upload/balsamic/test_balsamic.py index dd7865cc65..6de20a8cef 100644 --- a/tests/meta/upload/balsamic/test_balsamic.py +++ b/tests/meta/upload/balsamic/test_balsamic.py @@ -21,8 +21,8 @@ def test_genotype_check_wgs_normal(balsamic_context: CGConfig): - """Test a cancer case with WGS and normal sample that is Genotype compatible.""" - # GIVEN a balsamic case with WGS tag and a normal sample + """Test a cancer case with WHOLE_GENOME_SEQUENCING and normal sample that is Genotype compatible.""" + # GIVEN a balsamic case with WHOLE_GENOME_SEQUENCING tag and a normal sample internal_id = "balsamic_case_wgs_paired_enough_reads" case: Case = balsamic_context.status_db.get_case_by_internal_id(internal_id=internal_id) @@ -34,8 +34,8 @@ def test_genotype_check_wgs_normal(balsamic_context: CGConfig): def test_genotype_check_non_wgs_normal(balsamic_context: CGConfig): - """Test a cancer case with no WGS sample that is not Genotype compatible.""" - # GIVEN a balsamic case with a normal sample, but no WGS tag + """Test a cancer case with no WHOLE_GENOME_SEQUENCING sample that is not Genotype compatible.""" + # GIVEN a balsamic case with a normal sample, but no WHOLE_GENOME_SEQUENCING tag internal_id = "balsamic_case_tgs_paired" case: Case = balsamic_context.status_db.get_case_by_internal_id(internal_id=internal_id) diff --git a/tests/meta/upload/scout/conftest.py b/tests/meta/upload/scout/conftest.py index b8e14342f6..78e125890c 100644 --- a/tests/meta/upload/scout/conftest.py +++ b/tests/meta/upload/scout/conftest.py @@ -9,15 +9,11 @@ from housekeeper.store.models import Version from cg.constants import DataDelivery, Workflow -from cg.constants.constants import FileFormat, GenomeVersion, PrepCategory -from cg.constants.housekeeper_tags import ( - HK_DELIVERY_REPORT_TAG, - AnalysisTag, - NFAnalysisTags, -) +from cg.constants.constants import FileFormat, GenomeVersion +from cg.constants.housekeeper_tags import HK_DELIVERY_REPORT_TAG, AnalysisTag, NFAnalysisTags from cg.constants.pedigree import Pedigree from cg.constants.scout import UploadTrack -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import PhenotypeStatus from cg.io.controller import ReadFile from cg.meta.upload.scout.balsamic_config_builder import BalsamicConfigBuilder @@ -140,25 +136,25 @@ def rna_store( rna_sample_son = helpers.add_sample( store=store, - application_type=SequencingMethod.WTS, + application_type=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, name=rna_sample_son_id, subject_id="son", ) rna_sample_daughter = helpers.add_sample( store=store, - application_type=SequencingMethod.WTS, + application_type=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, name=rna_sample_daughter_id, subject_id="daughter", ) rna_sample_mother = helpers.add_sample( store=store, - application_type=SequencingMethod.WTS, + application_type=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, name=rna_sample_mother_id, subject_id=Pedigree.MOTHER, ) rna_sample_father = helpers.add_sample( store=store, - application_type=SequencingMethod.WTS, + application_type=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, name=rna_sample_father_id, subject_id=Pedigree.FATHER, ) @@ -200,29 +196,29 @@ def rna_store( dna_sample_son = helpers.add_sample( store=store, - application_tag=SequencingMethod.WGS, - application_type=SequencingMethod.WGS, + application_tag=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, name=dna_sample_son_id, subject_id="son", ) dna_sample_daughter = helpers.add_sample( store=store, - application_tag=SequencingMethod.WGS, - application_type=SequencingMethod.WGS, + application_tag=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, name=dna_sample_daughter_id, subject_id="daughter", ) dna_sample_mother = helpers.add_sample( store=store, - application_tag=SequencingMethod.WGS, - application_type=SequencingMethod.WGS, + application_tag=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, name=dna_sample_mother_id, subject_id=Pedigree.MOTHER, ) dna_sample_father = helpers.add_sample( store=store, - application_tag=SequencingMethod.WGS, - application_type=SequencingMethod.WGS, + application_tag=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, name=dna_sample_father_id, subject_id=Pedigree.FATHER, ) @@ -756,7 +752,7 @@ def balsamic_analysis_obj(analysis_obj: Analysis) -> Analysis: analysis_obj.workflow = Workflow.BALSAMIC for link_object in analysis_obj.case.links: link_object.sample.application_version.application.prep_category = ( - PrepCategory.WHOLE_EXOME_SEQUENCING + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING ) link_object.case.data_analysis = Workflow.BALSAMIC return analysis_obj @@ -768,7 +764,7 @@ def balsamic_umi_analysis_obj(analysis_obj: Analysis) -> Analysis: analysis_obj.workflow = Workflow.BALSAMIC_UMI for link_object in analysis_obj.case.links: link_object.sample.application_version.application.prep_category = ( - PrepCategory.WHOLE_EXOME_SEQUENCING + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING ) link_object.case.data_analysis = Workflow.BALSAMIC_UMI @@ -781,7 +777,7 @@ def raredisease_analysis_obj(analysis_obj: Analysis) -> Analysis: analysis_obj.workflow = Workflow.RAREDISEASE for link_object in analysis_obj.case.links: link_object.sample.application_version.application.prep_category = ( - PrepCategory.WHOLE_GENOME_SEQUENCING + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING ) link_object.sample.reference_genome = GenomeVersion.GRCh37 link_object.case.data_analysis = Workflow.RAREDISEASE @@ -794,7 +790,7 @@ def rnafusion_analysis_obj(analysis_obj: Analysis) -> Analysis: analysis_obj.workflow = Workflow.RNAFUSION for link_object in analysis_obj.case.links: link_object.sample.application_version.application.prep_category = ( - PrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING + SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING ) link_object.case.data_analysis = Workflow.RNAFUSION link_object.case.panels = None diff --git a/tests/meta/upload/scout/test_meta_upload_scoutapi_rna.py b/tests/meta/upload/scout/test_meta_upload_scoutapi_rna.py index 3d9d8a3f4c..b1f9a64852 100644 --- a/tests/meta/upload/scout/test_meta_upload_scoutapi_rna.py +++ b/tests/meta/upload/scout/test_meta_upload_scoutapi_rna.py @@ -11,11 +11,11 @@ from cg.apps.housekeeper.hk import HousekeeperAPI from cg.constants import HK_MULTIQC_HTML_TAG, Workflow from cg.constants.scout import ScoutCustomCaseReportTags -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import CgDataError from cg.meta.upload.scout.uploadscoutapi import RNADNACollection, UploadScoutAPI from cg.store.models import Case, Sample -from tests.mocks.hk_mock import MockHousekeeperAPI, MockFile +from tests.mocks.hk_mock import MockFile, MockHousekeeperAPI from tests.store_helpers import StoreHelpers @@ -45,8 +45,8 @@ def ensure_two_dna_tumour_matches( ) another_sample_id = helpers.add_sample( store=rna_store, - application_tag=SequencingMethod.WGS, - application_type=SequencingMethod.WGS, + application_tag=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, is_tumour=True, name=another_sample_id, subject_id=subject_id, @@ -70,7 +70,7 @@ def ensure_extra_rna_case_match( subject_id: str = get_subject_id_from_case(store=rna_store, case_id=rna_case_id) another_rna_sample_id = helpers.add_sample( store=rna_store, - application_type=SequencingMethod.WTS, + application_type=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING, is_tumour=False, internal_id=another_rna_sample_id, subject_id=subject_id, diff --git a/tests/models/balsamic/conftest.py b/tests/models/balsamic/conftest.py index 03fac247bc..82686b8c6f 100644 --- a/tests/models/balsamic/conftest.py +++ b/tests/models/balsamic/conftest.py @@ -42,21 +42,21 @@ def balsamic_tga_metrics_raw(balsamic_tga_metrics_path) -> dict: @pytest.fixture def balsamic_wgs_config_path(fixtures_dir) -> Path: - """Returns path to a WGS BALSAMIC case_config.json""" + """Returns path to a WHOLE_GENOME_SEQUENCING BALSAMIC case_config.json""" return Path(fixtures_dir, "apps", "balsamic", "wgs_case", "config.json") @pytest.fixture def balsamic_wgs_metrics_path(fixtures_dir) -> Path: - """Returns path to a WGS BALSAMIC case_metrics_deliverables.yaml""" + """Returns path to a WHOLE_GENOME_SEQUENCING BALSAMIC case_metrics_deliverables.yaml""" return Path(fixtures_dir, "apps", "balsamic", "wgs_case", "metrics_deliverables.yaml") @pytest.fixture def balsamic_wgs_config_raw(balsamic_wgs_config_path) -> dict: - """Return a WGS BALSAMIC config file as a dictionary""" + """Return a WHOLE_GENOME_SEQUENCING BALSAMIC config file as a dictionary""" config: dict = ReadFile.get_content_from_file( file_format=FileFormat.YAML, file_path=balsamic_wgs_config_path @@ -66,7 +66,7 @@ def balsamic_wgs_config_raw(balsamic_wgs_config_path) -> dict: @pytest.fixture def balsamic_wgs_metrics_raw(balsamic_wgs_metrics_path) -> dict: - """Return a WGS BALSAMIC metrics file as a dictionary""" + """Return a WHOLE_GENOME_SEQUENCING BALSAMIC metrics file as a dictionary""" metrics: dict = ReadFile.get_content_from_file( file_format=FileFormat.YAML, file_path=balsamic_wgs_metrics_path diff --git a/tests/models/delivery_report/test_models_validators.py b/tests/models/delivery_report/test_models_validators.py index d31871a6a7..16c620df7e 100644 --- a/tests/models/delivery_report/test_models_validators.py +++ b/tests/models/delivery_report/test_models_validators.py @@ -12,12 +12,12 @@ from cg.apps.lims import LimsAPI from cg.constants import ( NA_FIELD, - YES_FIELD, NO_FIELD, REPORT_SEX, - Sex, RIN_MAX_THRESHOLD, RIN_MIN_THRESHOLD, + YES_FIELD, + Sex, ) from cg.constants.constants import AnalysisType, Workflow from cg.meta.delivery_report.delivery_report_api import DeliveryReportAPI @@ -26,20 +26,20 @@ from cg.models.delivery.delivery import DeliveryFile from cg.models.delivery_report.metadata import RnafusionSampleMetadataModel from cg.models.delivery_report.validators import ( - get_report_string, + get_analysis_type_as_string, get_boolean_as_string, - get_number_as_string, - get_float_as_percentage, get_date_as_string, - get_list_as_string, get_delivered_files_as_file_names, + get_float_as_percentage, + get_list_as_string, + get_number_as_string, get_path_as_string, - get_sex_as_string, get_prep_category_as_string, - get_analysis_type_as_string, + get_report_string, + get_sex_as_string, ) from cg.models.orders.constants import OrderType -from cg.store.models import Case, Analysis, Sample +from cg.store.models import Analysis, Case, Sample def test_get_report_string(): @@ -220,7 +220,7 @@ def test_get_prep_category_as_string(caplog: LogCaptureFixture): def test_get_analysis_type_as_string(): """Test analysis type formatting for the delivery report generation.""" - # GIVEN a WGS analysis type and a model info dictionary + # GIVEN a WHOLE_GENOME_SEQUENCING analysis type and a model info dictionary analysis_type: str = AnalysisType.WHOLE_GENOME_SEQUENCING model_info = ValidationInfo model_info.data = {"workflow": Workflow.MIP_DNA.value} @@ -237,7 +237,7 @@ def test_get_analysis_type_as_string(): def test_get_analysis_type_as_string_balsamic(): """Test analysis type formatting for the delivery report generation.""" - # GIVEN a WGS analysis type and a model info dictionary + # GIVEN a WHOLE_GENOME_SEQUENCING analysis type and a model info dictionary analysis_type = "tumor_normal_wgs" model_info = ValidationInfo model_info.data = {"workflow": Workflow.BALSAMIC.value} diff --git a/tests/services/orders/order_store_service/test_fastq_order_service.py b/tests/services/orders/order_store_service/test_fastq_order_service.py index 333078e3d4..7bbc9251bb 100644 --- a/tests/services/orders/order_store_service/test_fastq_order_service.py +++ b/tests/services/orders/order_store_service/test_fastq_order_service.py @@ -3,7 +3,7 @@ import pytest from cg.constants import DataDelivery, Workflow -from cg.constants.constants import PrepCategory +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.exc import OrderError from cg.models.orders.order import OrderIn, OrderType from cg.services.orders.store_order_services.store_fastq_order_service import StoreFastqOrderService @@ -95,7 +95,7 @@ def test_store_fastq_samples_non_tumour_wgs_to_mip( assert base_store._get_query(table=Case).count() == 0 base_store.get_application_by_tag( fastq_status_data["samples"][0]["application"] - ).prep_category = PrepCategory.WHOLE_GENOME_SEQUENCING + ).prep_category = SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING fastq_status_data["samples"][0]["tumour"] = False # WHEN storing the order @@ -122,7 +122,7 @@ def test_store_fastq_samples_tumour_wgs_to_fastq( assert base_store._get_query(table=Case).count() == 0 base_store.get_application_by_tag( fastq_status_data["samples"][0]["application"] - ).prep_category = PrepCategory.WHOLE_GENOME_SEQUENCING + ).prep_category = SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING fastq_status_data["samples"][0]["tumour"] = True # WHEN storing the order @@ -147,7 +147,7 @@ def test_store_fastq_samples_non_wgs_as_fastq( # GIVEN a basic store with no samples and a fastq order as non wgs assert not base_store._get_query(table=Sample).first() assert base_store._get_query(table=Case).count() == 0 - non_wgs_prep_category = PrepCategory.WHOLE_EXOME_SEQUENCING + non_wgs_prep_category = SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING non_wgs_applications = base_store._get_query(table=Application).filter( Application.prep_category == non_wgs_prep_category diff --git a/tests/services/sequencing_qc_service/test_sequencing_quality_checks_utils.py b/tests/services/sequencing_qc_service/test_sequencing_quality_checks_utils.py index c62f5d9391..394f0bfd5f 100644 --- a/tests/services/sequencing_qc_service/test_sequencing_quality_checks_utils.py +++ b/tests/services/sequencing_qc_service/test_sequencing_quality_checks_utils.py @@ -1,18 +1,19 @@ import pytest -from cg.store.models import Case, Sample -from cg.constants.constants import PrepCategory + +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.services.sequencing_qc_service.quality_checks.utils import ( any_sample_in_case_has_reads, - is_case_express_priority, case_pass_sequencing_qc, express_case_pass_sequencing_qc, express_sample_has_enough_reads, get_express_reads_threshold_for_sample, - is_sample_ready_made_library, + is_case_express_priority, is_sample_express_priority, + is_sample_ready_made_library, ready_made_library_sample_has_enough_reads, sample_has_enough_reads, ) +from cg.store.models import Case, Sample from cg.store.store import Store from tests.conftest import StoreHelpers from tests.fixture_plugins.quality_controller_fixtures.sequencing_qc_check_scenario import ( @@ -264,7 +265,7 @@ def test_any_sample_in_case_has_reads( case: Case = request.getfixturevalue(case_fixture) # GIVEN that another sample on the case has no reads another_sample: Sample = sequencing_qc_check_scenarios.add_sample( - prep_category=PrepCategory.WHOLE_EXOME_SEQUENCING, + prep_category=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, pass_sequencing_qc=False, priority=case.priority, ) diff --git a/tests/store/api/conftest.py b/tests/store/api/conftest.py index 98abe15b56..037eef2584 100644 --- a/tests/store/api/conftest.py +++ b/tests/store/api/conftest.py @@ -2,8 +2,6 @@ import pytest -from cg.constants import Workflow -from cg.constants.constants import PrepCategory from cg.constants.subject import PhenotypeStatus from cg.store.models import CaseSample from cg.store.store import Store diff --git a/tests/store/crud/conftest.py b/tests/store/crud/conftest.py index 4e7dbc7b23..d71ab9c025 100644 --- a/tests/store/crud/conftest.py +++ b/tests/store/crud/conftest.py @@ -4,7 +4,8 @@ import pytest from cg.constants import Workflow -from cg.constants.constants import CustomerId, PrepCategory +from cg.constants.constants import CustomerId +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import PhenotypeStatus from cg.store.models import Case, CaseSample, Customer, Order, Sample from cg.store.store import Store @@ -124,7 +125,7 @@ def store_with_rna_and_dna_samples_and_cases(store: Store, helpers: StoreHelpers helpers.add_sample( store=store, internal_id="rna_sample", - application_type=PrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING.value, + application_type=SeqLibraryPrepCategory.WHOLE_TRANSCRIPTOME_SEQUENCING.value, subject_id="subject_1", is_tumour=True, customer_id="cust000", @@ -132,8 +133,8 @@ def store_with_rna_and_dna_samples_and_cases(store: Store, helpers: StoreHelpers related_dna_sample_1: Sample = helpers.add_sample( store=store, internal_id="related_dna_sample_1", - application_tag=PrepCategory.WHOLE_GENOME_SEQUENCING.value, - application_type=PrepCategory.WHOLE_GENOME_SEQUENCING.value, + application_tag=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING.value, + application_type=SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING.value, subject_id="subject_1", is_tumour=True, customer_id="cust001", @@ -141,8 +142,8 @@ def store_with_rna_and_dna_samples_and_cases(store: Store, helpers: StoreHelpers helpers.add_sample( store=store, internal_id="related_dna_sample_2", - application_tag=PrepCategory.TARGETED_GENOME_SEQUENCING.value, - application_type=PrepCategory.TARGETED_GENOME_SEQUENCING.value, + application_tag=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING.value, + application_type=SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING.value, subject_id="subject_1", is_tumour=True, customer_id="cust000", @@ -150,8 +151,8 @@ def store_with_rna_and_dna_samples_and_cases(store: Store, helpers: StoreHelpers helpers.add_sample( store=store, internal_id="related_dna_sample_3", - application_tag=PrepCategory.WHOLE_EXOME_SEQUENCING.value, - application_type=PrepCategory.WHOLE_EXOME_SEQUENCING.value, + application_tag=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING.value, + application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING.value, subject_id="subject_1", is_tumour=True, customer_id="cust000", @@ -159,8 +160,8 @@ def store_with_rna_and_dna_samples_and_cases(store: Store, helpers: StoreHelpers helpers.add_sample( store=store, internal_id="not_related_dna_sample", - application_tag=PrepCategory.WHOLE_EXOME_SEQUENCING.value, - application_type=PrepCategory.WHOLE_EXOME_SEQUENCING.value, + application_tag=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING.value, + application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING.value, subject_id="subject_2", is_tumour=False, customer_id="cust000", diff --git a/tests/store/crud/read/test_read.py b/tests/store/crud/read/test_read.py index e69fc6be8e..e9c138da7b 100644 --- a/tests/store/crud/read/test_read.py +++ b/tests/store/crud/read/test_read.py @@ -5,7 +5,8 @@ from sqlalchemy.orm import Query from cg.constants import SequencingRunDataAvailability -from cg.constants.constants import CaseActions, MicrosaltAppTags, PrepCategory, Workflow +from cg.constants.constants import CaseActions, MicrosaltAppTags, Workflow +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import PhenotypeStatus from cg.exc import CgError from cg.services.orders.order_service.models import OrderQueryParams @@ -94,7 +95,7 @@ def test_get_active_beds_when_archived(base_store: Store): def test_get_active_applications_by_prep_category(microbial_store: Store): """Test that non-archived and correct applications are returned for the given prep category.""" # GIVEN a store with applications with a given prep category - prep_category = PrepCategory.MICROBIAL + prep_category = SeqLibraryPrepCategory.MICROBIAL # WHEN fetching the active applications for a given prep category applications: list[Application] = microbial_store.get_active_applications_by_prep_category( diff --git a/tests/store/crud/read/test_read_sample.py b/tests/store/crud/read/test_read_sample.py index 7540ab802c..9af8e375dc 100644 --- a/tests/store/crud/read/test_read_sample.py +++ b/tests/store/crud/read/test_read_sample.py @@ -6,7 +6,7 @@ from _pytest.fixtures import FixtureRequest from sqlalchemy.orm import Query -from cg.constants import PrepCategory +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.store.models import Customer, Invoice, Sample from cg.store.store import Store from tests.store_helpers import StoreHelpers @@ -614,10 +614,10 @@ def test_get_related_samples( # GIVEN a database with an RNA sample and several DNA samples with the same subject_id and tumour status as the given sample # GIVEN that all customers are in a collaboration # GIVEN a list of dna prep categories - dna_prep_categories: list[PrepCategory] = [ - PrepCategory.WHOLE_GENOME_SEQUENCING, - PrepCategory.TARGETED_GENOME_SEQUENCING, - PrepCategory.WHOLE_EXOME_SEQUENCING, + dna_prep_categories: list[SeqLibraryPrepCategory] = [ + SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING, + SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING, + SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, ] # WHEN getting the related DNA samples to the given sample diff --git a/tests/store/filters/test_status_cases_filters.py b/tests/store/filters/test_status_cases_filters.py index d9daafc880..2bd5a0fab9 100644 --- a/tests/store/filters/test_status_cases_filters.py +++ b/tests/store/filters/test_status_cases_filters.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import Query from cg.constants.constants import CaseActions, DataDelivery, Workflow -from cg.constants.sequencing import SequencingMethod +from cg.constants.sequencing import SeqLibraryPrepCategory from cg.constants.subject import PhenotypeStatus from cg.store.filters.status_case_filters import ( filter_case_by_internal_id, @@ -248,7 +248,9 @@ def test_filter_cases_with_loqusdb_supported_sequencing_method( # GIVEN a sample with a valid Loqusdb sequencing method test_sample_wes: Sample = helpers.add_sample( - store=base_store, application_type=SequencingMethod.WES, last_sequenced_at=timestamp_now + store=base_store, + application_type=SeqLibraryPrepCategory.WHOLE_EXOME_SEQUENCING, + last_sequenced_at=timestamp_now, ) # GIVEN a MIP-DNA associated test case