Moved import PCR results to context menu.
This commit is contained in:
@@ -112,81 +112,6 @@ class SubmissionFormContainer(QWidget):
|
||||
logger.debug(f"Outgoing report: {self.report.results}")
|
||||
logger.debug(f"All attributes of submission container:\n{pformat(self.__dict__)}")
|
||||
|
||||
def import_pcr_results(self):
|
||||
"""
|
||||
Pull QuantStudio results into db
|
||||
"""
|
||||
self.import_pcr_results_function()
|
||||
self.app.report.add_result(self.report)
|
||||
self.report = Report()
|
||||
self.app.result_reporter()
|
||||
|
||||
def import_pcr_results_function(self):
|
||||
"""
|
||||
Import Quant-studio PCR data to an imported submission
|
||||
|
||||
Args:
|
||||
obj (QMainWindow): original app window
|
||||
|
||||
Returns:
|
||||
Tuple[QMainWindow, dict]: Collection of new main app window and result dict
|
||||
"""
|
||||
report = Report()
|
||||
fname = select_open_file(self, file_extension="xlsx")
|
||||
parser = PCRParser(filepath=fname)
|
||||
logger.debug(f"Attempting lookup for {parser.plate_num}")
|
||||
sub = BasicSubmission.query(rsl_number=parser.plate_num)
|
||||
try:
|
||||
logger.debug(f"Found submission: {sub.rsl_plate_num}")
|
||||
except AttributeError:
|
||||
# If no plate is found, may be because this is a repeat. Lop off the '-1' or '-2' and repeat
|
||||
logger.error(f"Submission of number {parser.plate_num} not found. Attempting rescue of plate repeat.")
|
||||
parser.plate_num = "-".join(parser.plate_num.split("-")[:-1])
|
||||
sub = BasicSubmission.query(rsl_number=parser.plate_num)
|
||||
try:
|
||||
logger.debug(f"Found submission: {sub.rsl_plate_num}")
|
||||
except AttributeError:
|
||||
logger.error(f"Rescue of {parser.plate_num} failed.")
|
||||
self.report.add_result(Result(msg="Couldn't find a submission with that RSL number.", status="Warning"))
|
||||
return
|
||||
# Check if PCR info already exists
|
||||
if hasattr(sub, 'pcr_info') and sub.pcr_info != None:
|
||||
# existing = json.loads(sub.pcr_info)
|
||||
existing = sub.pcr_info
|
||||
else:
|
||||
existing = None
|
||||
if existing != None:
|
||||
# update pcr_info
|
||||
try:
|
||||
logger.debug(f"Updating {type(existing)}: {existing} with {type(parser.pcr)}: {parser.pcr}")
|
||||
# if json.dumps(parser.pcr) not in sub.pcr_info:
|
||||
if parser.pcr not in sub.pcr_info:
|
||||
existing.append(parser.pcr)
|
||||
logger.debug(f"Setting: {existing}")
|
||||
# sub.pcr_info = json.dumps(existing)
|
||||
sub.pcr_info = existing
|
||||
except TypeError:
|
||||
logger.error(f"Error updating!")
|
||||
# sub.pcr_info = json.dumps([parser.pcr])
|
||||
sub.pcr_info = [parser.pcr]
|
||||
logger.debug(f"Final pcr info for {sub.rsl_plate_num}: {sub.pcr_info}")
|
||||
else:
|
||||
# sub.pcr_info = json.dumps([parser.pcr])
|
||||
sub.pcr_info = [parser.pcr]
|
||||
logger.debug(f"Existing {type(sub.pcr_info)}: {sub.pcr_info}")
|
||||
logger.debug(f"Inserting {type(json.dumps(parser.pcr))}: {json.dumps(parser.pcr)}")
|
||||
sub.save(original=False)
|
||||
logger.debug(f"Got {len(parser.samples)} samples to update!")
|
||||
logger.debug(f"Parser samples: {parser.samples}")
|
||||
for sample in sub.samples:
|
||||
logger.debug(f"Running update on: {sample}")
|
||||
try:
|
||||
sample_dict = [item for item in parser.samples if item['sample']==sample.rsl_number][0]
|
||||
except IndexError:
|
||||
continue
|
||||
sub.update_subsampassoc(sample=sample, input_dict=sample_dict)
|
||||
self.report.add_result(Result(msg=f"We added PCR info to {sub.rsl_plate_num}.", status='Information'))
|
||||
|
||||
def add_reagent(self, reagent_lot:str|None=None, reagent_type:str|None=None, expiry:date|None=None, name:str|None=None):
|
||||
"""
|
||||
Action to create new reagent in DB.
|
||||
|
||||
Reference in New Issue
Block a user