def test_store_samples(orders_api, base_store, fastq_status_data): # GIVEN a basic store with no samples and a fastq order assert base_store.samples().count() == 0 assert base_store.families().count() == 0 submitter: FastqSubmitter = FastqSubmitter(lims=orders_api.lims, status=orders_api.status) # WHEN storing the order new_samples = submitter.store_items_in_status( customer=fastq_status_data["customer"], order=fastq_status_data["order"], ordered=dt.datetime.now(), ticket=1234348, items=fastq_status_data["samples"], ) # THEN it should store the samples and create a case for each sample assert len(new_samples) == 2 assert base_store.samples().count() == 2 assert base_store.families().count() == 2 first_sample = new_samples[0] assert len(first_sample.links) == 1 family_link = first_sample.links[0] assert family_link.family in base_store.families() for sample in new_samples: assert len(sample.deliveries) == 1 assert family_link.family.data_analysis assert family_link.family.data_delivery == DataDelivery.FASTQ
def test_store_samples_sex_stored(orders_api, base_store, fastq_status_data): # GIVEN a basic store with no samples and a fastq order assert base_store.samples().count() == 0 assert base_store.families().count() == 0 submitter = FastqSubmitter(lims=orders_api.lims, status=orders_api.status) # WHEN storing the order new_samples = submitter.store_items_in_status( customer=fastq_status_data["customer"], order=fastq_status_data["order"], ordered=dt.datetime.now(), ticket=1234348, items=fastq_status_data["samples"], ) # THEN the sample sex should be stored assert new_samples[0].sex == "male"
def test_store_samples_bad_apptag(orders_api, base_store, fastq_status_data): # GIVEN a basic store with no samples and a fastq order assert base_store.samples().count() == 0 assert base_store.families().count() == 0 for sample in fastq_status_data["samples"]: sample["application"] = "nonexistingtag" submitter = FastqSubmitter(lims=orders_api.lims, status=orders_api.status) # THEN it should raise OrderError with pytest.raises(OrderError): # WHEN storing the order submitter.store_items_in_status( customer=fastq_status_data["customer"], order=fastq_status_data["order"], ordered=dt.datetime.now(), ticket=1234348, items=fastq_status_data["samples"], )
def test_store_fastq_samples_tumour_wgs_to_fastq(orders_api, base_store, fastq_status_data): # GIVEN a basic store with no samples and a tumour fastq order as wgs assert base_store.samples().count() == 0 assert base_store.families().count() == 0 base_store.application( fastq_status_data["samples"][0]["application"]).prep_category = "wgs" fastq_status_data["samples"][0]["tumour"] = True submitter = FastqSubmitter(lims=orders_api.lims, status=orders_api.status) # WHEN storing the order new_samples = submitter.store_items_in_status( customer=fastq_status_data["customer"], order=fastq_status_data["order"], ordered=dt.datetime.now(), ticket=1234348, items=fastq_status_data["samples"], ) # THEN the analysis for the case should be FASTQ assert new_samples[0].links[0].family.data_analysis == Pipeline.FASTQ
def test_store_fastq_samples_non_wgs_as_fastq(orders_api, base_store, fastq_status_data): # GIVEN a basic store with no samples and a fastq order as non wgs assert base_store.samples().count() == 0 assert base_store.families().count() == 0 non_wgs_prep_category = "wes" assert base_store.applications(category=non_wgs_prep_category) for sample in fastq_status_data["samples"]: sample["application"] = base_store.applications( category=non_wgs_prep_category)[0].tag submitter = FastqSubmitter(lims=orders_api.lims, status=orders_api.status) # WHEN storing the order new_samples = submitter.store_items_in_status( customer=fastq_status_data["customer"], order=fastq_status_data["order"], ordered=dt.datetime.now(), ticket=1234348, items=fastq_status_data["samples"], ) # THEN the analysis for the case should be fastq (none) assert new_samples[0].links[0].family.data_analysis == Pipeline.FASTQ
def test_samples_to_status(fastq_order_to_submit): # GIVEN fastq order with two samples order = OrderIn.parse_obj(fastq_order_to_submit, OrderType.FASTQ) # WHEN parsing for status data = FastqSubmitter.order_to_status(order=order) # THEN it should pick out samples and relevant information assert len(data["samples"]) == 2 first_sample = data["samples"][0] assert first_sample["name"] == "prov1" assert first_sample["application"] == "WGSPCFC060" assert first_sample["priority"] == "priority" assert first_sample["tumour"] is False assert first_sample["volume"] == "1" # ... and the other sample is a tumour assert data["samples"][1]["tumour"] is True
def fastq_status_data(fastq_order_to_submit): """Parse fastq order example.""" project: OrderType = OrderType.FASTQ order: OrderIn = OrderIn.parse_obj(obj=fastq_order_to_submit, project=project) return FastqSubmitter.order_to_status(order=order)