diff --git a/src/common/db_IO.py b/src/common/db_IO.py index a93c6f5b..144e7a6e 100644 --- a/src/common/db_IO.py +++ b/src/common/db_IO.py @@ -729,14 +729,14 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use if page_size != 'unlimited': command = command + " LIMIT %s, %s" actual_information += (offset, page_size) - print(command % actual_information) + #print(command % actual_information) self.cursor.execute(command, actual_information) variants_raw = self.cursor.fetchall() # get variant objects variants = [] for variant_raw in variants_raw: - variant = self.get_variant(variant_id=variant_raw[0], include_annotations = False, include_heredicare_classifications = False, include_clinvar = False, include_assays = False, include_literature = False) + variant = self.get_variant(variant_id=variant_raw[0], include_annotations = False, include_heredicare_classifications = True, include_clinvar = False, include_assays = False, include_literature = False) variants.append(variant) if page_size == 'unlimited': @@ -1708,7 +1708,6 @@ def get_variant(self, variant_id, is_hidden = True if variant_raw[5] == 1 else False annotations = None - all_heredicare_annotations = None if include_annotations: annotations = models.AllAnnotations() annotations_raw = self.get_recent_annotations(variant_id) @@ -1729,23 +1728,6 @@ def get_variant(self, variant_id, annotations.flag_linked_annotations() - heredicare_annotations_raw = self.get_heredicare_annotations(variant_id) - - all_heredicare_annotations = [] - for annot in heredicare_annotations_raw: - #id, vid, n_fam, n_pat, consensus_class, comment, date - heredicare_annotation_id = annot[0] - vid = annot[1] - n_fam = annot[2] - n_pat = annot[3] - consensus_class = annot[4] - comment = annot[5] - classification_date = annot[6] - - classification = models.HeredicareClassification(id = heredicare_annotation_id, selected_class = consensus_class, comment = comment, classification_date = classification_date, center = "VUSTF", vid = vid) - new_heredicare_annotation = models.HeredicareAnnotation(id = heredicare_annotation_id, vid = vid, n_fam = n_fam, n_pat = n_pat, vustf_classification = classification) - all_heredicare_annotations.append(new_heredicare_annotation) - # add all consensus classifications consensus_classifications = None @@ -1857,6 +1839,7 @@ def get_variant(self, variant_id, user_classifications.append(new_user_classification) heredicare_classifications = None + all_heredicare_annotations = None if include_heredicare_classifications: heredicare_classifications_raw = self.get_heredicare_center_classifications(variant_id) if heredicare_classifications_raw is not None: @@ -1869,6 +1852,23 @@ def get_variant(self, variant_id, date = cl_raw[5].strftime('%Y-%m-%d') new_heredicare_classification = models.HeredicareClassification(id = id, selected_class = selected_class, comment = comment, center = center, classification_date = date, vid="") heredicare_classifications.append(new_heredicare_classification) + + + heredicare_annotations_raw = self.get_heredicare_annotations(variant_id) + all_heredicare_annotations = [] + for annot in heredicare_annotations_raw: + #id, vid, n_fam, n_pat, consensus_class, comment, date + heredicare_annotation_id = annot[0] + vid = annot[1] + n_fam = annot[2] + n_pat = annot[3] + consensus_class = annot[4] + comment = annot[5] + classification_date = annot[6] + + classification = models.HeredicareClassification(id = heredicare_annotation_id, selected_class = consensus_class, comment = comment, classification_date = classification_date, center = "VUSTF", vid = vid) + new_heredicare_annotation = models.HeredicareAnnotation(id = heredicare_annotation_id, vid = vid, n_fam = n_fam, n_pat = n_pat, vustf_classification = classification) + all_heredicare_annotations.append(new_heredicare_annotation) # add clinvar annotation clinvar = None @@ -2270,7 +2270,7 @@ def clear_heredicare_annotation(self, variant_id): self.conn.commit() def get_enumtypes(self, tablename, columnname): - allowed_tablenames = ["consensus_classification", "user_classification"] + allowed_tablenames = ["consensus_classification", "user_classification", "variant"] if tablename in allowed_tablenames: command = "SHOW COLUMNS FROM " + tablename + " WHERE FIELD = %s" else: @@ -2281,4 +2281,93 @@ def get_enumtypes(self, tablename, columnname): column_type = column_type.strip('enum()') allowed_enum = column_type.split(',') allowed_enum = [x.strip('\'') for x in allowed_enum] - return allowed_enum \ No newline at end of file + return allowed_enum + + + + def get_gencode_basic_transcripts(self, gene_id): + if gene_id is None: + return None + command = "SELECT name FROM transcript WHERE gene_id = %s AND (is_gencode_basic=1 or is_mane_select=1 or is_mane_plus_clinical=1)" + self.cursor.execute(command, (gene_id, )) + result = self.cursor.fetchall() + return [x[0] for x in result if x[0].startswith("ENST")] + + + + # this function returns a list of consequence objects of the preferred transcripts + # (can be multiple if there are eg. 2 mane select transcripts for this variant) + def get_preferred_transcripts(self, gene_id, return_all=False): + result = [] + command = "SELECT name, biotype, length, is_gencode_basic, is_mane_select, is_mane_plus_clinical, is_ensembl_canonical FROM transcript WHERE gene_id = %s" + self.cursor.execute(command, (gene_id, )) + result_raw = self.cursor.fetchall() + transcripts = [] + for elem in result_raw: + if elem[0].startswith("ENST"): + source = "ensembl" if elem[0].startswith("ENST") else "refseq" + new_elem = {"name": elem[0], + "biotype": elem[1], + "length": elem[2], + "is_gencode_basic": elem[3], + "is_mane_select": elem[4], + "is_mane_plus_clinical": elem[5], + "is_ensembl_canonical": elem[6], + "source": source + } + transcripts.append(new_elem) + + if len(transcripts) > 0: + transcripts = self.order_transcripts(transcripts) + + if not return_all: + result.append(transcripts.pop(0)) # always append the first one + + for transcript in transcripts: # scan for all mane select transcripts + if transcript["is_mane_select"]: + result.append(transcript) + else: + break # we can do this because the list is sorted + else: + result = transcripts + else: # the variant does not have any consequences + return None + return result + + def order_transcripts(self, consequences): + keyfunc = cmp_to_key(mycmp = self.sort_transcripts) + consequences.sort(key = keyfunc) # sort by preferred transcript + return consequences + + def sort_transcripts(self, a, b): + # sort by ensembl/refseq + if a["source"] == 'ensembl' and b["source"] == 'refseq': + return -1 + elif a["source"] == 'refseq' and b["source"] == 'ensembl': + return 1 + elif a["source"] == b["source"]: + + # sort by mane select + if a["is_mane_select"] is None or b["is_mane_select"] is None: + return 1 + elif a["is_mane_select"] and not b["is_mane_select"]: + return -1 + elif not a["is_mane_select"] and b["is_mane_select"]: + return 1 + elif a["is_mane_select"] == b["is_mane_select"]: + + # sort by biotype + if a["biotype"] == 'protein coding' and b["biotype"] != 'protein coding': + return -1 + elif a["biotype"] != 'protein coding' and b["biotype"] == 'protein coding': + return 1 + elif (a["biotype"] != 'protein coding' and b["biotype"] != 'protein coding') or (a["biotype"] == 'protein coding' and b["biotype"] == 'protein coding'): + + # sort by length + if a["length"] > b["length"]: + return -1 + elif a["length"] < b["length"]: + return 1 + else: + return 0 + \ No newline at end of file diff --git a/src/common/functions.py b/src/common/functions.py index 9b915f3e..078ac0e4 100644 --- a/src/common/functions.py +++ b/src/common/functions.py @@ -276,15 +276,55 @@ def left_align_vcf(infile, outfile, ref_genome = 'GRCh38'): return returncode, err_msg, command_output - -def hgvsc_to_vcf(hgvs, reference = None): +## DEPRECATED +#def hgvsc_to_vcf(hgvs, reference = None): +# #tmp_file_path = tempfile.gettempdir() + "/hgvs_to_vcf" +# tmp_file_path = get_random_temp_file("_hgvs2vcf") +# tmp_file = open(tmp_file_path + ".tsv", "w") +# tmp_file.write("#reference hgvs_c\n") +# if reference is None: +# reference, hgvs = split_hgvs(hgvs) +# tmp_file.write(reference + "\t" + hgvs + "\n") +# tmp_file.close() +# +# command = [os.path.join(paths.ngs_bits_path, "HgvsToVcf")] +# command.extend(['-in', tmp_file_path + '.tsv', '-ref', paths.ref_genome_path, '-out', tmp_file_path + '.vcf']) +# returncode, err_msg, command_output = execute_command(command, "HgvsToVcf", use_prefix_error_log=False) +# +# chr = None +# pos = None +# ref = None +# alt = None +# tmp_file = open(tmp_file_path + '.vcf', "r") +# for line in tmp_file: # this assumes a single-entry vcf +# if line.strip() == '' or line.startswith('#'): +# continue +# parts = line.split('\t') +# chr = parts[0] +# pos = parts[1] +# ref = parts[3] +# alt = parts[4] +# +# +# rm(tmp_file_path + ".tsv") +# rm(tmp_file_path + ".vcf") +# return chr, pos, ref, alt, err_msg + + +def hgvsc_to_vcf(hgvs_strings, references = None): #tmp_file_path = tempfile.gettempdir() + "/hgvs_to_vcf" tmp_file_path = get_random_temp_file("_hgvs2vcf") tmp_file = open(tmp_file_path + ".tsv", "w") tmp_file.write("#reference hgvs_c\n") - if reference is None: - reference, hgvs = split_hgvs(hgvs) - tmp_file.write(reference + "\t" + hgvs + "\n") + if references is None: + references = [] + for hgvs in hgvs_strings: + reference, hgvs = split_hgvs(hgvs) + references.append(reference) + tmp_file.write(reference + "\t" + hgvs + "\n") + else: + for hgvs, reference in zip(hgvs_strings, references): + tmp_file.write(reference + "\t" + hgvs + "\n") tmp_file.close() command = [os.path.join(paths.ngs_bits_path, "HgvsToVcf")] @@ -295,21 +335,31 @@ def hgvsc_to_vcf(hgvs, reference = None): pos = None ref = None alt = None + first_iter = True tmp_file = open(tmp_file_path + '.vcf', "r") for line in tmp_file: # this assumes a single-entry vcf if line.strip() == '' or line.startswith('#'): continue parts = line.split('\t') - chr = parts[0] - pos = parts[1] - ref = parts[3] - alt = parts[4] + + #print(parts) + + if first_iter: + chr = parts[0] + pos = parts[1] + ref = parts[3] + alt = parts[4] + first_iter = False + else: + if chr != parts[0] or pos != parts[1] or ref != parts[3] or alt != parts[4]: # check that all are equal + return None, None, None, None, "HGVSc recovered vcf-style variant among transcripts is unequal: " + str(references) rm(tmp_file_path + ".tsv") rm(tmp_file_path + ".vcf") return chr, pos, ref, alt, err_msg + # function for splitting hgvs in refrence transcript and variant def split_hgvs(hgvs): hgvs = hgvs.strip() diff --git a/src/common/models.py b/src/common/models.py index cd79cbc2..a340920c 100644 --- a/src/common/models.py +++ b/src/common/models.py @@ -627,15 +627,6 @@ def get_heredicare_consensus_classifications(self): if heredicare_annotation.vustf_classification.selected_class is not None: result.append(heredicare_annotation.vustf_classification) return result - - def get_heredicare_consensus_classification_severeity(self): - result = [] - for heredicare_annotation in self.heredicare_annotations: - current_classification = heredicare_annotation.vustf_classification - if current_classification.selected_class is not None: - class_num = current_classification.selected_class_to_num() - result.append(class_num) - return list(set(result)) def get_total_heredicare_counts(self): @@ -718,6 +709,38 @@ def get_user_classifications(self, user_id): def to_json(self): return json.dumps(asdict(self)) + + def get_most_recent_heredicare_consensus_classification(self): + result = None + if self.heredicare_annotations is None: + return None + for heredicare_annotation in self.heredicare_annotations: + current_classification = heredicare_annotation.vustf_classification + if current_classification.selected_class is not None: + if result is None: + result = current_classification + elif current_classification.classification_date > result.classification_date: + result = current_classification + return result + + # the most recent consensus class or if that does not exist the most recent heredicare consensus classification + def get_consensus_class(self): + the_class = "-" + source = "heredivar" + most_recent_consensus_classification = self.get_recent_consensus_classification() + if most_recent_consensus_classification is None: + heredicare_classification = self.get_most_recent_heredicare_consensus_classification() + if heredicare_classification is not None: + the_class = heredicare_classification.selected_class_to_num() + source = "heredicare" + else: + the_class = most_recent_consensus_classification.selected_class + source = "heredivar" + + return the_class, source + + + # the most recent conensus classification independent of schemes def get_recent_consensus_classification(self): result = None if self.consensus_classifications is not None: @@ -729,6 +752,7 @@ def get_recent_consensus_classification(self): result = classification return result + # the most recent consensus classification for each scheme def get_recent_consensus_classification_all_schemes(self, convert_to_dict = False): result = None if self.consensus_classifications is not None: diff --git a/src/frontend_celery/webapp/static/css/colors.css b/src/frontend_celery/webapp/static/css/colors.css index bcaa3565..1261948f 100644 --- a/src/frontend_celery/webapp/static/css/colors.css +++ b/src/frontend_celery/webapp/static/css/colors.css @@ -210,4 +210,13 @@ input.invalid { .classification-gradient { background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.499019676229867) 20%, rgba(255,255,255,0.633473457742472) 40%, rgba(255,255,255,1) 100%); background-color: currentColor; +} + + + + +.white_border { + stroke: #d4d4d4; + stroke-width: 0.5px; + stroke-linejoin: round; } \ No newline at end of file diff --git a/src/frontend_celery/webapp/static/css/styles.css b/src/frontend_celery/webapp/static/css/styles.css index 3915460f..11413aad 100644 --- a/src/frontend_celery/webapp/static/css/styles.css +++ b/src/frontend_celery/webapp/static/css/styles.css @@ -437,4 +437,8 @@ footer { .class_label .the_c { position: absolute; z-index:1; +} +.classM_text { + white-space: pre; + font-size: 7px; } \ No newline at end of file diff --git a/src/frontend_celery/webapp/tasks.py b/src/frontend_celery/webapp/tasks.py index c7e7ca52..53cdfd2c 100644 --- a/src/frontend_celery/webapp/tasks.py +++ b/src/frontend_celery/webapp/tasks.py @@ -309,7 +309,7 @@ def import_one_variant_heredicare(self, vid, user_id, user_roles, import_variant try: conn = Connection(user_roles) conn.update_import_variant_queue_status(import_variant_queue_id, status = "progress", message = "") - status, message = fetch_heredicare(vid, heredicare_interface, user_id, conn) + status, message = fetch_heredicare(vid, heredicare_interface, user_id, conn, insert_variant = True, perform_annotation = False) except InternalError as e: # deadlock: code 1213 status = "retry" @@ -351,20 +351,37 @@ def import_one_variant_heredicare(self, vid, user_id, user_roles, import_variant -def fetch_heredicare(vid, heredicare_interface, user_id, conn:Connection): # the task worker - +def fetch_heredicare(vid, heredicare_interface, user_id, conn:Connection, insert_variant = True, perform_annotation = True): variant, status, message = heredicare_interface.get_variant(vid) - + if status != 'success': return status, message - print(variant) if str(variant.get("VISIBLE", "0")) == "0": - message = "Skipped because variant is invisible in HerediCare" + variant_id = conn.get_variant_id_from_external_id(vid, "heredicare") + if variant_id is not None: + conn.delete_external_id(vid, "heredicare", variant_id) + variant_vids = conn.get_external_ids_from_variant_id(variant_id) + if len(variant_vids) == 0: + conn.hide_variant(variant_id, is_hidden = False) + message = "Variant is already in database, but is hidden in HerediCare. It is now also hidden in HerediVar. If another VID points to this variant which is processed later this variant might get visible again." + else: + message = "Deleted VID because this vid is now hidden in HerediCare" + else: + message = "Skipped because variant is invisible in HerediCare" return status, message + + status, message = map_hg38(variant, user_id, conn, insert_variant = insert_variant, perform_annotation = perform_annotation, external_ids = [vid]) + + return status, message + + +def map_hg38(variant, user_id, conn:Connection, insert_variant = True, perform_annotation = True, external_ids = None): # the task worker + message = "" + status = "success" + variant_id = None allowed_sequence_letters = "ACGT" - perform_annotation = False # first check if the hg38 information is there chrom = variant.get('CHROM') @@ -373,7 +390,10 @@ def fetch_heredicare(vid, heredicare_interface, user_id, conn:Connection): # the alt = variant.get('ALT_HG38') genome_build = "GRCh38" - was_successful, message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, perform_annotation=perform_annotation) + was_successful = False + if all([x is not None for x in [chrom, pos, ref, alt]]): + was_successful, new_message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, insert_variant = insert_variant, perform_annotation=perform_annotation) + message = functions.collect_info(message, "hg38_msg=", new_message, sep = " ~~ ") if not was_successful: # check hg19 information @@ -381,38 +401,83 @@ def fetch_heredicare(vid, heredicare_interface, user_id, conn:Connection): # the ref = variant.get('REF_HG19') alt = variant.get('ALT_HG19') genome_build = "GRCh37" - - was_successful, message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, perform_annotation=perform_annotation) + + was_successful = False + if all([x is not None for x in [chrom, pos, ref, alt]]): + was_successful, new_message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, insert_variant = insert_variant, perform_annotation=perform_annotation) + message = functions.collect_info(message, "hg37_msg=", new_message, sep = " ~~ ") if not was_successful: # if there is still missing data check if the variant has hgvs_c information transcript = variant.get('REFSEQ') hgvs_c = variant.get('CHGVS') + gene_symbol = variant.get("GEN") genome_build = "GRCh38" - #TODO: maybe check if you can get some transcripts from the gene??? gene = variant.get('GEN') - if any([x is None for x in [transcript, hgvs_c]]) or transcript == 'unknown': - status = "error" - message = "Not enough data to convert variant!" - return status, message - - chrom, pos, ref, alt, err_msg = functions.hgvsc_to_vcf(hgvs_c, transcript) # convert to vcf + transcript_valid = transcript is not None and transcript != "" and transcript != "unknown" and transcript != "unbekannt" + hgvs_c_valid = hgvs_c is not None and hgvs_c != "" + gene_valid = gene_symbol is not None and gene_symbol != "" - if err_msg != "": # catch runtime errors of hgvs to vcf - status = "error" - message = "HGVS to VCF yieled an error: " + str(err_msg) - return status, message - - # the conversion was not successful - if any([x is None for x in [chrom, pos, ref, alt]]): - status = "error" - message = "HGVS could not be converted to VCF: " + str(transcript) + ":" + str(hgvs_c) - return status, message + #TODO: maybe check if you can get some transcripts from the gene??? gene = variant.get('GEN') + if transcript_valid and hgvs_c_valid: + chrom, pos, ref, alt, err_msg = functions.hgvsc_to_vcf([hgvs_c], [transcript]) # convert to vcf + + if err_msg != "": # catch runtime errors of hgvs to vcf + new_message = "HGVS to VCF yieled an error: " + str(err_msg) + message = functions.collect_info(message, "hgvs_msg=", new_message, sep = " ~~ ") + elif any([x is None for x in [chrom, pos, ref, alt]]): # the conversion was not successful + new_message = "HGVS could not be converted to VCF: " + str(transcript) + ":" + str(hgvs_c) + message = functions.collect_info(message, "hgvs_msg=", new_message, sep = " ~~ ") + else: + was_successful = True - was_successful, message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, perform_annotation=perform_annotation) - - if variant_id is not None: # insert new vid - conn.insert_external_variant_id(variant_id, vid, "heredicare") + if not was_successful and hgvs_c_valid and gene_valid: + gene_id = conn.get_gene_id_by_symbol(gene_symbol) + transcripts = conn.get_gencode_basic_transcripts(gene_id) + + if transcripts is not None: + #print(transcripts) + #print(variant["CHGVS"]) + + chrom, pos, ref, alt, err_msg = functions.hgvsc_to_vcf([variant["CHGVS"]]*len(transcripts), transcripts) # convert to vcf + + #print(err_msg) + + if 'unequal' in err_msg: + message = functions.collect_info(message, "hgvs_msg=", err_msg, sep = " ~~ ") + elif err_msg != '': + preferred_transcripts = conn.get_preferred_transcripts(gene_id, return_all = True) + err_msgs = err_msg.split('\n') + break_outer = False + for current_transcript in preferred_transcripts: + for e in err_msgs: + if current_transcript["name"] in e: + new_message = "HGVS to VCf yielded an error with transcript: " + e + message = functions.collect_info(message, "hgvs_msg=", new_message, sep = " ~~ ") + break_outer = True + break + if break_outer: + break + elif any([x is None for x in [chrom, pos, ref, alt]]): # the conversion was not successful + new_message = "HGVS could not be converted to VCF: " + str(hgvs_c) + message = functions.collect_info(message, "hgvs_msg=", new_message, sep = " ~~ ") + else: + was_successful = True + + if not was_successful and all([x is not None for x in [chrom, pos, ref, alt]]): + message += " possible candidate variant: " + '-'.join([chrom, pos, ref, alt]) + " (from transcript(s): " + current_transcript['name'] + + if was_successful: + was_successful, new_message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, insert_variant = insert_variant, perform_annotation=perform_annotation) + message = functions.collect_info(message, "hgvs_msg=", new_message, sep = " ~~ ") + + if variant_id is not None and external_ids is not None: # insert new vid + for external_id in external_ids: + conn.insert_external_variant_id(variant_id, external_id, "heredicare") + + if not was_successful and message == '': + new_message = "Not enough data to convert variant!" + message = functions.collect_info(message, "", new_message, sep = " ~~ ") if (not was_successful and variant_id is not None) or "already in database!" in message: # variant is already in database, start a reannotation status = "update" @@ -428,7 +493,7 @@ def fetch_heredicare(vid, heredicare_interface, user_id, conn:Connection): # the -def validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn: Connection, user_id, allowed_sequence_letters = "ACGT", perform_annotation = True): +def validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn: Connection, user_id, allowed_sequence_letters = "ACGT", insert_variant = True, perform_annotation = True): message = "" was_successful = True variant_id = None @@ -442,13 +507,17 @@ def validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn: Connec if not chrom_is_valid: message = "Chromosome is invalid: " + str(chrom) elif not ref_is_valid: - message = "Reference sequence contains non-ACGT characters: " + str(ref) - if len(ref) > 1000: - message = "Reference base is too long" + message = "Invalid reference sequence! The sequence must contain only ACGT and must have 0 < length < 1000: " + if ref is not None: + if len(ref) > 1000: + ref = ref[0:100] + "..." + message = message + "\"" + str(ref) + "\"" elif not alt_is_valid: - message = "Alternative sequence contains non-ACGT characters: " + str(alt) - if len(alt) > 1000: - message = "Alternative base is too long" + message = "Invalid alternative sequence! The sequence must contain only ACGT and must have 0 < length < 1000: " + if alt is not None: + if len(alt) > 1000: + alt = alt[0:100] + "..." + message = message + "\"" + str(alt) + "\"" elif not pos_is_valid: message = "Position is invalid: " + str(pos) if not chrom_is_valid or not ref_is_valid or not alt_is_valid or not pos_is_valid: @@ -508,14 +577,19 @@ def validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn: Connec tmp_file.close() is_duplicate = conn.check_variant_duplicate(new_chr, new_pos, new_ref, new_alt) # check if variant is already contained - if not is_duplicate: # insert it & capture the annotation_queue_id of the newly inserted variant to start the annotation service in celery - variant_id = conn.insert_variant(new_chr, new_pos, new_ref, new_alt, chrom, pos, ref, alt, user_id) + if insert_variant: + variant_id = conn.insert_variant(new_chr, new_pos, new_ref, new_alt, chrom, pos, ref, alt, user_id) + else: + message += "HG38 variant would be: " + '-'.join([str(new_chr), str(new_pos), str(new_ref), str(new_alt)]) else: - variant_id = conn.get_variant_id(new_chr, new_pos, new_ref, new_alt) - message = "Variant not imported: already in database!!" - conn.hide_variant(variant_id, True) + if insert_variant: + variant_id = conn.get_variant_id(new_chr, new_pos, new_ref, new_alt) + message = "Variant not imported: already in database!!" + conn.hide_variant(variant_id, True) + else: + message += "HG38 variant would be: " + '-'.join([str(new_chr), str(new_pos), str(new_ref), str(new_alt)]) was_successful = True if perform_annotation: celery_task_id = start_annotation_service(conn, user_id, variant_id) # starts the celery background task diff --git a/src/frontend_celery/webapp/templates/base.html b/src/frontend_celery/webapp/templates/base.html index 9a481954..81135329 100644 --- a/src/frontend_celery/webapp/templates/base.html +++ b/src/frontend_celery/webapp/templates/base.html @@ -26,6 +26,16 @@ Admin dashboard {% endif %} +