diff --git a/cg/meta/workflow/analysis.py b/cg/meta/workflow/analysis.py index e64d68db0d..d5516895b0 100644 --- a/cg/meta/workflow/analysis.py +++ b/cg/meta/workflow/analysis.py @@ -206,7 +206,9 @@ def get_case_source_type(self, case_id: str) -> str | None: Raises: CgError: If different sources are set for the samples linked to a case. """ - sample_ids: Iterator[str] = self.status_db.get_sample_ids_by_case_id(case_id=case_id) + sample_ids: Iterator[str] = self.status_db.get_original_sample_ids_by_case_id( + case_id=case_id + ) source_types: set[str | None] = { self.lims_api.get_source(sample_id) for sample_id in sample_ids } diff --git a/cg/store/crud/read.py b/cg/store/crud/read.py index 209d0f35d2..097d8f8bf2 100644 --- a/cg/store/crud/read.py +++ b/cg/store/crud/read.py @@ -345,6 +345,16 @@ def get_sample_ids_by_case_id(self, case_id: str = None) -> Iterator[str]: for link in case.links: yield link.sample.internal_id + def get_original_sample_ids_by_case_id(self, case_id: str = None) -> Iterator[str]: + """Return original sample ids (go to original sample id for downloaded samples) from case id.""" + case: Case = self.get_case_by_internal_id(internal_id=case_id) + self._is_case_found(case=case, case_id=case_id) + for link in case.links: + if link.sample.from_sample: + original_sample: Sample = link.sample.from_sample + yield original_sample.internal_id + yield link.sample.internal_id + def get_case_by_name_and_customer(self, customer: Customer, case_name: str) -> Case: """Find a case by case name within a customer.""" return apply_case_filter(