hitpicking complete, pre-addition of WW-Arctic parsers and models.
This commit is contained in:
@@ -92,14 +92,12 @@ def check_kit_integrity(sub:BasicSubmission|KitType, reagenttypes:list|None=None
|
||||
check = set(ext_kit_rtypes) == set(reagenttypes)
|
||||
logger.debug(f"Checking if reagents match kit contents: {check}")
|
||||
# what reagent types are in both lists?
|
||||
# common = list(set(ext_kit_rtypes).intersection(reagenttypes))
|
||||
missing = list(set(ext_kit_rtypes).difference(reagenttypes))
|
||||
logger.debug(f"Missing reagents types: {missing}")
|
||||
# if lists are equal return no problem
|
||||
if len(missing)==0:
|
||||
result = None
|
||||
else:
|
||||
# missing = [x for x in ext_kit_rtypes if x not in common]
|
||||
result = {'message' : f"The submission you are importing is missing some reagents expected by the kit.\n\nIt looks like you are missing: {[item.upper() for item in missing]}\n\nAlternatively, you may have set the wrong extraction kit.\n\nThe program will populate lists using existing reagents.\n\nPlease make sure you check the lots carefully!", 'missing': missing}
|
||||
return result
|
||||
|
||||
@@ -168,7 +166,6 @@ class RSLNamer(object):
|
||||
Object that will enforce proper formatting on RSL plate names.
|
||||
"""
|
||||
def __init__(self, instr:str):
|
||||
# self.parsed_name, self.submission_type = self.retrieve_rsl_number(instr)
|
||||
self.retrieve_rsl_number(in_str=instr)
|
||||
if self.submission_type != None:
|
||||
parser = getattr(self, f"enforce_{self.submission_type}")
|
||||
@@ -195,12 +192,13 @@ class RSLNamer(object):
|
||||
return
|
||||
logger.debug(f"Attempting match of {in_str}")
|
||||
regex = re.compile(r"""
|
||||
(?P<wastewater>RSL(?:-|_)?WW(?:-|_)?20\d{2}-?\d{2}-?\d{2}(?:(?:_|-)R?\d(?!\d))?)|
|
||||
(?P<wastewater>RSL(?:-|_)?WW(?:-|_)?20\d{2}-?\d{2}-?\d{2}(?:(?:_|-)\d?(?!\d)R?\d(?!\d))?)|
|
||||
(?P<bacterial_culture>RSL-?\d{2}-?\d{4})
|
||||
""", flags = re.IGNORECASE | re.VERBOSE)
|
||||
m = regex.search(in_str)
|
||||
try:
|
||||
self.parsed_name = m.group().upper()
|
||||
logger.debug(f"Got parsed submission name: {self.parsed_name}")
|
||||
self.submission_type = m.lastgroup
|
||||
except AttributeError as e:
|
||||
logger.critical("No RSL plate number found or submission type found!")
|
||||
@@ -210,11 +208,8 @@ class RSLNamer(object):
|
||||
"""
|
||||
Uses regex to enforce proper formatting of wastewater samples
|
||||
"""
|
||||
# self.parsed_name = re.sub(r"(\d)-(\d)", "\1\2", self.parsed_name)
|
||||
# year = str(date.today().year)[:2]
|
||||
self.parsed_name = re.sub(r"PCR(-|_)", "", self.parsed_name)
|
||||
self.parsed_name = self.parsed_name.replace("RSLWW", "RSL-WW")
|
||||
# .replace(f"WW{year}", f"WW-{year}")
|
||||
self.parsed_name = re.sub(r"WW(\d{4})", r"WW-\1", self.parsed_name, flags=re.IGNORECASE)
|
||||
self.parsed_name = re.sub(r"(\d{4})-(\d{2})-(\d{2})", r"\1\2\3", self.parsed_name)
|
||||
|
||||
@@ -222,14 +217,6 @@ class RSLNamer(object):
|
||||
"""
|
||||
Uses regex to enforce proper formatting of bacterial culture samples
|
||||
"""
|
||||
# year = str(date.today().year)[2:]
|
||||
# self.parsed_name = self.parsed_name.replace(f"RSL{year}", f"RSL-{year}")
|
||||
# reg_year = re.compile(fr"{year}(?P<rsl>\d\d\d\d)")
|
||||
self.parsed_name = re.sub(r"RSL(\d{2})", r"RSL-\1", self.parsed_name, flags=re.IGNORECASE)
|
||||
self.parsed_name = re.sub(r"RSL-(\d{2})(\d{4})", r"RSL-\1-\2", self.parsed_name, flags=re.IGNORECASE)
|
||||
# year = regex.group('year')
|
||||
# rsl = regex.group('rsl')
|
||||
# self.parsed_name = re.sub(fr"{year}(\d\d\d\d)", fr"{year}-\1", self.parsed_name)
|
||||
# plate_search = reg_year.search(self.parsed_name)
|
||||
# if plate_search != None:
|
||||
# self.parsed_name = re.sub(reg_year, f"{year}-{plate_search.group('rsl')}", self.parsed_name)
|
||||
|
||||
Reference in New Issue
Block a user