Skip to content

Commit

Permalink
fetch tissue type from original sample
Browse files Browse the repository at this point in the history
  • Loading branch information
rannick committed Nov 27, 2024
1 parent 1303240 commit 394b6f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cg/meta/workflow/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions cg/store/crud/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 394b6f3

Please sign in to comment.