Skip to content

Commit

Permalink
improved popovers & added heredicare n_fam & n_pat to variant details…
Browse files Browse the repository at this point in the history
… page
  • Loading branch information
MarvinDo committed Oct 6, 2023
1 parent 8c70773 commit f2c2802
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 35 deletions.
30 changes: 27 additions & 3 deletions src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,11 @@ def get_user_classifications_extended(self, variant_id, user_id='all', scheme_id




def get_heredicare_annotations(self, variant_id):
command = "SELECT id, vid, n_fam, n_pat, consensus_class, comment, date FROM variant_heredicare_annotation WHERE variant_id = %s"
self.cursor.execute(command, (variant_id, ))
res = self.cursor.fetchall()
return res



Expand Down Expand Up @@ -1671,6 +1675,7 @@ 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)
Expand All @@ -1690,6 +1695,24 @@ def get_variant(self, variant_id,
#annotations.insert_annotation(new_annotation)

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]
date = annot[6]

classification = models.HeredicareClassification(id = heredicare_annotation_id, selected_class = consensus_class, comment = comment, date = date, center = "VUSTF")
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
Expand Down Expand Up @@ -1878,10 +1901,12 @@ def get_variant(self, variant_id,
consensus_classifications = consensus_classifications,
user_classifications = user_classifications,
heredicare_classifications = heredicare_classifications,
heredicare_annotations = all_heredicare_annotations,
clinvar = clinvar,
consequences = consequences,
assays = assays,
literature = literature)
literature = literature
)
return variant


Expand Down Expand Up @@ -2210,4 +2235,3 @@ def clear_heredicare_annotation(self, variant_id):
self.cursor.execute(command, (variant_id, ))
self.conn.commit()


67 changes: 41 additions & 26 deletions src/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ class AllAnnotations:
tp53db_domain_function: Annotation = None
tp53db_transactivation_class: Annotation = None

heredicare_cases_count: Annotation = None
heredicare_family_count: Annotation = None

task_force_protein_domain: Annotation = None
task_force_protein_domain_source: Annotation = None

Expand Down Expand Up @@ -184,8 +181,6 @@ def get_group(self, group_identifier):
self.tp53db_DNE_LOF_class,
self.tp53db_domain_function,
self.tp53db_transactivation_class])
if group_identifier == 'HerediCare':
return self.prepare_group([self.heredicare_cases_count, self.heredicare_family_count])

def prepare_group(self, group):
prepared_group = [x for x in group if x is not None]
Expand Down Expand Up @@ -399,26 +394,6 @@ def get_header(self, simple = False):
return header


@dataclass
class HeredicareClassification:
id: int
selected_class: int
comment: str
date: str
center: str

def to_vcf(self, prefix = True):
info = '~7C'.join([str(self.selected_class), self.center, self.comment, self.date])
info = info
if prefix:
info = 'heredicare~1Y' + info
return info

def get_header(self):
header = {'heredicare_center_classifications': '##INFO=<ID=heredicare_center_classifications,Number=.,Type=String,Description="An & separated list of the variant classifications from centers imported from HerediCare. Format:class|center|comment|date">\n'}
return header


@dataclass
class ClinvarCondition:
condition_id: str
Expand Down Expand Up @@ -552,6 +527,36 @@ def to_vcf(self, prefix = True):
return info



@dataclass
class HeredicareClassification:
id: int
selected_class: int
comment: str
date: str
center: str

def to_vcf(self, prefix = True):
info = '~7C'.join([str(self.selected_class), self.center, self.comment, self.date])
info = info
if prefix:
info = 'heredicare~1Y' + info
return info

def get_header(self):
header = {'heredicare_center_classifications': '##INFO=<ID=heredicare_center_classifications,Number=.,Type=String,Description="An & separated list of the variant classifications from centers imported from HerediCare. Format:class|center|comment|date">\n'}
return header

@dataclass
class HeredicareAnnotation:
id: int
vid: str
n_fam: int
n_pat: int
vustf_classification: HeredicareClassification



@dataclass
class Variant:
id: int
Expand All @@ -564,14 +569,24 @@ class Variant:

consensus_classifications: Any = None # list of classifications
user_classifications: Any = None # list of classifications
heredicare_classifications: Any = None # list of heredicare classifications
heredicare_classifications: Any = None # list of heredicare center classifications
heredicare_annotations: Any = None # list of heredicare annotatins
clinvar: Any = None # a clinvar object
consequences: Any = None # list of consequences
assays: Any = None # list of assays
literature: Any = None # list of papers

annotations: AllAnnotations = AllAnnotations()

def get_total_heredicare_counts(self):
total_n_fam = 0
total_n_pat = 0
if self.heredicare_annotations is not None:
for annot in self.heredicare_annotations:
total_n_fam += annot.n_fam
total_n_pat += annot.n_pat
return total_n_fam, total_n_pat

def get_unique_genes(self):
result = []
gene_ids = []
Expand Down
14 changes: 14 additions & 0 deletions src/frontend_celery/webapp/static/css/utils.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
padding-left:1rem;
}

.nomargin {
margin: 0em;
}
.nomargin_bottom {
margin-bottom: 0em;
}
.nomargin_top {
margin-top: 0em;
}

/************** sizing **************/
.full_page {
Expand Down Expand Up @@ -217,3 +226,8 @@
.visually_hidden {
display: none;
}

.popover_fix{
width: fit-content !important;
max-width: 25em !important;
}
10 changes: 10 additions & 0 deletions src/frontend_celery/webapp/static/js/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ $(document).ready(function()
$('#consequence_refseq_tab').click(function() {
filter_consequence_table('refseq', variant_consequence_table_default_sorting_columns)
})

$(document).click(function (e) {
close_popovers(e)
});
});

function close_popovers(e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('[data-bs-toggle="popover"]').popover('hide');
}
}


// functionality for the consequence table switch between ensembl & refseq
function filter_consequence_table(source, variant_consequence_table_default_sorting_columns) {
Expand Down
2 changes: 2 additions & 0 deletions src/frontend_celery/webapp/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ <h4>Changelog</h4>
<li>Changed SpliceAI annotations to masked ones</li>
<li>Added variant import from HerediCare</li>
<li>Added HerediCare number of families and heredicare number of cases annotations</li>
<li>Improved criteria popover</li>
</ul>
Bugfixes:
<ul>
<li>Variants are now not selected by default on the search variants page</li>
<li>Abbreviations for criteria are now written with upper case letters</li>
<li>Disabled criteria were not shown correctly</li>
<li>Popovers now stay open when clicked and close when the user does not click inside the popover</li>
</ul>
Known issues:
<ul>
Expand Down
99 changes: 93 additions & 6 deletions src/frontend_celery/webapp/templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,37 @@

{% macro draw_criteria_display(criteria, source='user') %}
{% for criterium in criteria %}
<!--
<span class="d-inline-block ssr tooltip-lg" tabindex="0" data-bs-toggle="tooltip" data-bs-html="true" {% if source=="user" %} user_criterium_applied_id="{{ criterium.id }}" {% else %} consensus_criterium_applied_id="{{ criterium.id }}" {% endif %}
title="Strength: {{ criterium.strength }} <br> Evidence: {{ criterium.evidence }}">
<div class="btn-{{ criterium.type }} light-hover acmg-button acmg-button-small">{{ criterium.display_name() }}</div>
</span>
-->

<span class="d-inline-block ssr criterium-display" data-bs-toggle="popover"
data-bs-placement="top" data-bs-custom-class="popover_fix" data-bs-html="true"
{% if source=="user" %} user_criterium_applied_id="{{ criterium.id }}" {% else %} consensus_criterium_applied_id="{{ criterium.id }}" {% endif %}
data-bs-content="
<div class='width_large'></div>
<div class='row gx-2 border-bottom bg-light'>
<div class='col-3 text-center'>Type</div>
<div class='col-8 text-center border-start'>Info</div>
</div>
<div class='row gx-2'>
<div class='col-3'>Strength</div>
<div class='col-8 text-center border-start'>{{ criterium.strength }}</div>
</div>
<div class='row gx-2'>
<div class='col-3'>Evidence</div>
<div class='col-8 text-center border-start'>{{ criterium.evidence }}</div>
</div>
"
>
<div class="btn-{{ criterium.type }} light-hover acmg-button acmg-button-small">{{ criterium.display_name() }}</div>
</span>



{% endfor %}
{% endmacro %}

Expand Down Expand Up @@ -173,7 +200,7 @@
<li class="list-group-item noboarder-td" >
<div class="d-flex">
<div class="ssr">{{ spliceai.split('|')[0] }}:</div> <div class="ssr">{{ spliceai.split('|')[1:5] | map('float') | max }}</div>
<a class="link" tabindex="0" role="button" data-bs-toggle="popover" data-bs-html="true" data-bs-trigger="focus"
<a class="link" tabindex="0" role="button" data-bs-toggle="popover" data-bs-html="true"
data-bs-content="{{ spliceai_details.description }} <br/> {{ spliceai }}">
details
</a>
Expand All @@ -183,6 +210,7 @@
</ul>
</div>
{% endif %}

<!-- cancerhotspots cancertypes -->
{% if annot.title == 'cancerhotspots_cancertypes' %} <!-- cancerhotspots cancertypes -->
{% set cancerhotspots_cancertypes = annot.value.split('|') %}
Expand All @@ -205,7 +233,8 @@
</tbody>
</table>
</div>
{% endif %}
{% endif %}

<!-- Hexplorer -->
{% if annot.title == 'hexplorer' %} <!-- details for hexplorer score -->
{% set delta, wt, mut = annotations.get_hexplorer() %}
Expand All @@ -223,22 +252,80 @@
{% set delta, wt, mut = annotations.get_max_hbond_rev() %}
{{ draw_hexplorer_score(delta, wt, mut) }}
{% endif %}
<!-- HerediCare -->
{% if annot.title == 'heredicare' %} <!-- add red exclamation mark for heredicare counts -->

<!-- HerediCare add red exclamation mark for heredicare counts
{% if annot.title == 'heredicare' %}
<div annotation_id="{{ annot.id }}">
{% if has_multiple_vids %}
{{ draw_exclamation_mark('Multiple VIDs in HerediCare for this variant. Thus, these counts might be inaccurate!') }}
{% endif %}
<abbr class="ssr" title="{{ annot.description }}"><a class="dashed_underline">{{ annot.display_title }}:</a></abbr>{{ annot.value }}
</div>
{% endif %}
-->
{% endfor %}
</td>
</tr>
{% endif %}
{% endmacro %}


{% macro draw_heredicare_annotations(variant) %}
<tr>
<td class="li-label nowrap">HerediCare</td>
<td>
{% set heredicare_annotations = variant.heredicare_annotations %}

{% set total_n_fam, total_n_pat = variant.get_total_heredicare_counts() %}
<div>
{% if heredicare_annotations | length > 1 %}
{{ draw_exclamation_mark('Multiple VIDs in HerediCare for this variant. Thus, these counts might be inaccurate!') }}
{% endif %}
<abbr class="ssr" title="The number of families in HerediCare reported to have this variant"><a class="dashed_underline">n_fam:</a></abbr>{{ total_n_fam }}
<a class="link" tabindex="0" role="button" data-bs-toggle="popover" data-bs-html="true" data-bs-placement="top" data-bs-custom-class="popover_fix" data-bs-html="true"
data-bs-content="
<div class='row gx-2 border-bottom bg-light width_very_medium'>
<div class='col-7'>HerediCare VID</div>
<div class='col-4 text-center border-start'>n_fam</div>
</div>
{% for annot in heredicare_annotations %}
<div class='row gx-2 width_very_medium'>
<div class='col-7'>{{annot.vid}}</div>
<div class='col-4 text-center border-start'>{{annot.n_fam}}</div>
</div>
{% endfor %}
">
details
</a>
</div>
<div>
{% if heredicare_annotations | length > 1 %}
{{ draw_exclamation_mark('Multiple VIDs in HerediCare for this variant. Thus, these counts might be inaccurate!') }}
{% endif %}
<abbr class="ssr" title="The number of cases in HerediCare reported to have this variant"><a class="dashed_underline">n_pat:</a></abbr>{{ total_n_pat }}
<a class="link" tabindex="0" role="button" data-bs-toggle="popover" data-bs-html="true" data-bs-placement="top" data-bs-custom-class="popover_fix" data-bs-html="true"
data-bs-content="
<div class='row gx-2 border-bottom bg-light width_very_medium'>
<div class='col-7'>HerediCare VID</div>
<div class='col-4 text-center border-start'>n_pat</div>
</div>
{% for annot in heredicare_annotations %}
<div class='row gx-2 width_very_medium'>
<div class='col-7'>{{annot.vid}}</div>
<div class='col-4 text-center border-start'>{{annot.n_pat}}</div>
</div>
{% endfor %}
">
details
</a>
</div>


</td>
</tr>
{% endmacro %}


{% macro draw_transcript_annotation(annot) %}
{% if annot is not none %}
<div class="d-flex">
Expand All @@ -248,7 +335,7 @@
<li class="list-group-item noboarder-td" >
<div class="d-flex">
<div class="ssr">{{ annot.value[transcript] }}</div>
<a class="link" tabindex="0" role="button" data-bs-toggle="popover" data-bs-html="true" data-bs-trigger="focus"
<a class="link" tabindex="0" role="button" data-bs-toggle="popover" data-bs-html="true"
data-bs-content="Transcript: {{ transcript }}">
details
</a>
Expand Down Expand Up @@ -691,7 +778,7 @@
{{ draw_exclamation_mark('There is no wildtype or mutant score. Thus, one of the sequences is missing the motiv! Be careful with the interpretation of the delta score!') }}
{% endif %}
<abbr class="ssr" title="{{ delta.description }}"><a class="dashed_underline">{{ delta.display_title }}:</a></abbr>{{ delta.value }}
<a class="link" tabindex="0" data-bs-html="true" role="button" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-content="reference score: {% if wt is not none %}{{ wt.value }}{% else %}-{% endif %} <br/> mutant score: {% if mut is not none %}{{ mut.value }}{% else %}-{% endif %}">details</a>
<a class="link" tabindex="0" data-bs-html="true" role="button" data-bs-toggle="popover" data-bs-content="reference score: {% if wt is not none %}{{ wt.value }}{% else %}-{% endif %} <br/> mutant score: {% if mut is not none %}{{ mut.value }}{% else %}-{% endif %}">details</a>
</div>

{% endmacro %}
Expand Down
Loading

0 comments on commit f2c2802

Please sign in to comment.