Updated parsers and chart constructors.
This commit is contained in:
@@ -20,6 +20,7 @@ from getpass import getuser
|
||||
import numpy as np
|
||||
import yaml
|
||||
from pathlib import Path
|
||||
from math import ceil
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
@@ -161,9 +162,13 @@ def construct_submission_info(ctx:dict, info_dict:dict) -> models.BasicSubmissio
|
||||
# calculate cost of the run: immutable cost + mutable times number of columns
|
||||
# This is now attached to submission upon creation to preserve at-run costs incase of cost increase in the future.
|
||||
try:
|
||||
instance.run_cost = instance.extraction_kit.immutable_cost + (instance.extraction_kit.mutable_cost * ((instance.sample_count / 8)/12))
|
||||
except (TypeError, AttributeError):
|
||||
logger.debug(f"Looks like that kit doesn't have cost breakdown yet, using full plate cost.")
|
||||
# ceil(instance.sample_count / 8) will get number of columns
|
||||
# the cost of a full run multiplied by (that number / 12) is x twelfths the cost of a full run
|
||||
logger.debug(f"Instance extraction kit details: {instance.extraction_kit.__dict__}")
|
||||
cols_count = ceil(int(instance.sample_count) / 8)
|
||||
instance.run_cost = instance.extraction_kit.constant_cost + (instance.extraction_kit.mutable_cost * (cols_count / 12))
|
||||
except (TypeError, AttributeError) as e:
|
||||
logger.debug(f"Looks like that kit doesn't have cost breakdown yet due to: {e}, using full plate cost.")
|
||||
instance.run_cost = instance.extraction_kit.cost_per_run
|
||||
# We need to make sure there's a proper rsl plate number
|
||||
try:
|
||||
|
||||
@@ -105,6 +105,9 @@ class Control(Base):
|
||||
for key in data[genus]:
|
||||
_dict[key] = data[genus][key]
|
||||
output.append(_dict)
|
||||
# Have to triage kraken data to keep program from getting overwhelmed
|
||||
if "kraken" in mode:
|
||||
output = sorted(output, key=lambda d: d[f"{mode}_count"], reverse=True)[:49]
|
||||
return output
|
||||
|
||||
def create_dummy_data(self, mode:str) -> dict:
|
||||
|
||||
@@ -25,8 +25,8 @@ class KitType(Base):
|
||||
submissions = relationship("BasicSubmission", back_populates="extraction_kit") #: submissions this kit was used for
|
||||
used_for = Column(JSON) #: list of names of sample types this kit can process
|
||||
cost_per_run = Column(FLOAT(2)) #: dollar amount for each full run of this kit NOTE: depreciated, use the constant and mutable costs instead
|
||||
mutable_cost = Column(FLOAT(2)) #: dollar amount that can change with number of columns (reagents, tips, etc)
|
||||
constant_cost = Column(FLOAT(2)) #: dollar amount that will remain constant (plates, man hours, etc)
|
||||
mutable_cost = Column(FLOAT(2)) #: dollar amount per plate that can change with number of columns (reagents, tips, etc)
|
||||
constant_cost = Column(FLOAT(2)) #: dollar amount per plate that will remain constant (plates, man hours, etc)
|
||||
reagent_types = relationship("ReagentType", back_populates="kits", uselist=True, secondary=reagenttypes_kittypes) #: reagent types this kit contains
|
||||
reagent_types_id = Column(INTEGER, ForeignKey("_reagent_types.id", ondelete='SET NULL', use_alter=True, name="fk_KT_reagentstype_id")) #: joined reagent type id
|
||||
|
||||
@@ -110,4 +110,16 @@ class Reagent(Base):
|
||||
"type": type,
|
||||
"lot": self.lot,
|
||||
"expiry": place_holder.strftime("%Y-%m-%d")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# class Discounts(Base):
|
||||
# """
|
||||
# Relationship table for client labs for certain kits.
|
||||
# """
|
||||
# __tablename__ = "_discounts"
|
||||
|
||||
# id = Column(INTEGER, primary_key=True) #: primary key
|
||||
# kit = relationship("KitType") #: joined parent reagent type
|
||||
# kit_id = Column(INTEGER, ForeignKey("_kits.id", ondelete='SET NULL', name="fk_kit_type_id"))
|
||||
# client = relationship("Organization")
|
||||
Reference in New Issue
Block a user