Commit pre-refactor for code cleanup.

This commit is contained in:
Landon Wark
2023-02-10 10:22:39 -06:00
parent c3db706e7c
commit a9ce9514fc
11 changed files with 400 additions and 272 deletions

View File

@@ -0,0 +1,31 @@
# from ..models import *
from backend.db.models import *
import logging
import numpy as np
logger = logging.getLogger(f"submissions.{__name__}")
def check_kit_integrity(sub:BasicSubmission):
ext_kit_rtypes = [reagenttype.name for reagenttype in sub.extraction_kit.reagent_types]
logger.debug(f"Kit reagents: {ext_kit_rtypes}")
reagenttypes = [reagent.type.name for reagent in sub.reagents]
logger.debug(f"Submission reagents: {reagenttypes}")
check = set(ext_kit_rtypes) == set(reagenttypes)
logger.debug(f"Checking if reagents match kit contents: {check}")
common = list(set(ext_kit_rtypes).intersection(reagenttypes))
logger.debug(f"common reagents types: {common}")
if check:
result = None
else:
result = {'message' : f"Couldn't verify reagents match listed kit components.\n\nIt looks like you are missing: {[x.upper() for x in ext_kit_rtypes if x not in common]}\n\nAlternatively, you may have set the wrong extraction kit."}
return result
def check_not_nan(cell_contents) -> bool:
try:
return not np.isnan(cell_contents)
except ValueError:
return True
except Exception as e:
logger.debug(f"Check encounteded unknown error: {e}")
return False