Skip to content

Commit

Permalink
Add Taxprofiler ordering support (#3935) (minor)
Browse files Browse the repository at this point in the history
### Added

- Taxprofiler excel order form test fixture

### Changed

- 1508 orderforms need to be version 32
  • Loading branch information
islean authored Nov 13, 2024
1 parent e6550dc commit 1406c24
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cg/apps/orderform/excel_orderform_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ExcelOrderformParser(OrderformParser):
model_config = ConfigDict(arbitrary_types_allowed=True)
NO_ANALYSIS: str = "no-analysis"
NO_VALUE: str = "no_value"
SHEET_NAMES: list[str] = ["Orderform", "orderform", "order form"]
SHEET_NAMES: list[str] = ["Orderform", "orderform", "order form", "Order Form"]
VALID_ORDERFORMS: list[str] = [
f"{Orderform.MIP_DNA}:{Orderform.get_current_orderform_version(Orderform.MIP_DNA)}", # Orderform MIP-DNA, Balsamic, sequencing only, MIP-RNA
f"{Orderform.MICROSALT}:{Orderform.get_current_orderform_version(Orderform.MICROSALT)}", # Microbial WGS
Expand Down
3 changes: 2 additions & 1 deletion cg/constants/orderforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class Orderform(StrEnum):
SARS_COV_2: str = "2184"
MICROBIAL_FASTQ: str = "microbial_sequencing"
PACBIO_LONG_READ: str = "pacbio_revio_sequencing"
TAXPROFILER: str = "1508"

@staticmethod
def get_current_orderform_version(order_form: str) -> str:
"""Returns the current version of the given order form."""
current_order_form_versions = {
Orderform.MIP_DNA: "31",
Orderform.MIP_DNA: "32",
Orderform.RML: "19",
Orderform.MICROSALT: "11",
Orderform.SARS_COV_2: "9",
Expand Down
4 changes: 4 additions & 0 deletions cg/models/orders/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ def required_for_new_samples(cls, v: str) -> None:
return None


class TaxprofilerSample(MetagenomeSample):
_suitable_project = OrderType.TAXPROFILER


class MicrobialSample(OrderInSample):
# 1603 Orderform Microbial WGS
# "These fields are required"
Expand Down
1 change: 1 addition & 0 deletions cg/models/orders/validators/excel_sample_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def validate_data_analysis(data_analysis):
"MIP RNA", # OF 1508
"RNAfusion", # OF 1508
"Mutant", # OF 2184
"Taxprofiler", # OF 1508
"Tomte", # OF 1508
"No analysis", # OF 1508, 1604, 2184
]
Expand Down
16 changes: 16 additions & 0 deletions tests/apps/orderform/test_excel_orderform_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,19 @@ def test_parse_microbial_sequencing_orderform(microbial_sequencing_orderform: st
assert order_form_parser.project_type == OrderType.MICROBIAL_FASTQ
# THEN assert that samples are parsed
assert order_form_parser.samples


def test_parse_taxprofiler_orderform(taxprofiler_orderform: str):
"""Test to parse a Taxprofiler orderform in excel format"""

# GIVEN an order form in Excel format
assert is_excel(Path(taxprofiler_orderform))

# GIVEN an ExcelOrderformParser
orderform_parser: ExcelOrderformParser = ExcelOrderformParser()

# WHEN parsing the orderform
orderform_parser.parse_orderform(excel_path=taxprofiler_orderform)

# THEN assert that the project type is correct
assert orderform_parser.project_type == OrderType.TAXPROFILER
9 changes: 9 additions & 0 deletions tests/fixture_plugins/orders_fixtures/order_form_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ def rnafusion_orderform(orderforms: Path) -> str:
).as_posix()


@pytest.fixture
def taxprofiler_orderform(orderforms: Path) -> str:
"""Orderform fixture for sarscov2 samples."""
return Path(
orderforms,
f"{Orderform.TAXPROFILER}.{Orderform.get_current_orderform_version(Orderform.TAXPROFILER)}.taxprofiler.xlsx",
).as_posix()


@pytest.fixture(scope="session")
def mip_uploaded_json_order(orderforms: Path) -> str:
"""JSON orderform fixture for MIP DNA samples."""
Expand Down
Binary file removed tests/fixtures/orderforms/1508.31.balsamic.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.balsamic_qc.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.balsamic_umi.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.fastq.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.metagenome.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.mip.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.mip_rna.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.rnafusion.xlsx
Binary file not shown.
Binary file removed tests/fixtures/orderforms/1508.31.tomte.xlsx
Binary file not shown.
Binary file added tests/fixtures/orderforms/1508.32.balsamic.xlsx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/fixtures/orderforms/1508.32.fastq.xlsx
Binary file not shown.
Binary file not shown.
Binary file added tests/fixtures/orderforms/1508.32.mip.xlsx
Binary file not shown.
Binary file added tests/fixtures/orderforms/1508.32.mip_rna.xlsx
Binary file not shown.
Binary file added tests/fixtures/orderforms/1508.32.rnafusion.xlsx
Binary file not shown.
Binary file not shown.
Binary file added tests/fixtures/orderforms/1508.32.tomte.xlsx
Binary file not shown.

0 comments on commit 1406c24

Please sign in to comment.