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

Add balsamic #3662

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from cg.services.order_validation_service.models.case import Case
from cg.services.order_validation_service.workflows.balsamic.models.sample import BalsamicSample


class BalsamicCase(Case):
samples: list[BalsamicSample]
cohorts: list[str] | None = None
synopsis: str | None = None
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from cg.services.order_validation_service.models.order_with_cases import OrderWithCases
from cg.services.order_validation_service.workflows.balsamic.models.case import BalsamicCase


class BalsamicOrder(OrderWithCases):
seallard marked this conversation as resolved.
Show resolved Hide resolved
cases: list[BalsamicCase]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pydantic import Field
from cg.constants.constants import GenomeVersion
from cg.models.orders.sample_base import NAME_PATTERN, ControlEnum, SexEnum, StatusEnum
from cg.services.order_validation_service.constants import ElutionBuffer, TissueBlockEnum
from cg.services.order_validation_service.models.sample import Sample


class BalsamicSample(Sample):
age_at_sampling: float | None = None
capture_kit: str | None = None
comment: str | None = None
concentration_ng_ul: float | None = None
control: ControlEnum | None = None
elution_buffer: ElutionBuffer
seallard marked this conversation as resolved.
Show resolved Hide resolved
formalin_fixation_time: int | None = None
is_tumour: bool
phenotype_groups: list[str] | None = None
phenotype_terms: list[str] | None = None
post_formalin_fixation_time: int | None = None
reference_genome: GenomeVersion
sex: SexEnum
source: str
status: StatusEnum | None = None
subject_id: str = Field(pattern=NAME_PATTERN, max_length=128)
tissue_block_size: TissueBlockEnum | None = None
tumour_purity: int | None = None
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CASE_RULES = []
CASE_SAMPLE_RULES = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from cg.services.order_validation_service.errors.case_errors import CaseError
from cg.services.order_validation_service.errors.case_sample_errors import CaseSampleError
from cg.services.order_validation_service.errors.order_errors import OrderError
from cg.services.order_validation_service.errors.validation_errors import ValidationErrors
from cg.services.order_validation_service.model_validator.model_validator import ModelValidator
from cg.services.order_validation_service.order_validation_service import OrderValidationService
from cg.services.order_validation_service.response_mapper import create_order_validation_response
from cg.services.order_validation_service.utils import (
apply_case_sample_validation,
apply_case_validation,
apply_order_validation,
)
from cg.services.order_validation_service.workflows.balsamic.validation_rules import (
CASE_RULES,
CASE_SAMPLE_RULES,
)
from cg.services.order_validation_service.workflows.order_validation_rules import ORDER_RULES
from cg.store.store import Store


class MicroSaltValidationService(OrderValidationService):
seallard marked this conversation as resolved.
Show resolved Hide resolved

def __init__(self, store: Store):
self.store = store

def validate(self, raw_order: dict) -> dict:
errors: ValidationErrors = self._get_errors(raw_order)
return create_order_validation_response(raw_order=raw_order, errors=errors)

def _get_errors(self, raw_order: dict) -> ValidationErrors:
order, field_errors = ModelValidator.validate(order=raw_order, model=BalsamicOrder)

if field_errors:
return field_errors

order_errors: list[OrderError] = apply_order_validation(
rules=ORDER_RULES,
order=order,
store=self.store,
)
case_errors: list[CaseError] = apply_case_validation(
rules=CASE_RULES,
order=order,
store=self.store,
)
case_sample_errors: list[CaseSampleError] = apply_case_sample_validation(
rules=CASE_SAMPLE_RULES,
order=order,
store=self.store,
)

return ValidationErrors(
order_errors=order_errors,
case_errors=case_errors,
case_sample_errors=case_sample_errors,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pydantic import Field
from cg.constants.constants import GenomeVersion
from cg.models.orders.sample_base import NAME_PATTERN, ControlEnum, SexEnum, StatusEnum
from cg.services.order_validation_service.constants import TissueBlockEnum
from cg.services.order_validation_service.models.sample import Sample
Expand Down
Loading