Skip to content

Commit

Permalink
remove organism validation (#4103)
Browse files Browse the repository at this point in the history
remove organism existence validation
  • Loading branch information
diitaz93 authored Jan 16, 2025
1 parent a13c2aa commit 0ef1613
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 60 deletions.
5 changes: 0 additions & 5 deletions cg/services/order_validation_service/errors/sample_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ class VolumeRequiredError(SampleError):
message: str = "Volume is required"


class OrganismDoesNotExistError(SampleError):
field: str = "organism"
message: str = "Organism does not exist"


class SampleNameNotAvailableError(SampleError):
field: str = "name"
message: str = "Sample name already used in previous order"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
)

OrderWithIndexedSamples = FluffyOrder | RmlOrder
OrderWithSamplesFromOrganism = MutantOrder | MicrosaltOrder
OrderWithControlSamples = (
MetagenomeSample | MicrobialFastqOrder | MicrosaltOrder | MutantOrder | TaxprofilerSample
)
17 changes: 0 additions & 17 deletions cg/services/order_validation_service/rules/sample/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
IndexSequenceMissingError,
InvalidVolumeError,
OccupiedWellError,
OrganismDoesNotExistError,
PoolApplicationError,
PoolPriorityError,
SampleNameNotAvailableControlError,
Expand All @@ -29,7 +28,6 @@
from cg.services.order_validation_service.models.order_aliases import (
OrderWithControlSamples,
OrderWithIndexedSamples,
OrderWithSamplesFromOrganism,
)
from cg.services.order_validation_service.models.sample_aliases import IndexedSample
from cg.services.order_validation_service.rules.sample.utils import (
Expand Down Expand Up @@ -211,21 +209,6 @@ def validate_index_sequence_required(
return errors


def validate_organism_exists(
order: OrderWithSamplesFromOrganism, store: Store, **kwargs
) -> list[OrganismDoesNotExistError]:
"""
Validate that the organisms of all samples in the order exist in the database.
Only applicable to Microsalt and Mutant orders.
"""
errors: list[OrganismDoesNotExistError] = []
for sample_index, sample in order.enumerated_samples:
if not store.get_organism_by_internal_id(sample.organism):
error = OrganismDoesNotExistError(sample_index=sample_index)
errors.append(error)
return errors


def validate_pools_contain_one_application(
order: OrderWithIndexedSamples, **kwargs
) -> list[PoolApplicationError]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
validate_applications_not_archived,
validate_container_name_required,
validate_non_control_sample_names_available,
validate_organism_exists,
validate_sample_names_unique,
validate_tube_container_name_unique,
validate_volume_interval,
Expand All @@ -20,7 +19,6 @@
validate_applications_not_archived,
validate_container_name_required,
validate_non_control_sample_names_available,
validate_organism_exists,
validate_sample_names_unique,
validate_tube_container_name_unique,
validate_volume_interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
validate_applications_not_archived,
validate_container_name_required,
validate_non_control_sample_names_available,
validate_organism_exists,
validate_sample_names_unique,
validate_tube_container_name_unique,
validate_volume_interval,
Expand All @@ -20,7 +19,6 @@
validate_applications_not_archived,
validate_container_name_required,
validate_non_control_sample_names_available,
validate_organism_exists,
validate_volume_required,
validate_sample_names_unique,
validate_tube_container_name_unique,
Expand Down
2 changes: 1 addition & 1 deletion cg/store/crud/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
)
from cg.constants.sequencing import DNA_PREP_CATEGORIES, SeqLibraryPrepCategory
from cg.exc import CaseNotFoundError, CgError, OrderNotFoundError, SampleNotFoundError
from cg.models.orders.sample_base import SexEnum
from cg.models.orders.constants import OrderType
from cg.models.orders.sample_base import SexEnum
from cg.server.dto.samples.collaborator_samples_request import CollaboratorSamplesRequest
from cg.services.orders.order_service.models import OrderQueryParams
from cg.store.base import BaseHandler
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/cgweb_orders/microbial_fastq.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"elution_buffer": "Nuclease-free water",
"name": "prov1",
"priority": "priority",
"volume": "1",
"volume": "100",
"well_position": ""
},
{
Expand All @@ -29,7 +29,7 @@
"elution_buffer": "Nuclease-free water",
"name": "prov2",
"priority": "priority",
"volume": "2",
"volume": "20",
"well_position": "A:1"
}
]
Expand Down
4 changes: 2 additions & 2 deletions tests/meta/orders/test_meta_orders_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_too_long_order_name():
OrderType.FASTQ,
OrderType.FLUFFY,
OrderType.METAGENOME,
# OrderType.MICROBIAL_FASTQ,
# OrderType.MICROSALT,
OrderType.MICROBIAL_FASTQ,
OrderType.MICROSALT,
# OrderType.MIP_DNA,
# OrderType.MIP_RNA,
# OrderType.PACBIO_LONG_READ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
ApplicationNotCompatibleError,
ApplicationNotValidError,
InvalidVolumeError,
OrganismDoesNotExistError,
)
from cg.services.order_validation_service.rules.sample.rules import (
validate_application_compatibility,
validate_application_exists,
validate_applications_not_archived,
validate_organism_exists,
validate_volume_interval,
)
from cg.services.order_validation_service.workflows.microsalt.models.order import MicrosaltOrder
Expand Down Expand Up @@ -85,29 +83,3 @@ def test_invalid_volume(valid_microsalt_order: MicrosaltOrder, base_store: Store

# THEN the error should concern the invalid volume
assert isinstance(errors[0], InvalidVolumeError)


def test_invalid_organism(valid_microsalt_order: MicrosaltOrder, base_store: Store):

# GIVEN an order with a sample specifying a non-existent organism
valid_microsalt_order.samples[0].organism = "Non-existent organism"

# WHEN validating that all organisms exist
errors = validate_organism_exists(order=valid_microsalt_order, store=base_store)

# THEN an error should be returned
assert errors

# THEN the error should concern the invalid organism
assert isinstance(errors[0], OrganismDoesNotExistError)


def test_valid_organisms(valid_microsalt_order: MicrosaltOrder, base_store: Store):

# GIVEN a valid order

# WHEN validating that all organisms exist
errors = validate_organism_exists(order=valid_microsalt_order, store=base_store)

# THEN no error should be returned
assert not errors

0 comments on commit 0ef1613

Please sign in to comment.