Skip to content

Commit

Permalink
remove directory for balsamic specific rules
Browse files Browse the repository at this point in the history
  • Loading branch information
diitaz93 committed Jan 17, 2025
1 parent cdb4465 commit 35f7979
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 35 deletions.
19 changes: 19 additions & 0 deletions cg/services/orders/validation/rules/case_sample/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ApplicationNotCompatibleError,
ApplicationNotValidError,
BufferMissingError,
CaptureKitMissingError,
ConcentrationRequiredIfSkipRCError,
ContainerNameMissingError,
ContainerNameRepeatedError,
Expand Down Expand Up @@ -52,6 +53,7 @@
is_concentration_missing,
is_container_name_missing,
is_invalid_plate_well_format,
is_sample_missing_capture_kit,
is_sample_tube_name_reused,
is_well_position_missing,
validate_concentration_in_case,
Expand All @@ -62,6 +64,7 @@
is_volume_invalid,
is_volume_missing,
)
from cg.services.orders.validation.workflows.balsamic.models.order import BalsamicOrder
from cg.store.models import Sample as DbSample
from cg.store.store import Store

Expand Down Expand Up @@ -438,3 +441,19 @@ def validate_buffer_required(order: OrderWithCases, **kwargs) -> list[BufferMiss
error = BufferMissingError(case_index=case_index, sample_index=sample_index)
errors.append(error)
return errors


def validate_capture_kit_panel_requirement(
order: BalsamicOrder, store: Store
) -> list[CaptureKitMissingError]:
"""
Return an error for each new sample missing a capture kit, if its application requires one.
Applicable to Balsamic orders only.
"""
errors: list[CaptureKitMissingError] = []
for case_index, case in order.enumerated_new_cases:
for sample_index, sample in case.enumerated_new_samples:
if is_sample_missing_capture_kit(sample=sample, store=store):
error = CaptureKitMissingError(case_index=case_index, sample_index=sample_index)
errors.append(error)
return errors
13 changes: 13 additions & 0 deletions cg/services/orders/validation/rules/case_sample/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import Counter

from cg.constants.constants import StatusOptions
from cg.constants.sequencing import SeqLibraryPrepCategory
from cg.constants.subject import Sex
from cg.models.orders.sample_base import ContainerEnum, SexEnum
from cg.services.orders.validation.errors.case_errors import RepeatedCaseNameError
Expand Down Expand Up @@ -33,6 +34,8 @@
is_sample_on_plate,
is_volume_within_allowed_interval,
)
from cg.services.orders.validation.workflows.balsamic.models.sample import BalsamicSample
from cg.store.models import Application
from cg.store.store import Store


Expand Down Expand Up @@ -283,3 +286,13 @@ def is_buffer_missing(sample: SampleInCase) -> bool:
sample.application.startswith(tuple(applications_requiring_buffer))
and not sample.elution_buffer
)


def is_sample_missing_capture_kit(sample: BalsamicSample, store: Store) -> bool:
"""Returns whether a TGS sample has an application and is missing a capture kit."""
application: Application | None = store.get_application_by_tag(sample.application)
return (
application
and application.prep_category == SeqLibraryPrepCategory.TARGETED_GENOME_SEQUENCING
and not sample.capture_kit
)
Empty file.
16 changes: 0 additions & 16 deletions cg/services/orders/validation/workflows/balsamic/rules.py

This file was deleted.

13 changes: 0 additions & 13 deletions cg/services/orders/validation/workflows/balsamic/utils.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
validate_application_not_archived,
validate_buffer_required,
validate_buffer_skip_rc_condition,
validate_capture_kit_panel_requirement,
validate_concentration_interval_if_skip_rc,
validate_concentration_required_if_skip_rc,
validate_container_name_required,
Expand All @@ -27,9 +28,6 @@
validate_well_positions_required,
validate_wells_contain_at_most_one_sample,
)
from cg.services.orders.validation.workflows.balsamic.rules import (
validate_capture_kit_panel_requirement,
)

BALSAMIC_CASE_RULES: list[callable] = [
validate_at_most_two_samples_per_case,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
validate_at_most_two_samples_per_case,
validate_number_of_normal_samples,
)
from cg.services.orders.validation.workflows.balsamic.models.order import BalsamicOrder
from cg.services.orders.validation.workflows.balsamic.models.sample import BalsamicSample
from cg.services.orders.validation.workflows.balsamic.rules import (
from cg.services.orders.validation.rules.case_sample.rules import (
validate_capture_kit_panel_requirement,
)
from cg.services.orders.validation.workflows.balsamic.models.order import BalsamicOrder
from cg.services.orders.validation.workflows.balsamic.models.sample import BalsamicSample
from cg.store.models import Application
from cg.store.store import Store

Expand Down

0 comments on commit 35f7979

Please sign in to comment.