def add_application_object( application: ApplicationSchema, sign: str, store: Store ) -> models.Application: """Adds an application from a raw application record""" new_application: models.Application = store.add_application( tag=application.tag, category=application.prep_category, description=application.description, is_accredited=application.is_accredited == 1.0, turnaround_time=application.turnaround_time, minimum_order=application.minimum_order, sequencing_depth=application.sequencing_depth, target_reads=application.target_reads, sample_amount=application.sample_amount, sample_volume=application.sample_volume, sample_concentration=application.sample_concentration, priority_processing=application.priority_processing == 1.0, details=application.details, limitations=application.limitations, percent_kth=application.percent_kth, percent_reads_guaranteed=application.percent_reads_guaranteed, comment=application.comment + " Added by %s" % sign, is_archived=application.is_archived == 1.0, is_external=application.is_external == 1.0, created_at=datetime.now(), ) return new_application
def add_application( store: Store, application_tag: str = "dummy_tag", application_type: str = "wgs", description: str = None, is_archived: bool = False, is_accredited: bool = False, is_external: bool = False, min_sequencing_depth: int = 30, **kwargs, ) -> models.Application: """Utility function to add a application to a store""" application = store.application(tag=application_tag) if application: return application if not description: description = "dummy_description" application = store.add_application( tag=application_tag, category=application_type, description=description, is_archived=is_archived, percent_kth=80, percent_reads_guaranteed=75, is_accredited=is_accredited, limitations="A limitation", is_external=is_external, min_sequencing_depth=min_sequencing_depth, **kwargs, ) store.add_commit(application) return application
def add_application( store: Store, application_tag: str = "dummy_tag", application_type: str = "wgs", description: str = None, is_accredited: bool = False, is_external: bool = False, **kwargs, ) -> models.Application: """Utility function to add a application to a store""" application = store.application(tag=application_tag) if application: return application if not description: description = "dummy_description" application = store.add_application( tag=application_tag, category=application_type, description=description, percent_kth=80, is_accredited=is_accredited, limitations="A limitation", is_external=is_external, ) store.add_commit(application) return application
def test_add_pool(store: Store): # GIVEN a valid customer and a valid application_version customer_group = store.add_customer_group("dummy_group", "dummy group") new_customer = store.add_customer( internal_id="cust000", name="Test customer", scout_access=True, customer_group=customer_group, invoice_address="skolgatan 15", invoice_reference="abc", ) store.add_commit(new_customer) application = store.add_application( tag="RMLS05R150", category="rml", description="Ready-made", percent_kth=80, sequencing_depth=0, ) store.add_commit(application) app_version = store.add_version( application=application, version=1, valid_from=dt.today(), prices={ "standard": 12, "priority": 222, "express": 123, "research": 12 }, ) store.add_commit(app_version) # WHEN adding a new pool into the database new_pool = store.add_pool( customer=new_customer, name="Test", order="Test", ordered=dt.today(), application_version=app_version, data_analysis="fastq", ) store.add_commit(new_pool) # THEN the new pool should have no_invoice = False pool = store.pools(customer=None).first() assert pool.no_invoice is False
def ensure_applications(base_store: Store, active_applications: list, inactive_applications: list): """Create some requested applications for the tests """ for active_application in active_applications: if not base_store.application(active_application): base_store.add_commit( base_store.add_application( active_application, "mic", "dummy_description", is_archived=False, percent_kth=80, )) for inactive_application in inactive_applications: if not base_store.application(inactive_application): base_store.add_commit( base_store.add_application( inactive_application, category="mic", description="dummy_description", is_archived=True, percent_kth=80, ))
def add_application_from_raw(raw_application, sign, store: Store): """Adds an application from a raw application record""" new_application = store.add_application( tag=_get_tag_from_raw_application(raw_application), category=raw_application["prep_category"], description=raw_application["description"], is_accredited=raw_application["is_accredited"] == 1.0, turnaround_time=raw_application["turnaround_time"], minimum_order=raw_application["minimum_order"], sequencing_depth=raw_application["sequencing_depth"], target_reads=raw_application["target_reads"], sample_amount=raw_application["sample_amount"], sample_volume=raw_application["sample_volume"], sample_concentration=raw_application["sample_concentration"], priority_processing=raw_application["priority_processing"] == 1.0, details=raw_application["details"], limitations=raw_application["limitations"], percent_kth=raw_application["percent_kth"], comment=raw_application["comment"] + " Added by %s" % sign, is_archived=raw_application["is_archived"] == 1.0, is_external=raw_application["is_external"] == 1.0, created_at=datetime.now(), ) return new_application
def fixture_base_store(store: Store, apptag_rna: str) -> Store: """Setup and example store.""" customer_group = store.add_customer_group("all_customers", "all customers") store.add_commit(customer_group) customers = [ store.add_customer( "cust000", "Production", scout_access=True, customer_group=customer_group, invoice_address="Test street", invoice_reference="ABCDEF", ), store.add_customer( "cust001", "Customer", scout_access=False, customer_group=customer_group, invoice_address="Test street", invoice_reference="ABCDEF", ), store.add_customer( "cust002", "Karolinska", scout_access=True, customer_group=customer_group, invoice_address="Test street", invoice_reference="ABCDEF", ), store.add_customer( "cust003", "CMMS", scout_access=True, customer_group=customer_group, invoice_address="Test street", invoice_reference="ABCDEF", ), ] store.add_commit(customers) applications = [ store.add_application( tag="WGXCUSC000", category="wgs", description="External WGS", sequencing_depth=0, is_external=True, percent_kth=80, percent_reads_guaranteed=75, target_reads=10, ), store.add_application( tag="EXXCUSR000", category="wes", description="External WES", sequencing_depth=0, is_external=True, percent_kth=80, percent_reads_guaranteed=75, target_reads=10, ), store.add_application( tag="WGSPCFC060", category="wgs", description="WGS, double", sequencing_depth=30, accredited=True, percent_kth=80, percent_reads_guaranteed=75, target_reads=10, ), store.add_application( tag="RMLP05R800", category="rml", description="Ready-made", sequencing_depth=0, percent_kth=80, percent_reads_guaranteed=75, target_reads=10, ), store.add_application( tag="WGSPCFC030", category="wgs", description="WGS trio", is_accredited=True, sequencing_depth=30, target_reads=30, limitations="some", percent_kth=80, percent_reads_guaranteed=75, ), store.add_application( tag="METLIFR020", category="wgs", description="Whole genome metagenomics", sequencing_depth=0, target_reads=400000, percent_kth=80, percent_reads_guaranteed=75, ), store.add_application( tag="METNXTR020", category="wgs", description="Metagenomics", sequencing_depth=0, target_reads=200000, percent_kth=80, percent_reads_guaranteed=75, ), store.add_application( tag="MWRNXTR003", category="mic", description="Microbial whole genome ", sequencing_depth=0, percent_kth=80, percent_reads_guaranteed=75, target_reads=10, ), store.add_application( tag=apptag_rna, category="tgs", description="RNA seq, poly-A based priming", percent_kth=80, percent_reads_guaranteed=75, sequencing_depth=25, accredited=True, target_reads=10, ), store.add_application( tag="VWGDPTR001", category="cov", description="Viral whole genome ", sequencing_depth=0, percent_kth=80, percent_reads_guaranteed=75, target_reads=10, ), ] store.add_commit(applications) prices = {"standard": 10, "priority": 20, "express": 30, "research": 5} versions = [ store.add_version(application, 1, valid_from=dt.datetime.now(), prices=prices) for application in applications ] store.add_commit(versions) beds = [store.add_bed("Bed")] store.add_commit(beds) bed_versions = [store.add_bed_version(bed, 1, "Bed.bed") for bed in beds] store.add_commit(bed_versions) organism = store.add_organism("C. jejuni", "C. jejuni") store.add_commit(organism) yield store