Skip to content

Commit

Permalink
Merge 6bbb4f7 into 2db7505
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed May 9, 2022
2 parents 2db7505 + 6bbb4f7 commit 1f65bff
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 0 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -19,6 +19,7 @@ End-User Summary
- Fixing paths in "Variant Ingest" documentation (#472).
- Small extension of "Resolution proposal" template (#472).
- Adjusting wrong release name to "anthenea" (#479).
- Adding "show all variant carriers" feature (#470).

Full Change List
================
Expand All @@ -33,6 +34,7 @@ Full Change List
- Fixing paths in "Variant Ingest" documentation (#472).
- Small extension of "Resolution proposal" template (#472).
- Adjusting wrong release name to "anthenea" (#479).
- Adding "show all variant carriers" feature (#470).

------
v1.2.0
Expand Down
18 changes: 18 additions & 0 deletions varfish/static/js/variant_carrier.js
@@ -0,0 +1,18 @@
function showVariantCarrierModal(obj, release, chromosome, start, reference, alternative) {
const box = $(`#variantcarriermodal-${release}-${chromosome}-${start}-${reference}-${alternative}`).find('.variant-carrier-results');
box.html('<div class="text-center"><i class="iconify spin" data-icon="fa-solid:spinner"></i></div>');
$.ajax({
type: 'GET',
url: `${variant_carriers_url}?release=${release}&chromosome=${chromosome}&position=${start}` +
`&reference=${reference}&alternative=${alternative}`,
success: function (response) {
// icon.removeClass('spin').attr('data-icon', 'fa-solid:cloud-upload');
box.html(response);
},
error: function (jqXHR, textStatus, errorThrown) {
alert("Error during AJAX call:", textStatus, + errorThrown);
console.log("Error during AJAX call: ", jqXHR, textStatus, errorThrown);
},
timeout: 0
});
}
27 changes: 27 additions & 0 deletions variants/templates/variants/filter_result/row.html
Expand Up @@ -455,6 +455,15 @@
{% endif %}
<td>
<div class="btn-group sodar-list-btn-group pr-2">
<button
class="btn btn-primary sodar-list-btn"
type="button"
data-toggle="modal"
data-target="#variantcarriermodal-{{ entry.release }}-{{ entry.chromosome }}-{{ entry.start }}-{{ entry.reference }}-{{ entry.alternative }}"
onclick="showVariantCarrierModal(this, '{{ entry.release }}', '{{ entry.chromosome }}', '{{ entry.start }}', '{{ entry.reference }}', '{{ entry.alternative }}');"
>
<span class="iconify" data-icon="mdi:binoculars"></span>
</button>
{% if entry.release == "GRCh37" %}
<a
href="https://www.genecascade.org/MTc2021/ChrPos102.cgi?chromosome={{ entry.chromosome }}&position={{ entry.start }}&ref={{ entry.reference }}&alt={{ entry.alternative }}"
Expand Down Expand Up @@ -634,6 +643,24 @@
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="variantcarriermodal-{{ entry.release }}-{{ entry.chromosome }}-{{ entry.start }}-{{ entry.reference }}-{{ entry.alternative }}">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="variantcarriermodallabel-{{ entry.release }}-{{ entry.chromosome }}-{{ entry.start }}-{{ entry.reference }}-{{ entry.alternative }}">In-House Variant Carriers</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="variant-carrier-results container-fluid">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
<div class="modal fade" id="variantvalidatormodal-{{ entry.release }}-{{ entry.chromosome }}-{{ entry.start }}-{{ entry.reference }}-{{ entry.alternative }}" tabindex="-1" role="dialog" aria-labelledby="variantvalidatormodallabel-{{ entry.release }}-{{ entry.chromosome }}-{{ entry.start }}-{{ entry.reference }}-{{ entry.alternative }}" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
Expand Down
@@ -0,0 +1,47 @@
{% load dict %}
{% load variants_tags %}

<div>
<p>
A total of {{ count_total }} carriers were found for variant <code>{{ small_var.human_readable }}</code>.
{% if count_total == count_noaccess %}
You do not have access to any of them, though.
{% elif count_noaccess == 0 %}
They are displayed below (you have access to all of them).
{% else %}
You do not have access to {{ count_noaccess }} but the remaining {{ count_access }} are displayed below.
{% endif %}
</p>

<table class="table-sm table-striped">
<thead>
<tr>
<th style="width: 20%;">case</th>
<th style="width: 60%;">project</th>
<th style="width: 20%;">genotype</th>
</tr>
</thead>
<tbody>
{% for case, var in case_vars %}
{% for name, genotype in var.genotype.items %}
<tr>
<td>
<a href="{% url 'variants:case-detail' case.project.sodar_uuid case.sodar_uuid %}">
{{ case.name }}
</a>
</td>
<td>
<a href="{% url 'projectroles:detail' case.project.sodar_uuid %}">
{{ case.project.title }}
</a>
</td>
<td>
<span class="small">{{ name|strip_sample_suffix }}</span>
<strong>{{ genotype|keyvalue:"gt" }}</strong>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
2 changes: 2 additions & 0 deletions variants/templates/variants/scripts.html
Expand Up @@ -15,13 +15,15 @@
settings_restored = true;
}
var variant_validator_url = "{% url 'variants:variant-validator-api' %}"
var variant_carriers_url = "{% url 'variants:variant-carriers' %}"
</script>
<script type="text/javascript" src="{% static "js/helpers.js" %}"></script>
<script type="text/javascript" src="{% static "js/state_machine.js" %}"></script>
<script type="text/javascript" src="{% static "js/filter_form.js" %}"></script>
<script type="text/javascript" src="{% static "js/flags_comments.js" %}"></script>
<script type="text/javascript" src="{% static "js/variant_comments.js" %}"></script>
<script type="text/javascript" src="{% static "js/variant_validator.js" %}"></script>
<script type="text/javascript" src="{% static "js/variant_carrier.js" %}"></script>
<script type="text/javascript">
$(document).ready(function() {
let data = {};
Expand Down
10 changes: 10 additions & 0 deletions variants/templatetags/variants_tags.py
Expand Up @@ -592,3 +592,13 @@ def entry_chr(entry):
return "chr" + entry.chromosome
else:
return entry.chromosome


@register.filter
def strip_sample_suffix(value):
"""Strip the SNAPPY suffix ``-N1-DNA1-*``."""
value = value or ""
if "-N1-DNA1" in value:
return value.split("-N1-DNA1")[0]
else:
return value
5 changes: 5 additions & 0 deletions variants/urls.py
Expand Up @@ -370,6 +370,11 @@
view=views.VariantValidatorApiView.as_view(),
name="variant-validator-api",
),
url(
regex=r"^variant-carriers/$",
view=views.VariantCarriersView.as_view(),
name="variant-carriers",
),
#: Detail views for site-wide maintenance jobs.
url(
regex=r"^clear-expired-job/(?P<job>[0-9a-f-]+)/$",
Expand Down
44 changes: 44 additions & 0 deletions variants/views.py
Expand Up @@ -4441,6 +4441,50 @@ def post(self, *args, **kwargs):
)


class VariantCarriersView(PluginContextMixin, TemplateView):
"""Render HTML with other carriers of the variant."""

template_name = "variants/filter_result/variant_carriers_result.html"

def get_context_data(self, *args, **kwargs):
result = super().get_context_data(*args, **kwargs)

small_vars = SmallVariant.objects.filter(
release=self.request.GET.get("release"),
chromosome=self.request.GET.get("chromosome"),
start=self.request.GET.get("position"),
reference=self.request.GET.get("reference"),
alternative=self.request.GET.get("alternative"),
)

result["count_total"] = small_vars.count()
result["count_noaccess"] = 0
result["case_vars"] = []
case_ids = [var.case_id for var in small_vars]
cases = {
case.id: case
for case in Case.objects.prefetch_related("project")
.filter(id__in=case_ids)
.order_by("project__title", "name")
}
for small_var in small_vars:
case = cases[small_var.case_id]
has_access = (
self.request.user and self.request.user.is_superuser
) or case.project.has_role(self.request.user)
if has_access:
result["case_vars"].append((case, small_var))
for name, gt in small_var.genotype.items():
if "1" in gt.get("GT", "0/0"):
result["count_total"] += 1
if not has_access:
result["count_noaccess"] += 1
result["count_access"] = result["count_total"] - result["count_noaccess"]
result["small_var"] = result["case_vars"][0][1]

return result


class KioskHomeView(PluginContextMixin, FormView):
"""Home view when the app is running in kiosk mode.
Expand Down

0 comments on commit 1f65bff

Please sign in to comment.