Bug fixes
This commit is contained in:
@@ -1880,34 +1880,34 @@ class Wastewater(BasicSubmission):
|
|||||||
new_control.save()
|
new_control.save()
|
||||||
return report
|
return report
|
||||||
|
|
||||||
def update_subsampassoc(self, assoc: SubmissionSampleAssociation, input_dict: dict) -> SubmissionSampleAssociation:
|
# def update_subsampassoc(self, assoc: SubmissionSampleAssociation, input_dict: dict) -> SubmissionSampleAssociation:
|
||||||
"""
|
# """
|
||||||
Updates a joined submission sample association by assigning ct values to n1 or n2 based on alphabetical sorting.
|
# Updates a joined submission sample association by assigning ct values to n1 or n2 based on alphabetical sorting.
|
||||||
|
|
||||||
Args:
|
|
||||||
sample (BasicSample): Associated sample.
|
|
||||||
input_dict (dict): values to be updated
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
SubmissionSampleAssociation: Updated association
|
|
||||||
"""
|
|
||||||
# logger.debug(f"Input dict: {pformat(input_dict)}")
|
|
||||||
#
|
#
|
||||||
assoc = super().update_subsampassoc(assoc=assoc, input_dict=input_dict)
|
# Args:
|
||||||
# targets = {k: input_dict[k] for k in sorted(input_dict.keys()) if k.startswith("ct_")}
|
# sample (BasicSample): Associated sample.
|
||||||
# assert 0 < len(targets) <= 2
|
# input_dict (dict): values to be updated
|
||||||
# for k, v in targets.items():
|
#
|
||||||
# # logger.debug(f"Setting sample {sample} with key {k} to value {v}")
|
# Returns:
|
||||||
# # update_key = f"ct_n{i}"
|
# SubmissionSampleAssociation: Updated association
|
||||||
# current_value = getattr(assoc, k)
|
# """
|
||||||
# logger.debug(f"Current value came back as: {current_value}")
|
# # logger.debug(f"Input dict: {pformat(input_dict)}")
|
||||||
# if current_value is None:
|
# #
|
||||||
# setattr(assoc, k, v)
|
# assoc = super().update_subsampassoc(assoc=assoc, input_dict=input_dict)
|
||||||
# else:
|
# # targets = {k: input_dict[k] for k in sorted(input_dict.keys()) if k.startswith("ct_")}
|
||||||
# logger.debug(f"Have a value already, {current_value}... skipping.")
|
# # assert 0 < len(targets) <= 2
|
||||||
if assoc.column == 3:
|
# # for k, v in targets.items():
|
||||||
logger.debug(f"Final association for association {assoc}:\n{pformat(assoc.__dict__)}")
|
# # # logger.debug(f"Setting sample {sample} with key {k} to value {v}")
|
||||||
return assoc
|
# # # update_key = f"ct_n{i}"
|
||||||
|
# # current_value = getattr(assoc, k)
|
||||||
|
# # logger.debug(f"Current value came back as: {current_value}")
|
||||||
|
# # if current_value is None:
|
||||||
|
# # setattr(assoc, k, v)
|
||||||
|
# # else:
|
||||||
|
# # logger.debug(f"Have a value already, {current_value}... skipping.")
|
||||||
|
# if assoc.column == 3:
|
||||||
|
# logger.debug(f"Final association for association {assoc}:\n{pformat(assoc.__dict__)}")
|
||||||
|
# return assoc
|
||||||
|
|
||||||
|
|
||||||
class WastewaterArtic(BasicSubmission):
|
class WastewaterArtic(BasicSubmission):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
Contains functions for generating summary reports
|
Contains functions for generating summary reports
|
||||||
"""
|
"""
|
||||||
import itertools
|
import itertools
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from pandas import DataFrame, ExcelWriter
|
from pandas import DataFrame, ExcelWriter
|
||||||
@@ -211,8 +212,13 @@ class ConcentrationMaker(ReportArchetype):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def build_record(cls, control) -> dict:
|
def build_record(cls, control) -> dict:
|
||||||
|
regex = re.compile(r"^(ATCC)|(MCS)", flags=re.IGNORECASE)
|
||||||
positive = not control.submitter_id.lower().startswith("en")
|
if bool(regex.match(control.submitter_id)):
|
||||||
|
positive = "positive"
|
||||||
|
elif control.submitter_id.lower().startswith("en"):
|
||||||
|
positive = "negative"
|
||||||
|
else:
|
||||||
|
positive = "sample"
|
||||||
try:
|
try:
|
||||||
concentration = float(control.concentration)
|
concentration = float(control.concentration)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class ConcentrationsChart(CustomFigure):
|
|||||||
# logger.debug(f"DF after changes:\n{self.df}")
|
# logger.debug(f"DF after changes:\n{self.df}")
|
||||||
scatter = px.scatter(data_frame=self.df, x='submission', y="concentration",
|
scatter = px.scatter(data_frame=self.df, x='submission', y="concentration",
|
||||||
hover_data=["name", "submission", "submitted_date", "concentration"],
|
hover_data=["name", "submission", "submitted_date", "concentration"],
|
||||||
color="positive", color_discrete_map={True: "red", False: "green"}
|
color="positive", color_discrete_map={"positive": "red", "negative": "green", "sample":"orange"}
|
||||||
)
|
)
|
||||||
except (ValueError, AttributeError) as e:
|
except (ValueError, AttributeError) as e:
|
||||||
logger.error(f"Error constructing chart: {e}")
|
logger.error(f"Error constructing chart: {e}")
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ class App(QMainWindow):
|
|||||||
helpMenu.addAction(self.docsAction)
|
helpMenu.addAction(self.docsAction)
|
||||||
helpMenu.addAction(self.githubAction)
|
helpMenu.addAction(self.githubAction)
|
||||||
fileMenu.addAction(self.importAction)
|
fileMenu.addAction(self.importAction)
|
||||||
fileMenu.addAction(self.yamlExportAction)
|
# fileMenu.addAction(self.yamlExportAction)
|
||||||
fileMenu.addAction(self.yamlImportAction)
|
# fileMenu.addAction(self.yamlImportAction)
|
||||||
methodsMenu.addAction(self.searchSample)
|
methodsMenu.addAction(self.searchSample)
|
||||||
maintenanceMenu.addAction(self.joinExtractionAction)
|
maintenanceMenu.addAction(self.joinExtractionAction)
|
||||||
maintenanceMenu.addAction(self.joinPCRAction)
|
maintenanceMenu.addAction(self.joinPCRAction)
|
||||||
@@ -112,8 +112,8 @@ class App(QMainWindow):
|
|||||||
self.docsAction = QAction("&Docs", self)
|
self.docsAction = QAction("&Docs", self)
|
||||||
self.searchSample = QAction("Search Sample", self)
|
self.searchSample = QAction("Search Sample", self)
|
||||||
self.githubAction = QAction("Github", self)
|
self.githubAction = QAction("Github", self)
|
||||||
self.yamlExportAction = QAction("Export Type Example", self)
|
# self.yamlExportAction = QAction("Export Type Example", self)
|
||||||
self.yamlImportAction = QAction("Import Type Template", self)
|
# self.yamlImportAction = QAction("Import Type Template", self)
|
||||||
self.editReagentAction = QAction("Edit Reagent", self)
|
self.editReagentAction = QAction("Edit Reagent", self)
|
||||||
self.manageOrgsAction = QAction("Manage Clients", self)
|
self.manageOrgsAction = QAction("Manage Clients", self)
|
||||||
self.manageKitsAction = QAction("Manage Kits", self)
|
self.manageKitsAction = QAction("Manage Kits", self)
|
||||||
@@ -130,8 +130,8 @@ class App(QMainWindow):
|
|||||||
self.docsAction.triggered.connect(self.openDocs)
|
self.docsAction.triggered.connect(self.openDocs)
|
||||||
self.searchSample.triggered.connect(self.runSampleSearch)
|
self.searchSample.triggered.connect(self.runSampleSearch)
|
||||||
self.githubAction.triggered.connect(self.openGithub)
|
self.githubAction.triggered.connect(self.openGithub)
|
||||||
self.yamlExportAction.triggered.connect(self.export_ST_yaml)
|
# self.yamlExportAction.triggered.connect(self.export_ST_yaml)
|
||||||
self.yamlImportAction.triggered.connect(self.import_ST_yaml)
|
# self.yamlImportAction.triggered.connect(self.import_ST_yaml)
|
||||||
self.table_widget.pager.current_page.textChanged.connect(self.update_data)
|
self.table_widget.pager.current_page.textChanged.connect(self.update_data)
|
||||||
self.editReagentAction.triggered.connect(self.edit_reagent)
|
self.editReagentAction.triggered.connect(self.edit_reagent)
|
||||||
self.manageOrgsAction.triggered.connect(self.manage_orgs)
|
self.manageOrgsAction.triggered.connect(self.manage_orgs)
|
||||||
@@ -186,46 +186,46 @@ class App(QMainWindow):
|
|||||||
dlg = SearchBox(parent=self, object_type=Reagent, extras=[dict(name='Role', field="role")])
|
dlg = SearchBox(parent=self, object_type=Reagent, extras=[dict(name='Role', field="role")])
|
||||||
dlg.exec()
|
dlg.exec()
|
||||||
|
|
||||||
def export_ST_yaml(self):
|
# def export_ST_yaml(self):
|
||||||
"""
|
# """
|
||||||
Copies submission type yaml to file system for editing and remport
|
# Copies submission type yaml to file system for editing and remport
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
# """
|
||||||
|
# if check_if_app():
|
||||||
|
# yaml_path = Path(sys._MEIPASS).joinpath("files", "resources", "viral_culture.yml")
|
||||||
|
# else:
|
||||||
|
# yaml_path = project_path.joinpath("src", "submissions", "resources", "viral_culture.yml")
|
||||||
|
# fname = select_save_file(obj=self, default_name="Submission Type Template.yml", extension="yml")
|
||||||
|
# shutil.copyfile(yaml_path, fname)
|
||||||
|
|
||||||
Returns:
|
# @check_authorization
|
||||||
None
|
# def import_ST_yaml(self, *args, **kwargs):
|
||||||
"""
|
# """
|
||||||
if check_if_app():
|
# Imports a yml form into a submission type.
|
||||||
yaml_path = Path(sys._MEIPASS).joinpath("files", "resources", "viral_culture.yml")
|
#
|
||||||
else:
|
# Args:
|
||||||
yaml_path = project_path.joinpath("src", "submissions", "resources", "viral_culture.yml")
|
# *args ():
|
||||||
fname = select_save_file(obj=self, default_name="Submission Type Template.yml", extension="yml")
|
# **kwargs ():
|
||||||
shutil.copyfile(yaml_path, fname)
|
#
|
||||||
|
# Returns:
|
||||||
@check_authorization
|
#
|
||||||
def import_ST_yaml(self, *args, **kwargs):
|
# """
|
||||||
"""
|
# fname = select_open_file(obj=self, file_extension="yml")
|
||||||
Imports a yml form into a submission type.
|
# if not fname:
|
||||||
|
# logger.info(f"Import cancelled.")
|
||||||
Args:
|
# return
|
||||||
*args ():
|
# ap = AlertPop(message="This function will proceed in the debug window.", status="Warning", owner=self)
|
||||||
**kwargs ():
|
# ap.exec()
|
||||||
|
# st = SubmissionType.import_from_json(filepath=fname)
|
||||||
Returns:
|
# if st:
|
||||||
|
# # NOTE: Do not delete the print statement below.
|
||||||
"""
|
# choice = input("Save the above submission type? [y/N]: ")
|
||||||
fname = select_open_file(obj=self, file_extension="yml")
|
# if choice.lower() == "y":
|
||||||
if not fname:
|
# pass
|
||||||
logger.info(f"Import cancelled.")
|
# else:
|
||||||
return
|
# logger.warning("Save of submission type cancelled.")
|
||||||
ap = AlertPop(message="This function will proceed in the debug window.", status="Warning", owner=self)
|
|
||||||
ap.exec()
|
|
||||||
st = SubmissionType.import_from_json(filepath=fname)
|
|
||||||
if st:
|
|
||||||
# NOTE: Do not delete the print statement below.
|
|
||||||
choice = input("Save the above submission type? [y/N]: ")
|
|
||||||
if choice.lower() == "y":
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
logger.warning("Save of submission type cancelled.")
|
|
||||||
|
|
||||||
def update_data(self):
|
def update_data(self):
|
||||||
self.table_widget.sub_wid.setData(page=self.table_widget.pager.page_anchor, page_size=page_size)
|
self.table_widget.sub_wid.setData(page=self.table_widget.pager.page_anchor, page_size=page_size)
|
||||||
|
|||||||
Reference in New Issue
Block a user