From 1e08f4a74686c844124733cf6135020dca045179 Mon Sep 17 00:00:00 2001 From: ChristianOertlin Date: Tue, 22 Oct 2024 15:18:25 +0200 Subject: [PATCH] add(bam delivery message) (#3876) (patch) # Description add bam delivery message --- .../delivery_message/messages/bam_message.py | 20 +++++++++++++++++++ cg/services/delivery_message/utils.py | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 cg/services/delivery_message/messages/bam_message.py diff --git a/cg/services/delivery_message/messages/bam_message.py b/cg/services/delivery_message/messages/bam_message.py new file mode 100644 index 0000000000..bce9ccc81f --- /dev/null +++ b/cg/services/delivery_message/messages/bam_message.py @@ -0,0 +1,20 @@ +from cg.services.delivery_message.messages.delivery_message import DeliveryMessage +from cg.services.delivery_message.messages.utils import get_caesar_delivery_path +from cg.store.models import Case + + +class BamMessage(DeliveryMessage): + + def create_message(self, cases: list[Case]) -> str: + delivery_path: str = get_caesar_delivery_path(cases[0]) + return ( + f"Hello,\n\n" + f"The following samples in this order have been sequenced:\n\n" + f"{self.generate_sample_name_list(cases)}\n\n" + f"The bam files have been uploaded to your inbox on Caesar at:\n\n" + f"{delivery_path}" + ) + + @staticmethod + def generate_sample_name_list(cases: list[Case]) -> str: + return "\n".join([sample.name for case in cases for sample in case.samples]) diff --git a/cg/services/delivery_message/utils.py b/cg/services/delivery_message/utils.py index ffdf89ad27..04ad891379 100644 --- a/cg/services/delivery_message/utils.py +++ b/cg/services/delivery_message/utils.py @@ -15,6 +15,7 @@ StatinaMessage, ) from cg.services.delivery_message.messages.analysis_message import AnalysisMessage +from cg.services.delivery_message.messages.bam_message import BamMessage from cg.services.delivery_message.messages.delivery_message import DeliveryMessage from cg.services.delivery_message.messages.fastq_analysis_message import ( FastqAnalysisMessage, @@ -55,6 +56,7 @@ def get_message_strategy_from_data_delivery(case: Case) -> DeliveryMessage: DataDelivery.ANALYSIS_SCOUT: AnalysisScoutMessage, DataDelivery.FASTQ_ANALYSIS_SCOUT: FastqAnalysisScoutMessage, DataDelivery.STATINA: StatinaMessage, + DataDelivery.BAM: BamMessage, }