Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    def ensure_application_version(
        store: Store,
        application_tag: str = "dummy_tag",
        application_type: str = "wgs",
        is_external: bool = False,
        is_rna: bool = False,
        description: str = None,
        sequencing_depth: int = None,
        is_accredited: bool = False,
    ) -> models.ApplicationVersion:
        """Utility function to return existing or create application version for tests"""
        if is_rna:
            application_tag = "rna_tag"
            application_type = "wts"

        application = store.application(tag=application_tag)
        if not application:
            application = StoreHelpers.add_application(
                store,
                application_tag,
                application_type,
                is_external=is_external,
                description=description,
                is_accredited=is_accredited,
                sequencing_depth=sequencing_depth,
            )

        prices = {"standard": 10, "priority": 20, "express": 30, "research": 5}
        version = store.application_version(application, 1)
        if not version:
            version = store.add_version(application, 1, valid_from=datetime.now(), prices=prices)

            store.add_commit(version)
        return version
Ejemplo n.º 4
0
    def ensure_customer(
        store: Store,
        customer_id: str = "cust000",
        name: str = "Production",
        scout_access: bool = False,
        customer_group: str = "all_customers",
    ) -> models.Customer:
        """Utility function to return existing or create customer for tests"""
        customer_group_id = customer_group or customer_id + "_group"
        customer_group = store.customer_group(customer_group_id)
        if not customer_group:
            customer_group = store.add_customer_group(customer_group_id, customer_group_id)

        customer = store.customer(customer_id)

        if not customer:
            customer = store.add_customer(
                internal_id=customer_id,
                name=name,
                scout_access=scout_access,
                customer_group=customer_group,
                invoice_address="Test street",
                invoice_reference="ABCDEF",
            )
            store.add_commit(customer)
        return customer
Ejemplo n.º 5
0
def test_contact_storing(store: Store, contact_type, helpers):

    # GIVEN an empty database
    assert store.Customer.query.first() is None
    internal_id, name, scout_access = "cust000", "Test customer", True
    customer_group = store.add_customer_group("dummy_group", "dummy group")
    contact_email = contact_type + "*****@*****.**"
    contact_name = contact_type

    # WHEN adding a new customer and setting the new field
    new_customer = store.add_customer(
        internal_id=internal_id,
        name=name,
        scout_access=scout_access,
        customer_group=customer_group,
        invoice_address="dummy street 1",
        invoice_reference="dummy nr",
    )

    new_user = store.add_user(new_customer, contact_email, contact_name)

    contact_field = contact_type + "_contact"
    setattr(new_customer, contact_field, new_user)
    store.add_commit(new_customer)

    # THEN contact should be stored on the customer
    assert getattr(store.customer(internal_id=internal_id),
                   contact_field) == new_user
Ejemplo n.º 6
0
    def add_family(
        self,
        store: Store,
        family_id: str = "family_test",
        customer_id: str = "cust000",
        panels: List = None,
        family_obj: models.Family = None,
    ) -> models.Family:
        """Utility function to add a family to use in tests,
           If no family object is used a autogenerated family id will be used

        """
        customer = self.ensure_customer(store, customer_id)
        if family_obj:
            panels = family_obj.panels
        if not panels:
            panels = ["panel_test"]
        for panel_name in panels:
            self.ensure_panel(store,
                              panel_id=panel_name,
                              customer_id=customer_id)

        if not family_obj:
            family_obj = store.add_family(name=family_id, panels=panels)

        print("Adding family with name %s (%s)" %
              (family_obj.name, family_obj.internal_id))
        family_obj.customer = customer
        store.add_commit(family_obj)
        return family_obj
Ejemplo n.º 7
0
def test_add_microbial_sample(base_store: Store):
    # GIVEN an empty database
    assert base_store.MicrobialSample.query.first() is None
    name = "microbial_sample"
    organism_name = "e. coli"
    internal_id = "lims-id"
    reference_genome = "ref_gen"
    priority = "research"
    application_version = base_store.ApplicationVersion.query.first()
    base_store.add_organism(organism_name, organism_name, reference_genome)
    organism = base_store.Organism.query.first()
    microbial_order_id = "dummy_order_id"

    # WHEN adding a new microbial sample
    new_microbial_sample = base_store.add_microbial_sample(
        microbial_order_id=microbial_order_id,
        name=name,
        organism=organism,
        internal_id=internal_id,
        reference_genome=reference_genome,
        application_version=application_version,
        priority=priority,
    )
    base_store.add_commit(new_microbial_sample)

    # THEN it should be stored in the database
    assert base_store.MicrobialSample.query.first() == new_microbial_sample
    stored_microbial_sample = base_store.MicrobialSample.query.first()
    assert stored_microbial_sample.name == name
    assert stored_microbial_sample.internal_id == internal_id
    assert stored_microbial_sample.reference_genome == reference_genome
    assert stored_microbial_sample.application_version == application_version
    assert stored_microbial_sample.priority_human == priority
    assert stored_microbial_sample.organism == organism
Ejemplo n.º 8
0
    def add_sample(
        self,
        store: Store,
        sample_id: str = "sample_test",
        gender: str = "female",
        is_tumour: bool = False,
        is_rna: bool = False,
        is_external: bool = False,
        data_analysis: str = "balsamic",
        application_tag: str = "dummy_tag",
        application_type: str = "tgs",
        customer_name: str = None,
        reads: int = None,
        **kwargs,
    ) -> models.Sample:
        """Utility function to add a sample to use in tests"""
        customer_name = customer_name or "cust000"
        customer = self.ensure_customer(store, customer_name)
        application_version = self.ensure_application_version(
            store,
            application_tag=application_tag,
            application_type=application_type,
            is_external=is_external,
            is_rna=is_rna,
        )
        print(repr(application_version))
        application_version_id = application_version.id
        sample = store.add_sample(
            name=sample_id,
            sex=gender,
            tumour=is_tumour,
            sequenced_at=datetime.now(),
            data_analysis=data_analysis,
            reads=reads,
        )

        sample.application_version_id = application_version_id
        sample.customer = customer
        print("Set is external to %s", is_external)
        sample.is_external = is_external

        if kwargs.get("delivered_at"):
            print("Adding delivered")
            sample.delivered_at = kwargs["delivered_at"]

        if kwargs.get("received_at"):
            print("Adding received_at")
            sample.received_at = kwargs["received_at"]

        if kwargs.get("prepared_at"):
            print("Adding prepared")
            sample.received_at = kwargs["prepared_at"]

        if kwargs.get("flowcell"):
            print("Adding flowcell")
            sample.flowcells.append(kwargs["flowcell"])

        store.add_commit(sample)
        return sample
Ejemplo n.º 9
0
def test_add_customer_group(store: Store):
    # GIVEN an empty database
    assert store.CustomerGroup.query.first() is None
    internal_id, name = "cust_group", "Test customer group"

    # WHEN adding a new customer group
    new_customer_group = store.add_customer_group(internal_id=internal_id, name=name)
    store.add_commit(new_customer_group)

    # THEN it should be stored in the database
    assert store.CustomerGroup.query.first() == new_customer_group
Ejemplo n.º 10
0
    def ensure_bed_version(store: Store, bed_name: str = "dummy_bed") -> models.ApplicationVersion:
        """Utility function to return existing or create bed version for tests"""
        bed = store.bed(name=bed_name)
        if not bed:
            bed = store.add_bed(name=bed_name)
            store.add_commit(bed)

        version = store.latest_bed_version(bed_name)
        if not version:
            version = store.add_bed_version(bed, 1, "dummy_filename", shortname=bed_name)
            store.add_commit(version)
        return version
Ejemplo n.º 11
0
def store_samples_with_names_from_order(store: Store, helpers: StoreHelpers,
                                        order_data: OrderIn):
    customer_obj = store.customer(order_data.customer)
    for sample in order_data.samples:
        sample_name = sample.name
        if not store.find_samples(customer=customer_obj,
                                  name=sample_name).first():
            sample_obj = helpers.add_sample(
                store=store,
                name=sample_name,
                customer_id=customer_obj.internal_id)
            store.add_commit(sample_obj)
Ejemplo n.º 12
0
 def ensure_organism(
     store: Store,
     organism_id: str = "organism_test",
     name: str = "organism_name",
     reference_genome: str = "reference_genome_test",
 ) -> models.Organism:
     """Utility function to add an organism to use in tests"""
     organism = StoreHelpers.add_organism(
         store, internal_id=organism_id, name=name, reference_genome=reference_genome
     )
     store.add_commit(organism)
     return organism
Ejemplo n.º 13
0
    def add_sample(
        store: Store,
        application_tag: str = "dummy_tag",
        application_type: str = "tgs",
        control: str = "",
        customer_id: str = None,
        gender: str = "female",
        is_external: bool = False,
        is_rna: bool = False,
        is_tumour: bool = False,
        reads: int = None,
        name: str = "sample_test",
        ticket: int = None,
        **kwargs,
    ) -> models.Sample:
        """Utility function to add a sample to use in tests"""
        customer_id = customer_id or "cust000"
        customer = StoreHelpers.ensure_customer(store, customer_id=customer_id)
        application_version = StoreHelpers.ensure_application_version(
            store=store,
            application_tag=application_tag,
            application_type=application_type,
            is_external=is_external,
            is_rna=is_rna,
        )
        application_version_id = application_version.id
        sample = store.add_sample(
            control=control,
            name=name,
            reads=reads,
            sex=gender,
            ticket=ticket,
            tumour=is_tumour,
        )

        sample.application_version_id = application_version_id
        sample.customer = customer
        sample.ordered_at = datetime.now()

        for key, value in kwargs.items():
            if key == "flowcell":
                sample.flowcells.append(kwargs["flowcell"])
            elif hasattr(sample, key):
                setattr(sample, key, value)
            else:
                raise AttributeError(f"Unknown sample attribute/feature: {key}, {value}")

        store.add_commit(sample)
        return sample
Ejemplo n.º 14
0
 def add_microbial_sample_and_order(
     self,
     store: Store,
     order_id: str = "microbial_order_test",
     sample_id: str = "microbial_sample_test",
     customer_id: str = "cust_test",
 ) -> models.MicrobialSample:
     """Utility add a order and a sample to use in tests"""
     self.ensure_application_version(store)
     self.ensure_customer(store, customer_id)
     organism = self.ensure_organism(store)
     order = self.ensure_microbial_order(store)
     sample = self.add_microbial_sample(store, organism=organism)
     sample.microbial_order_id = order.id
     store.add_commit(sample)
     return sample
Ejemplo n.º 15
0
 def add_relationship(
     store: Store,
     sample: models.Sample,
     family: models.Family,
     status: str = "unknown",
     father: models.Sample = None,
     mother: models.Sample = None,
 ) -> models.FamilySample:
     """Utility function to link a sample to a family"""
     link = store.relate_sample(sample=sample,
                                family=family,
                                status=status,
                                father=father,
                                mother=mother)
     store.add_commit(link)
     return link
Ejemplo n.º 16
0
 def ensure_panel(
     store: Store, panel_id: str = "panel_test", customer_id: str = "cust000"
 ) -> models.Panel:
     """Utility function to add a panel to use in tests"""
     customer = StoreHelpers.ensure_customer(store, customer_id)
     panel = store.panel(panel_id)
     if not panel:
         panel = store.add_panel(
             customer=customer,
             name=panel_id,
             abbrev=panel_id,
             version=1.0,
             date=datetime.now(),
             genes=1,
         )
         store.add_commit(panel)
     return panel
Ejemplo n.º 17
0
def test_add_customer(store: Store):
    # GIVEN an empty database
    assert store.Customer.query.first() is None
    internal_id, name, scout_access = "cust000", "Test customer", True
    customer_group = store.add_customer_group("dummy_group", "dummy group")

    # WHEN adding a new customer
    new_customer = store.add_customer(
        internal_id=internal_id,
        name=name,
        scout_access=scout_access,
        customer_group=customer_group,
        invoice_address="dummy street 1",
        invoice_reference="dummy nr",
    )
    store.add_commit(new_customer)

    # THEN it should be stored in the database
    assert store.Customer.query.first() == new_customer
Ejemplo n.º 18
0
    def ensure_microbial_order(
        self,
        store: Store,
        order_id: str = "microbial_order_test",
        name: str = "microbial_name_test",
        customer_id: str = "cust_test",
    ) -> models.MicrobialOrder:
        """Utility function add a microbial order and sample"""
        customer = self.ensure_customer(store, customer_id)
        order = store.add_microbial_order(
            customer=customer,
            internal_id=order_id,
            name=name,
            ordered=datetime.now(),
            ticket_number=123456,
        )
        store.add_commit(order)

        return order
Ejemplo n.º 19
0
    def add_flowcell(
        store: Store,
        flowcell_id: str = "flowcell_test",
        archived_at: datetime = None,
        samples: list = None,
    ) -> models.Flowcell:
        """Utility function to set a flowcell to use in tests"""
        flowcell_obj = store.add_flowcell(
            name=flowcell_id,
            sequencer="dummy_sequencer",
            sequencer_type="hiseqx",
            date=datetime.now(),
        )
        flowcell_obj.archived_at = archived_at
        if samples:
            flowcell_obj.samples = samples

        store.add_commit(flowcell_obj)
        return flowcell_obj
Ejemplo n.º 20
0
def test_add_user(store: Store):
    # GIVEN a database with a customer in it that we can connect the user to
    customer_group = store.add_customer_group("dummy_group", "dummy group")
    customer = store.add_customer(
        internal_id="custtest",
        name="Test Customer",
        scout_access=False,
        customer_group=customer_group,
        invoice_address="dummy street 1",
        invoice_reference="dummy nr",
    )
    store.add_commit(customer)

    # WHEN adding a new user
    name, email = "Paul T. Anderson", "*****@*****.**"
    new_user = store.add_user(customer=customer, email=email, name=name)

    store.add_commit(new_user)

    # THEN it should be stored in the database
    assert store.User.query.first() == new_user
Ejemplo n.º 21
0
def test_microbial_sample_to_dict(microbial_store: Store, helpers):

    # GIVEN a store with a Microbial sample
    sample_obj = helpers.add_microbial_sample(microbial_store)
    microbial_store.add_commit(sample_obj)
    assert sample_obj

    # WHEN running to dict on that sample
    a_dict = sample_obj.to_dict(links=True)

    # THEN you should get a dictionary with
    assert a_dict["id"]
    assert a_dict["internal_id"]
    assert a_dict["name"]
    assert a_dict["application_version_id"]
    assert a_dict["created_at"]
    assert a_dict["priority"]
    assert a_dict["reads"]
    assert a_dict["comment"]
    assert a_dict["application"]
    assert a_dict["application_version"]
Ejemplo n.º 22
0
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
Ejemplo n.º 23
0
def test_get_family_by_name(invoke_cli, disk_store: Store):
    # GIVEN A database with a customer in it
    customer_id = "customer-test"
    customer_group = disk_store.add_customer_group("dummy_group", "dummy group")
    customer = disk_store.add_customer(
        internal_id=customer_id,
        name="Test Customer",
        scout_access=False,
        customer_group=customer_group,
        invoice_address="Street nr, 12345 Uppsala",
        invoice_reference="ABCDEF",
    )
    disk_store.add_commit(customer)

    # WHEN trying to get a non-existing family by name
    db_uri = disk_store.uri
    result = invoke_cli(
        ["--database", db_uri, "get", "family", "-c", customer_id, "-n", "dummy-family-name",]
    )

    # THEN it should not crash
    assert result.exit_code == 0
Ejemplo n.º 24
0
    def add_analysis(
        self,
        store: Store,
        family: models.Family = None,
        started_at: datetime = None,
        completed_at: datetime = None,
        uploaded_at: datetime = None,
        upload_started: datetime = None,
        delivery_reported_at: datetime = None,
        pipeline: str = "dummy_pipeline",
        pipeline_version: str = "1.0",
        uploading: bool = False,
        config_path: str = None,
    ) -> models.Analysis:
        """Utility function to add an analysis for tests"""

        if not family:
            family = self.add_family(store)

        analysis = store.add_analysis(pipeline=pipeline,
                                      version=pipeline_version)

        if started_at:
            analysis.started_at = started_at
        if completed_at:
            analysis.completed_at = completed_at
        if uploaded_at:
            analysis.uploaded_at = uploaded_at
        if delivery_reported_at:
            analysis.delivery_report_created_at = delivery_reported_at
        if uploading:
            analysis.upload_started_at = upload_started or datetime.now()
        if config_path:
            analysis.config_path = config_path

        analysis.limitations = "A limitation"
        analysis.family = family
        store.add_commit(analysis)
        return analysis
Ejemplo n.º 25
0
def test_add_microbial_sample(base_store: Store, helpers):
    # GIVEN an empty database
    assert base_store.Sample.query.first() is None
    customer_obj = helpers.ensure_customer(base_store)
    assert customer_obj
    name = "microbial_sample"
    organism_name = "e. coli"
    internal_id = "lims-id"
    reference_genome = "ref_gen"
    priority = "research"
    ticket_number = 123456
    application_version = base_store.ApplicationVersion.query.first()
    base_store.add_organism(organism_name, organism_name, reference_genome)
    organism = base_store.Organism.query.first()

    # WHEN adding a new microbial sample
    new_sample = base_store.add_sample(
        application_version=application_version,
        internal_id=internal_id,
        name=name,
        organism=organism,
        priority=priority,
        reference_genome=reference_genome,
        sex="unknown",
        ticket=ticket_number,
    )
    new_sample.customer = customer_obj
    base_store.add_commit(new_sample)

    # THEN it should be stored in the database
    assert base_store.Sample.query.first() == new_sample
    stored_microbial_sample = base_store.Sample.query.first()
    assert stored_microbial_sample.name == name
    assert stored_microbial_sample.internal_id == internal_id
    assert stored_microbial_sample.reference_genome == reference_genome
    assert stored_microbial_sample.application_version == application_version
    assert stored_microbial_sample.priority_human == priority
    assert stored_microbial_sample.organism == organism
Ejemplo n.º 26
0
    def add_case(
        store: Store,
        name: str = "case_test",
        data_analysis: Pipeline = Pipeline.MIP_DNA,
        data_delivery: DataDelivery = DataDelivery.SCOUT,
        action: str = None,
        internal_id: str = None,
        customer_id: str = "cust000",
        panels: List = ["panel_test"],
        case_obj: models.Family = None,
    ) -> models.Family:
        """Utility function to add a case to use in tests,
        If no case object is used a autogenerated case id will be used

        """
        customer = StoreHelpers.ensure_customer(store, customer_id)
        if case_obj:
            panels = case_obj.panels
        for panel_name in panels:
            StoreHelpers.ensure_panel(store=store, panel_id=panel_name, customer_id=customer_id)

        if not case_obj:
            case_obj: Optional[models.Family] = store.family(internal_id=name)
        if not case_obj:
            case_obj = store.add_case(
                data_analysis=data_analysis,
                data_delivery=data_delivery,
                name=name,
                panels=panels,
            )
        if action:
            case_obj.action = action
        if internal_id:
            case_obj.internal_id = internal_id

        case_obj.customer = customer
        store.add_commit(case_obj)
        return case_obj
Ejemplo n.º 27
0
def test_add_user(invoke_cli, disk_store: Store):
    # GIVEN a database with a customer in it that we can connect the user to
    customer_id = "custtest"
    customer_group = disk_store.add_customer_group("dummy_group",
                                                   "dummy group")
    customer = disk_store.add_customer(
        internal_id=customer_id,
        name="Test Customer",
        scout_access=False,
        customer_group=customer_group,
        invoice_address="Street nr, 12345 Uppsala",
        invoice_reference="ABCDEF",
    )
    disk_store.add_commit(customer)

    # WHEN adding a new user
    name, email = "Paul T. Anderson", "*****@*****.**"
    db_uri = disk_store.uri
    result = invoke_cli(
        ["--database", db_uri, "add", "user", "-c", customer_id, email, name])

    # THEN it should be stored in the database
    assert result.exit_code == 0
    assert disk_store.User.query.count() == 1
Ejemplo n.º 28
0
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,
                ))
Ejemplo n.º 29
0
def test_submit_scout_legal_sample_customer(
    all_orders_to_submit: dict,
    monkeypatch,
    order_type: OrderType,
    orders_api: OrdersAPI,
    sample_store: Store,
    ticket_number: int,
    user_mail: str,
    user_name: str,
):

    order_data = OrderIn.parse_obj(obj=all_orders_to_submit[order_type],
                                   project=order_type)
    monkeypatch_process_lims(monkeypatch, order_data)
    # GIVEN we have an order with a customer that is in the same customer group as customer
    # that the samples originate from
    customer_group = sample_store.add_customer_group(
        "customer999only", "customer 999 only group")
    sample_store.add_commit(customer_group)
    sample_customer = sample_store.add_customer(
        "customer1",
        "customer 1",
        scout_access=True,
        invoice_address="dummy street 1",
        customer_group=customer_group,
        invoice_reference="dummy nr",
    )
    order_customer = sample_store.add_customer(
        "customer2",
        "customer 2",
        scout_access=True,
        invoice_address="dummy street 2",
        customer_group=customer_group,
        invoice_reference="dummy nr",
    )
    sample_store.add_commit(sample_customer)
    sample_store.add_commit(order_customer)
    existing_sample = sample_store.samples().first()
    existing_sample.customer = sample_customer
    sample_store.commit()
    order_data.customer = order_customer.internal_id

    for sample in order_data.samples:
        sample.internal_id = existing_sample.internal_id
        break

    # WHEN calling submit
    # THEN an OrderError should not be raised on illegal customer
    orders_api.submit(project=order_type,
                      order_in=order_data,
                      user_name=user_name,
                      user_mail=user_mail)
Ejemplo n.º 30
0
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