Skip to content

Commit

Permalink
(Improve order flow) Override microbial dump (#4127) (patch)
Browse files Browse the repository at this point in the history
### Fixed

- MutantSample and MicrosaltSample dumps the verified_organism value
  • Loading branch information
islean authored Jan 21, 2025
1 parent ffc3e68 commit 09071ae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 0 additions & 4 deletions cg/services/orders/lims_service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from cg.constants import DataDelivery, Workflow
from cg.models.lims.sample import LimsSample
from cg.services.orders.validation.models.sample import Sample
from cg.services.orders.validation.workflows.microsalt.models.sample import MicrosaltSample
from cg.services.orders.validation.workflows.mutant.models.sample import MutantSample

LOG = logging.getLogger(__name__)

Expand All @@ -28,8 +26,6 @@ def _build_lims_sample(
dict_sample["data_analysis"] = workflow
dict_sample["data_delivery"] = delivery_type
dict_sample["family_name"] = sample._case_name
if isinstance(sample, MutantSample | MicrosaltSample):
dict_sample["verified_organism"] = sample._verified_organism
lims_sample: LimsSample = LimsSample.parse_obj(dict_sample)
samples_lims.append(lims_sample)
return samples_lims
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _fill_in_sample_verified_organism(self, samples: list[MicrobialSample]):
organism_id = sample.organism
reference_genome = sample.reference_genome
organism: Organism = self.status.get_organism_by_internal_id(internal_id=organism_id)
is_verified = (
is_verified: bool = (
organism and organism.reference_genome == reference_genome and organism.verified
)
sample._verified_organism = is_verified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ class MicrosaltSample(Sample):
organism: str
priority: PriorityEnum
reference_genome: str = Field(max_length=255)
_verified_organism: str | None = PrivateAttr(default=None)
_verified_organism: bool | None = PrivateAttr(default=None)

def model_dump(self, **kwargs) -> dict:
data = super().model_dump(**kwargs)
data["verified_organism"] = self._verified_organism
return data
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MutantSample(Sample):
region: Region
region_code: str
selection_criteria: SelectionCriteria
_verified_organism: str | None = PrivateAttr(default=None)
_verified_organism: bool | None = PrivateAttr(default=None)

@model_validator(mode="before")
@classmethod
Expand All @@ -62,4 +62,5 @@ def serialize_collection_date(self, value: date) -> str:
def model_dump(self, **kwargs) -> dict:
data = super().model_dump(**kwargs)
data["lab_code"] = self._lab_code
data["verified_organism"] = self._verified_organism
return data

0 comments on commit 09071ae

Please sign in to comment.