Skip to content

Commit

Permalink
Capping max. number of cases to query at once (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Mar 9, 2022
1 parent cc29127 commit 0d79215
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 63 deletions.
16 changes: 9 additions & 7 deletions HISTORY.rst
Expand Up @@ -49,8 +49,9 @@ End-User Summary
- Adding REST API for creating small variant queries (#332)
- Fixing beaconsite queries with dots in the key id (#369)
- Allowing joint queries of larger cohorts (#241)
- Documenting Clinical Beacon v1 protocol.
- Improving performance for fetching result queries (#371).
- Documenting Clinical Beacon v1 protocol
- Improving performance for fetching result queries (#371)
- Capping max. number of cases to query at once (#372)

Full Change List
================
Expand Down Expand Up @@ -109,11 +110,12 @@ Full Change List
- Adding REST API for creating small variant queries (#332)
- Upgrading sodar-core dependency to 0.10.10
- Fixing beaconsite queries with dots in the key id (#369)
- Allowing joint queries of larger cohorts (#241).
This is achieved by performing fewer UNION queries (at most ``VARFISH_QUERY_MAX_UNION=20`` at one time).
- Documenting Clinical Beacon v1 protocol.
- Improving performance for fetching result queries (#371).
- Fix to support sodar-core v0.10.10.
- Allowing joint queries of larger cohorts (#241)
This is achieved by performing fewer UNION queries (at most ``VARFISH_QUERY_MAX_UNION=20`` at one time)
- Documenting Clinical Beacon v1 protocol
- Improving performance for fetching result queries (#371)
- Fix to support sodar-core v0.10.10
- Capping max. number of cases to query at once (#372)

-------
v0.23.9
Expand Down
3 changes: 3 additions & 0 deletions config/settings/base.py
Expand Up @@ -475,6 +475,9 @@ def set_logging(level=None):
# Varfish: Base
# ------------------------------------------------------------------------------

# Limit on number of cases to allow project/cohort wide queries for.
VARFISH_MAX_CASE_QUERY_COUNT = env.int("VARFISH_MAX_CASE_QUERY_COUNT", 100)

# Yes, we want ForeinKey(unique=True), thank you very much.
SILENCED_SYSTEM_CHECKS = ["fields.W342"]

Expand Down
9 changes: 9 additions & 0 deletions varfish/static/js/filter_form.js
Expand Up @@ -2069,6 +2069,15 @@ function buildTextareaFromHpoSelected() {

$(document).ready(
function() {
// Do not load if the #filterForm has case-count and case-max-count attributes
if ($("#filterForm").length) {
const caseCount = $("#filterForm").data("case-count")
const maxCases = $("#filterForm").data("case-max-count")
if (caseCount !== null && maxCases !== null && caseCount > maxCases) {
return;
}
}

if (structural_or_small === "small") {
makeNumberFieldsReceiveOnlyDigits();
if ($("#settingsDump").val() != "") {
Expand Down
133 changes: 77 additions & 56 deletions variants/templates/variants/_filter_form.html
Expand Up @@ -8,6 +8,7 @@
{% get_django_setting 'VARFISH_ENABLE_CADD' as cadd_enabled %}
{% get_django_setting 'VARFISH_ENABLE_CADD_SUBMISSION' as cadd_submission_enabled %}
{% get_django_setting 'VARFISH_ENABLE_SPANR_SUBMISSION' as spanr_submission_enabled %}
{% get_django_setting 'VARFISH_MAX_CASE_QUERY_COUNT' as max_case_query_count %}
{% get_is_testing as is_testing %}

{% if form.errors %}
Expand All @@ -18,7 +19,7 @@
{% endfor %}
{% endif %}

<form id="filterForm" method="post">{% csrf_token %}
<form id="filterForm" method="post" data-case-count="{{ case_count }}" data-case-max-count="{{ max_case_query_count }}">{% csrf_token %}
{{ form.cohort }}
{% if is_testing %}<span style="display: none;" class="testing" id="panel-app-is-testing">enabled</span>{% endif %}
<div class="card">
Expand Down Expand Up @@ -66,8 +67,21 @@
<div class="card-body p-0">
<div class="tab-content">
<div class="tab-pane fade show active" id="panel-genotype" role="tabpanel" aria-labelledby="genotype-tab">
{% include "variants/filter_form/genotype.html" %}
</div>
{% if not case_count or case_count <= max_case_query_count %}
{% include "variants/filter_form/genotype.html" %}
{% else %}
<div style="overflow-y: auto !important; max-height: 400px;">
<div class="danger ml-3 mr-3 mt-3 mb-3">
<span class="iconify text-danger" data-icon="fa-solid:exclamation-triangle"></span>
This {% if cohort %} cohort {% else %} project {% endif %} has {{ case_count }} cases.
Currently, VarFish is limited to filter at most {{ max_case_query_count }} at once.
For now, a workaround is to split your {% if cohort %} cohort {% else %} project {% endif %} into smaller cohorts.
The VarFish developer team is working on resolving this for the v2.x branch.
You can <a href="https://github.com/bihealth/varfish-server/issues/309">track the progress here</a>.
</div>
</div>
{% endif %}
</div>
<div class="tab-pane fade" id="panel-frequency" role="tabpanel" aria-labelledby="frequency-tab">
{% include "variants/filter_form/frequency.html" %}
</div>
Expand Down Expand Up @@ -113,70 +127,77 @@
</div>
</div>
<div class="col text-right p-0">
<div class="btn-group">
<button type="button" id="submitFilter" name="submit" value="display" class="btn btn-primary" data-toggle="tooltip" aria-haspopup="true" aria-expanded="false" data-html="true"
title="Filter variants again with current settings, limited to <i><b>Miscellaneous / Result row limit</b></i> results and display in table below"
data-url='{{ submit_button_url }}'
data-url-reload='{{ load_data_url }}'
data-url-request-last-job='{{ request_previous_job_url }}'
data-url-status='{{ job_status_url }}'
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="mdi:refresh"></i>
Filter &amp; Display
{% if case_count > max_case_query_count %}
<button class="btn btn-primary" disabled>
<span class="iconify" data-icon="fa-solid:times-circle"></span>
Filter Disabled
</button>
<button class="btn btn-secondary dropdown-toggle" type="button" id="filterdisplayoptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="iconify" data-icon="fa-solid:ellipsis-h"></i>
</button>
<div class="dropdown-menu" aria-labelledby="filterdisplayoptions" style="z-index: 3000">
<button type="submit" name="submit" value="download" class="dropdown-item" data-toggle="tooltip" aria-haspopup="true" aria-expanded="false" data-html="true"
title="Create downloadable file in the background of <i><b>all</b></i> variants with current settings (ignoring result count limit)."
{% else %}
<div class="btn-group">
<button type="button" id="submitFilter" name="submit" value="display" class="btn btn-primary" data-toggle="tooltip" aria-haspopup="true" aria-expanded="false" data-html="true"
title="Filter variants again with current settings, limited to <i><b>Miscellaneous / Result row limit</b></i> results and display in table below"
data-url='{{ submit_button_url }}'
data-url-reload='{{ load_data_url }}'
data-url-request-last-job='{{ request_previous_job_url }}'
data-url-status='{{ job_status_url }}'
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="fa-solid:cloud-download-alt"></i>
Download as File
<i class="iconify" data-icon="mdi:refresh"></i>
Filter &amp; Display
</button>
{% if allow_md_submission %}
{% if form.case.release == "GRCh37" %}
<button type="button" class="dropdown-item" data-toggle="modal" data-target="#confirm-submit-mutationdistiller"
data-tooltip="tooltip" aria-haspopup="true" aria-expanded="false"
title="Submit to MutationDistiller (only supports single-sample VCF at the moment)"
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="bi:send-fill"></i>
Submit to MutationDistiller
</button>
{% else %}
<button type="button" class="dropdown-item disabled">
<i class="iconify" data-icon="bi:send-fill"></i>
MutationDistiller: Only GRCh37
</button>
{% endif %}
{% endif %}
{% if cadd_submission_enabled %}
<button type="button" class="dropdown-item" data-toggle="modal" data-target="#confirm-submit-cadd"
data-tooltip="tooltip" aria-haspopup="true" aria-expanded="false"
title="Submit to CADD"
<button class="btn btn-secondary dropdown-toggle" type="button" id="filterdisplayoptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="iconify" data-icon="fa-solid:ellipsis-h"></i>
</button>
<div class="dropdown-menu" aria-labelledby="filterdisplayoptions" style="z-index: 3000">
<button type="submit" name="submit" value="download" class="dropdown-item" data-toggle="tooltip" aria-haspopup="true" aria-expanded="false" data-html="true"
title="Create downloadable file in the background of <i><b>all</b></i> variants with current settings (ignoring result count limit)."
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="bi:send-fill"></i>
Submit to CADD
<i class="iconify" data-icon="fa-solid:cloud-download-alt"></i>
Download as File
</button>
{% endif %}
{% if spanr_submission_enabled %}
{% if form.case.release == "GRCh37" %}
<button type="button" class="dropdown-item" data-toggle="modal" data-target="#confirm-submit-spanr"
{% if allow_md_submission %}
{% if form.case.release == "GRCh37" %}
<button type="button" class="dropdown-item" data-toggle="modal" data-target="#confirm-submit-mutationdistiller"
data-tooltip="tooltip" aria-haspopup="true" aria-expanded="false"
title="Submit to MutationDistiller (only supports single-sample VCF at the moment)"
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="bi:send-fill"></i>
Submit to MutationDistiller
</button>
{% else %}
<button type="button" class="dropdown-item disabled">
<i class="iconify" data-icon="bi:send-fill"></i>
MutationDistiller: Only GRCh37
</button>
{% endif %}
{% endif %}
{% if cadd_submission_enabled %}
<button type="button" class="dropdown-item" data-toggle="modal" data-target="#confirm-submit-cadd"
data-tooltip="tooltip" aria-haspopup="true" aria-expanded="false"
title="Submit to SPANR"
title="Submit to CADD"
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="bi:send-fill"></i>
Submit to SPANR
</button>
{% else %}
<button type="button" class="dropdown-item disabled">
<i class="iconify" data-icon="bi:send-fill"></i>
SPANR: Only GRCh37
Submit to CADD
</button>
{% endif %}
{% endif %}
{% if spanr_submission_enabled %}
{% if form.case.release == "GRCh37" %}
<button type="button" class="dropdown-item" data-toggle="modal" data-target="#confirm-submit-spanr"
data-tooltip="tooltip" aria-haspopup="true" aria-expanded="false"
title="Submit to SPANR"
{% if num_small_vars == 0 or not variant_set_exists %}disabled{% endif %}>
<i class="iconify" data-icon="bi:send-fill"></i>
Submit to SPANR
</button>
{% else %}
<button type="button" class="dropdown-item disabled">
<i class="iconify" data-icon="bi:send-fill"></i>
SPANR: Only GRCh37
</button>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions variants/views.py
Expand Up @@ -2774,6 +2774,10 @@ def get_initial(self):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["cohort"] = self.get_cohort()
if context["cohort"]:
context["case_count"] = context["cohort"].cases.count()
else:
context["case_count"] = context["project"].case_set.count()
context["num_small_vars"] = context["project"].num_small_vars()
context["variant_set_exists"] = (
context["project"].case_set.filter(smallvariantset__state="active").exists()
Expand Down

0 comments on commit 0d79215

Please sign in to comment.