diff --git a/cg/constants/delivery.py b/cg/constants/delivery.py index c6c98eb0b6..21e898a1cc 100644 --- a/cg/constants/delivery.py +++ b/cg/constants/delivery.py @@ -153,20 +153,21 @@ {"fusion", "arriba"}, {"fusion", "star-fusion"}, {"fusion", "fusioncatcher"}, - {"cram"}, {"fusioncatcher-summary"}, {"fusioninspector"}, {"fusionreport", "research"}, {"fusioninspector-html", "research"}, {"arriba-visualisation", "research"}, {"multiqc-html", "rna"}, - {"software-versions"}, - {"qc-metrics"}, - {"multiqc-json"}, {"delivery-report"}, + {"vcf-fusion"}, + {"gene-counts"}, ] -RNAFUSION_ANALYSIS_SAMPLE_TAGS: list[set[str]] = [] +RNAFUSION_ANALYSIS_SAMPLE_TAGS: list[set[str]] = [ + {"cram"}, + {"cram-index"}, +] PIPELINE_ANALYSIS_TAG_MAP: dict[Pipeline, dict] = { diff --git a/cg/constants/scout_upload.py b/cg/constants/scout_upload.py index 8cc10f7cd8..5214ef308e 100644 --- a/cg/constants/scout_upload.py +++ b/cg/constants/scout_upload.py @@ -1,5 +1,7 @@ from enum import StrEnum +from cg.constants.housekeeper_tags import AlignmentFileTag + class GenomeBuild(StrEnum): hg19: str = "37" @@ -57,6 +59,7 @@ class ScoutCustomCaseReportTags(StrEnum): RNAfusion_inspector={"fusioninspector-html", "clinical"}, RNAfusion_inspector_research={"fusioninspector-html", "research"}, delivery_report={"delivery-report"}, + vcf_fusion={"vcf-fusion"}, ) MIP_SAMPLE_TAGS = dict( @@ -86,4 +89,6 @@ class ScoutCustomCaseReportTags(StrEnum): ) -RNAFUSION_SAMPLE_TAGS = {} +RNAFUSION_SAMPLE_TAGS = dict( + alignment_file={AlignmentFileTag.CRAM}, +) diff --git a/cg/meta/report/balsamic.py b/cg/meta/report/balsamic.py index f563efb723..3bf96099fb 100644 --- a/cg/meta/report/balsamic.py +++ b/cg/meta/report/balsamic.py @@ -226,17 +226,3 @@ def get_template_name(self) -> str: def get_upload_case_tags(self) -> dict: """Return Balsamic upload case tags.""" return BALSAMIC_CASE_TAGS - - def get_scout_uploaded_file_from_hk(self, case_id: str, scout_tag: str) -> str | None: - """Return file path of the uploaded to Scout file given its tag.""" - version: Version = self.housekeeper_api.last_version(bundle=case_id) - tags: list = self.get_hk_scout_file_tags(scout_tag=scout_tag) - uploaded_file: File = self.housekeeper_api.get_latest_file( - bundle=case_id, tags=tags, version=version.id - ) - if not tags or not uploaded_file: - LOG.warning( - f"No files were found for the following Scout Housekeeper tag: {scout_tag} (case: {case_id})" - ) - return None - return uploaded_file.full_path diff --git a/cg/meta/report/field_validators.py b/cg/meta/report/field_validators.py index 793a332c49..7ee33469a3 100644 --- a/cg/meta/report/field_validators.py +++ b/cg/meta/report/field_validators.py @@ -6,6 +6,10 @@ from cg.models.report.report import ReportModel +def get_mapped_reads_fraction(mapped_reads: float, total_reads: float) -> float | None: + return mapped_reads / total_reads if mapped_reads and total_reads else None + + def get_million_read_pairs(reads: int) -> float | None: """Return number of sequencing reads as millions of read pairs.""" return ( diff --git a/cg/meta/report/report_api.py b/cg/meta/report/report_api.py index c2dd7a7d43..9ca2057b10 100644 --- a/cg/meta/report/report_api.py +++ b/cg/meta/report/report_api.py @@ -103,8 +103,18 @@ def get_delivery_report_from_hk(self, case_id: str, version: Version) -> str | N return delivery_report.full_path def get_scout_uploaded_file_from_hk(self, case_id: str, scout_tag: str) -> str | None: - """Return the file path of the uploaded to Scout file given its tag.""" - raise NotImplementedError + """Return file path of the uploaded to Scout file given its tag.""" + version: Version = self.housekeeper_api.last_version(bundle=case_id) + tags: list = self.get_hk_scout_file_tags(scout_tag=scout_tag) + uploaded_file: File = self.housekeeper_api.get_latest_file( + bundle=case_id, tags=tags, version=version.id + ) + if not tags or not uploaded_file: + LOG.warning( + f"No files were found for the following Scout Housekeeper tag: {scout_tag} (case: {case_id})" + ) + return None + return uploaded_file.full_path def render_delivery_report(self, report_data: dict) -> str: """Renders the report on the Jinja template.""" @@ -354,6 +364,9 @@ def get_scout_uploaded_files(self, case: Case) -> ScoutReportFiles: smn_tsv=self.get_scout_uploaded_file_from_hk( case_id=case.internal_id, scout_tag="smn_tsv" ), + vcf_fusion=self.get_scout_uploaded_file_from_hk( + case_id=case.internal_id, scout_tag="vcf_fusion" + ), ) @staticmethod diff --git a/cg/meta/report/rnafusion.py b/cg/meta/report/rnafusion.py index ef0cfafeda..f94918c054 100644 --- a/cg/meta/report/rnafusion.py +++ b/cg/meta/report/rnafusion.py @@ -14,7 +14,8 @@ Pipeline, ) from cg.constants.constants import GenomeVersion -from cg.meta.report.field_validators import get_million_read_pairs +from cg.constants.scout_upload import RNAFUSION_CASE_TAGS +from cg.meta.report.field_validators import get_mapped_reads_fraction, get_million_read_pairs from cg.meta.report.report_api import ReportAPI from cg.meta.workflow.rnafusion import RnafusionAnalysisAPI from cg.models.analysis import AnalysisModel @@ -47,15 +48,16 @@ def get_sample_metadata( rin = self.lims_api.get_sample_rin(sample_id=sample.internal_id) return RnafusionSampleMetadataModel( - bias_5_3=sample_metrics.bias_5_3, + bias_5_3=sample_metrics.median_5prime_to_3prime_bias, duplicates=sample_metrics.pct_duplication, gc_content=sample_metrics.after_filtering_gc_content, input_amount=input_amount, insert_size=None, insert_size_peak=None, - mapped_reads=sample_metrics.reads_aligned - * 2 - / sample_metrics.before_filtering_total_reads, + mapped_reads=get_mapped_reads_fraction( + mapped_reads=sample_metrics.read_pairs_examined * 2, + total_reads=sample_metrics.before_filtering_total_reads, + ), mean_length_r1=sample_metrics.after_filtering_read1_mean_length, million_read_pairs=get_million_read_pairs( reads=sample_metrics.before_filtering_total_reads @@ -77,12 +79,8 @@ def get_genome_build(self, analysis_metadata: AnalysisModel) -> str: def get_report_accreditation( self, samples: list[SampleModel], analysis_metadata: AnalysisModel ) -> bool: - """Checks if the report is accredited or not. Rnafusion is not an accredited workflow.""" - return False - - def get_scout_uploaded_file_from_hk(self, case_id: str, scout_tag: str) -> str | None: - """Return file path of the uploaded to Scout file given its tag.""" - return None + """Checks if the report is accredited or not. Rnafusion is an accredited workflow.""" + return True def get_template_name(self) -> str: """Return template name to render the delivery report.""" @@ -111,3 +109,7 @@ def get_required_fields(self, case: CaseModel) -> dict: case=case, required_fields=REQUIRED_SAMPLE_METADATA_RNAFUSION_FIELDS ), } + + def get_upload_case_tags(self) -> dict: + """Return Balsamic UMI upload case tags.""" + return RNAFUSION_CASE_TAGS diff --git a/cg/meta/report/templates/balsamic_report.html b/cg/meta/report/templates/balsamic_report.html index e4f780e187..477eec7531 100644 --- a/cg/meta/report/templates/balsamic_report.html +++ b/cg/meta/report/templates/balsamic_report.html @@ -241,7 +241,7 @@

Scout

Varianter finns uppladdade i Scout: scout.scilifelab.se/{{ customer.id }}/{{ case.name }}