From 6d06f985171818bae0407f75f7b9a6ce2a0a75a4 Mon Sep 17 00:00:00 2001 From: MarvinDo Date: Mon, 20 Nov 2023 13:14:27 +0100 Subject: [PATCH] fixed a bug where heredicare annotation yielded an error --- .../annotation_jobs/heredicare_job.py | 39 ++++++++++--------- src/annotation_service/main.py | 1 + 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/annotation_service/annotation_jobs/heredicare_job.py b/src/annotation_service/annotation_jobs/heredicare_job.py index 0b5172d6..d1644907 100644 --- a/src/annotation_service/annotation_jobs/heredicare_job.py +++ b/src/annotation_service/annotation_jobs/heredicare_job.py @@ -54,23 +54,26 @@ def save_to_db(self, info, variant_id, conn): if tries > 0: time.sleep(30 * tries) if status == "error": - raise Exception("There was an error during variant retrieval from heredicare: " + str(message)) - - n_fam = heredicare_variant["N_FAM"] - n_pat = heredicare_variant["N_PAT"] - consensus_class = heredicare_variant["PATH_TF"] if heredicare_variant["PATH_TF"] != "-1" else None - comment = heredicare_variant["VUSTF_15"] if heredicare_variant["VUSTF_15"] is not None else '' - comment = comment.strip() - comment = comment if comment != '' else None - classification_date = heredicare_variant["VUSTF_DATUM"] if heredicare_variant["VUSTF_DATUM"] != '' else None - if classification_date is not None: - try: - classification_date = datetime.strptime(classification_date, "%d.%m.%Y") - except: - raise Exception("The date could not be saved in the database. Format should be dd.mm.yyyy, but was: " + str(classification_date)) - - conn.insert_heredicare_annotation(variant_id, vid, n_fam, n_pat, consensus_class, classification_date, comment) - - return status_code, err_msg + err_msg += "There was an error during variant retrieval from heredicare: " + str(message) + status_code = 1 + else: + n_fam = heredicare_variant["N_FAM"] + n_pat = heredicare_variant["N_PAT"] + consensus_class = heredicare_variant["PATH_TF"] if heredicare_variant["PATH_TF"] != "-1" else None + comment = heredicare_variant["VUSTF_15"] if heredicare_variant["VUSTF_15"] is not None else '' + comment = comment.strip() + comment = comment if comment != '' else None + classification_date = heredicare_variant["VUSTF_DATUM"] if heredicare_variant["VUSTF_DATUM"] != '' else None + if classification_date is not None: + try: + classification_date = datetime.strptime(classification_date, "%d.%m.%Y") + except: + err_msg += "The date could not be saved in the database. Format should be dd.mm.yyyy, but was: " + str(classification_date) + status_code = 1 + + if status_code == 0: + conn.insert_heredicare_annotation(variant_id, vid, n_fam, n_pat, consensus_class, classification_date, comment) + + return status_code, err_msg diff --git a/src/annotation_service/main.py b/src/annotation_service/main.py index 20d8bf92..2383fd19 100644 --- a/src/annotation_service/main.py +++ b/src/annotation_service/main.py @@ -168,6 +168,7 @@ def process_one_request(annotation_queue_id, job_config = get_default_job_config info = line.split('\t')[7] for job in all_jobs: + print(job.job_name) status_code, err_msg = job.save_to_db(info, variant_id, conn=conn) if status_code > 0: status = "error"