Improved scraping of gel info for Artic.
This commit is contained in:
@@ -75,7 +75,7 @@ class RSLNamer(object):
|
||||
try:
|
||||
submission_type = m.lastgroup
|
||||
except AttributeError as e:
|
||||
logger.critical("No RSL plate number found or submission type found!")
|
||||
logger.critical(f"No RSL plate number found or submission type found!: {e}")
|
||||
case _:
|
||||
submission_type = None
|
||||
try:
|
||||
@@ -180,6 +180,14 @@ class RSLNamer(object):
|
||||
template = environment.from_string(template)
|
||||
return template.render(**kwargs)
|
||||
|
||||
def calculate_repeat(self):
|
||||
regex = re.compile(r"-\d(?P<repeat>R\d)")
|
||||
m = regex.search(self.parsed_name)
|
||||
if m is not None:
|
||||
return m.group("repeat")
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
from .pydant import PydSubmission, PydKit, PydContact, PydOrganization, PydSample, PydReagent, PydReagentRole, \
|
||||
PydEquipment, PydEquipmentRole, PydTips
|
||||
|
||||
@@ -296,7 +296,9 @@ class PydTips(BaseModel):
|
||||
SubmissionTipsAssociation: Association between queried tips and submission
|
||||
"""
|
||||
tips = Tips.query(name=self.name, lot=self.lot, limit=1)
|
||||
assoc = SubmissionTipsAssociation(submission=submission, tips=tips, role_name=self.role)
|
||||
assoc = SubmissionTipsAssociation.query(tip_id=tips.id, submission_id=submission.id, role=self.role, limit=1)
|
||||
if assoc is None:
|
||||
assoc = SubmissionTipsAssociation(submission=submission, tips=tips, role_name=self.role)
|
||||
return assoc
|
||||
|
||||
|
||||
@@ -640,6 +642,7 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
# this could also be done with default_factory
|
||||
self.submission_object = BasicSubmission.find_polymorphic_subclass(
|
||||
polymorphic_identity=self.submission_type['value'])
|
||||
self.namer = RSLNamer(self.rsl_plate_num['value'])
|
||||
|
||||
def set_attribute(self, key: str, value):
|
||||
"""
|
||||
@@ -853,7 +856,7 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
"""
|
||||
template = self.submission_object.filename_template()
|
||||
# logger.debug(f"Using template string: {template}")
|
||||
render = RSLNamer.construct_export_name(template=template, **self.improved_dict(dictionaries=False)).replace(
|
||||
render = self.namer.construct_export_name(template=template, **self.improved_dict(dictionaries=False)).replace(
|
||||
"/", "")
|
||||
# logger.debug(f"Template rendered as: {render}")
|
||||
return render
|
||||
|
||||
Reference in New Issue
Block a user