Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug raredisease delivery report tags #4200

Merged
merged 16 commits into from
Feb 20, 2025
15 changes: 15 additions & 0 deletions cg/apps/housekeeper/hk.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ def get_latest_file(
files: Query = self._store.get_files(bundle_name=bundle, tag_names=tags, version_id=version)
return files.order_by(File.id.desc()).first()

def get_file_by_exact_tags(
self, bundle: str, tags: list, version: int | None = None
) -> File | None:
"""Return a file that matches exact tags and optionally filtered by bundle and version."""
if not tags:
LOG.debug("No tags provided, skipping")
return None
files: list[File] = self.files(bundle=bundle, version=version, tags=tags).all()
for file in files:
file_tags = {tag.name for tag in file.tags}
LOG.debug(f"Using tags {file_tags}")
if file_tags == set(tags):
LOG.debug(f"Found file {file}")
return file

def check_bundle_files(
self,
bundle_name: str,
Expand Down
5 changes: 5 additions & 0 deletions cg/constants/housekeeper_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class HermesFileTag(StrEnum):

CLINICAL_DELIVERY: str = "clinical-delivery"
LONG_TERM_STORAGE: str = "long-term-storage"
SCOUT: str = "scout"


class AnalysisTag(StrEnum):
Expand All @@ -81,8 +82,12 @@ class AnalysisTag(StrEnum):
OUTRIDER: str = "outrider"
RESEARCH: str = "research"
RNA: str = "rna"
SMN_CALLING: str = "smn-calling"
STARFUSION: str = "star-fusion"
VCF_FUSION: str = "vcf-fusion"
VCF_SNV_CLINICAL: str = "vcf-snv-clinical"
VCF_STR: str = "vcf-str"
VCF_SV_CLINICAL: str = "vcf-sv-clinical"


class HkMipAnalysisTag:
Expand Down
2 changes: 2 additions & 0 deletions cg/constants/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ScoutUploadKey(StrEnum):
SV_VCF = auto()
VCF_STR = auto()
VCF_FUSION = auto()
VCF_SNV = auto()
VCF_SV = auto()


RAREDISEASE_CASE_TAGS = dict(
Expand Down
53 changes: 41 additions & 12 deletions cg/meta/delivery_report/raredisease.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Raredisease Delivery Report API."""

from cg.clients.chanjo2.models import CoverageMetrics
from cg.constants.housekeeper_tags import HermesFileTag, AnalysisTag
from cg.constants.report import (
REQUIRED_APPLICATION_FIELDS,
REQUIRED_CASE_FIELDS,
Expand Down Expand Up @@ -64,18 +65,46 @@ def is_report_accredited(
def get_scout_variants_files(self, case_id: str) -> ScoutVariantsFiles:
"""Return Raredisease files that will be uploaded to Scout."""
return ScoutVariantsFiles(
snv_vcf=self.get_scout_uploaded_file_from_hk(
case_id=case_id, scout_key=ScoutUploadKey.SNV_VCF
),
sv_vcf=self.get_scout_uploaded_file_from_hk(
case_id=case_id, scout_key=ScoutUploadKey.SV_VCF
),
vcf_str=self.get_scout_uploaded_file_from_hk(
case_id=case_id, scout_key=ScoutUploadKey.VCF_STR
),
smn_tsv=self.get_scout_uploaded_file_from_hk(
case_id=case_id, scout_key=ScoutUploadKey.SMN_TSV
),
snv_vcf=self.housekeeper_api.get_file_by_exact_tags(
bundle=case_id,
tags=[
AnalysisTag.VCF_SNV_CLINICAL,
case_id,
HermesFileTag.CLINICAL_DELIVERY,
HermesFileTag.LONG_TERM_STORAGE,
HermesFileTag.SCOUT,
],
).full_path,
sv_vcf=self.housekeeper_api.get_file_by_exact_tags(
bundle=case_id,
tags=[
AnalysisTag.VCF_SV_CLINICAL,
case_id,
HermesFileTag.CLINICAL_DELIVERY,
HermesFileTag.LONG_TERM_STORAGE,
HermesFileTag.SCOUT,
],
).full_path,
vcf_str=self.housekeeper_api.get_file_by_exact_tags(
bundle=case_id,
tags=[
AnalysisTag.VCF_STR,
case_id,
HermesFileTag.CLINICAL_DELIVERY,
HermesFileTag.LONG_TERM_STORAGE,
HermesFileTag.SCOUT,
],
).full_path,
smn_tsv=self.housekeeper_api.get_file_by_exact_tags(
bundle=case_id,
tags=[
AnalysisTag.SMN_CALLING,
case_id,
HermesFileTag.CLINICAL_DELIVERY,
HermesFileTag.LONG_TERM_STORAGE,
HermesFileTag.SCOUT,
],
).full_path,
)

@staticmethod
Expand Down
Loading