Skip to content

Commit

Permalink
Added heredicare classes to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Oct 12, 2023
1 parent b3e7981 commit c4ff099
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 24 deletions.
19 changes: 15 additions & 4 deletions src/annotation_service/annotation_jobs/heredicare_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from annotation_service.heredicare_interface import heredicare_interface
import time
from datetime import datetime


## annotate variant with hexplorer splicing scores (Hexplorer score + HBond score)
Expand Down Expand Up @@ -38,15 +39,15 @@ def save_to_db(self, info, variant_id, conn):

vids = conn.get_external_ids_from_variant_id(variant_id, id_source="heredicare") # the vids are imported from the import variants admin page

print(vids)
#print(vids)

for vid in vids:
status = "retry"
tries = 0
max_tries = 3
while status == "retry" and tries < max_tries:
heredicare_variant, status, message = heredicare_interface.get_variant(vid)
print(heredicare_variant)
#print(heredicare_variant)
if tries > 0:
time.sleep(30 * tries)
if status == "error":
Expand All @@ -55,9 +56,19 @@ def save_to_db(self, info, variant_id, conn):
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["BEMERK"] if heredicare_variant["BEMERK"] != '' else None
bemerk = heredicare_variant["BEMERK"] if heredicare_variant["BEMERK"] is not None else ''
vustf_bemerk = heredicare_variant["VUSTF_BEMERK"] if heredicare_variant["VUSTF_BEMERK"] is not None else ''
comment = bemerk + ' ' + vustf_bemerk
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, comment)
conn.insert_heredicare_annotation(variant_id, vid, n_fam, n_pat, consensus_class, classification_date, comment)



12 changes: 6 additions & 6 deletions src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -1740,9 +1740,9 @@ def get_variant(self, variant_id,
n_pat = annot[3]
consensus_class = annot[4]
comment = annot[5]
date = annot[6]
classification_date = annot[6]

classification = models.HeredicareClassification(id = heredicare_annotation_id, selected_class = consensus_class, comment = comment, date = date, center = "VUSTF")
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)

Expand Down Expand Up @@ -1867,7 +1867,7 @@ def get_variant(self, variant_id,
comment = cl_raw[4]
center = cl_raw[3]
date = cl_raw[5].strftime('%Y-%m-%d')
new_heredicare_classification = models.HeredicareClassification(id = id, selected_class = selected_class, comment = comment, center = center, date = date)
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)

# add clinvar annotation
Expand Down Expand Up @@ -2259,9 +2259,9 @@ def get_placeholders(self, num):



def insert_heredicare_annotation(self, variant_id, vid, n_fam, n_pat, consensus_class, comment):
command = "INSERT INTO variant_heredicare_annotation (variant_id, vid, n_fam, n_pat, consensus_class, comment) VALUES (%s, %s, %s, %s, %s, %s)"
self.cursor.execute(command, (variant_id, vid, n_fam, n_pat, consensus_class, comment))
def insert_heredicare_annotation(self, variant_id, vid, n_fam, n_pat, consensus_class, classification_date, comment):
command = "INSERT INTO variant_heredicare_annotation (variant_id, vid, n_fam, n_pat, consensus_class, date, comment) VALUES (%s, %s, %s, %s, %s, %s, %s)"
self.cursor.execute(command, (variant_id, vid, n_fam, n_pat, consensus_class, classification_date, comment))
self.conn.commit()

def clear_heredicare_annotation(self, variant_id):
Expand Down
62 changes: 61 additions & 1 deletion src/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,51 @@ class HeredicareClassification:
id: int
selected_class: int
comment: str
date: str
classification_date: str
center: str
vid: str

def selected_class_to_text(self):
if self.selected_class is None:
return "not classified"
class2text = {
"1": "pathogenic",
"2": "VUS",
"3": "polymorphism/neutral",
"11": "class 1",
"12": "class 2",
"32": "class 3-",
"13": "class 3",
"34": "class 3+",
"14": "class 4",
"15": "class 5",
"20": "artifact",
"21": "not classified",
"4": "unknown",
"-1": "not classified"
}
return class2text[str(self.selected_class)]

def selected_class_to_num(self):
if self.selected_class is None:
return "-"
class2text = {
"1": "5",
"2": "3",
"3": "1",
"11": "1",
"12": "2",
"32": "3-",
"13": "3",
"34": "3+",
"14": "4",
"15": "5",
"20": "-", # ARTIFACT???
"21": "-",
"4": "-",
"-1": "-"
}
return class2text[str(self.selected_class)]

def to_vcf(self, prefix = True):
info = '~7C'.join([str(self.selected_class), self.center, self.comment, self.date])
Expand Down Expand Up @@ -578,6 +621,23 @@ class Variant:

annotations: AllAnnotations = AllAnnotations()

def get_heredicare_consensus_classifications(self):
result = []
for heredicare_annotation in self.heredicare_annotations:
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):
total_n_fam = 0
total_n_pat = 0
Expand Down
44 changes: 31 additions & 13 deletions src/frontend_celery/webapp/templates/variant/variant_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,37 @@ <h4 class="card-subcaption">HerediVar user classifications</h4>
</div>
</div>
{% endif %}

{% if variant.heredicare_annotations is not none %}
<div>

{% set heredicare_consensus_classifications = variant.get_heredicare_consensus_classifications() %}
{% if heredicare_consensus_classifications | length > 0 %}
<div class="ssb">
<h4 class="card-subcaption">HerediCare consensus classifications</h4>
{% for heredicare_annotation in variant.heredcare_annotations %}
{% set current_classification = heredicare_annotation.vustf_classification %}
{% if current_classification.selected_class is not none %}
<div>{{current_classification.selected_class}}</div>
<div>{{current_classification.comment}}</div>
{% endif %}
{% endfor %}

<div class="left-space-padding">
<table class="table table-borderless table-slim">
<tbody>
{% for heredicare_consensus_classification in heredicare_consensus_classifications %}
<tr class="nsl">
<td class="li-label width_very_small">VID {{heredicare_consensus_classification.vid}}</td>
<td class="vertical_align_middle">
<ul class="list-group list-group-horizontal-sm list-nopad-td list-nobackground">
<li class="list-group-item noboarder-td">
Class: {{heredicare_consensus_classification.selected_class_to_text()}} ({{heredicare_consensus_classification.selected_class}})
</li>
<li class="list-group-item noboarder-td">
Date: {{heredicare_consensus_classification.classification_date}}
</li>
<li class="list-group-item noboarder-td">
Comment: {{heredicare_consensus_classification.comment}}
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

{% endif %}

<!-- heredicare center classifications -->
Expand Down Expand Up @@ -245,7 +263,7 @@ <h4 class="card-subcaption">ClinVar classifications</h4>

<!-- BRCA-EXCHANGE -->
{% if variant.annotations.brca_exchange_clinical_significance is not none %}
<div>
<div class="ssb">
<h4 class="card-subcaption">BRCA exchange classification</h4>
<div class="ssl">
{{variant.annotations.brca_exchange_clinical_significance.value}}
Expand All @@ -255,7 +273,7 @@ <h4 class="card-subcaption">BRCA exchange classification</h4>

<!-- ARUP -->
{% if variant.annotations.arup_classification is not none %}
<div>
<div class="ssb">
<h4 class="card-subcaption">ARUP BRCA classification</h4>
<div class="ssl">
{{variant.annotations.arup_classification.value}}
Expand Down

0 comments on commit c4ff099

Please sign in to comment.