Skip to content

Commit

Permalink
Fixed bug where Exac and thousand genomes settings were not shown in …
Browse files Browse the repository at this point in the history
…frequency tab for GRCh37.

Closes: #597
Related-Issue: #597
Projected-Results-Impact: none
  • Loading branch information
stolpeo committed Aug 2, 2022
1 parent 3240bae commit de77b63
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -35,6 +35,7 @@ End-User Summary
- Adding feature to enable and configure link-out to HGMD (#576).
- Small variant filtration results now allow to easily look up second hits in the same gene (#573).
- Structural filtration results now allow to easily look up second hits in the same gene (#574).
- Fixed bug where Exac and thousand genomes settings were not shown in frequency tab for GRCh37 (#597).

Full Change List
================
Expand Down Expand Up @@ -69,6 +70,7 @@ Full Change List
- Small variant filtration results now allow to easily look up second hits in the same gene (#573).
- Structural filtration results now allow to easily look up second hits in the same gene (#574).
- Bugfix broken SV filter (#587).
- Fixed bug where Exac and thousand genomes settings were not shown in frequency tab for GRCh37 (#597).

------
v1.2.0
Expand Down
15 changes: 0 additions & 15 deletions variants/forms.py
Expand Up @@ -1478,21 +1478,6 @@ def __init__(self, *args, **kwargs):
self.fields["cohort"] = forms.CharField(
widget=forms.HiddenInput(), initial=str(cohort.sodar_uuid)
)
self.genomebuild = self._get_genomebuild()

def _get_genomebuild(self):
"""Return genome build for case or cohort or project"""
if isinstance(self.project_or_cohort, Cohort):
cases = [
case
for case in self.project_or_cohort.get_accessible_cases_for_user(self.superuser)
]
else: # project
cases = [case for case in self.project_or_cohort.case_set.all()]
if not cases:
return "GRCh37"
else:
return cases[0].release

def get_pedigree(self):
"""Return ``list`` of ``dict`` with pedigree information."""
Expand Down
9 changes: 6 additions & 3 deletions variants/templates/variants/filter_form/frequency.html
Expand Up @@ -9,7 +9,7 @@
The checkboxes enable (<i class="iconify" data-icon="fa-regular:check-square"></i>) or disable (<i class="iconify" data-icon="fa-regular:square"></i>) filtration based on the population frequencies of the given database.
You can provide the number of carriers with maximal heterozygous/homozygous (respectively: -plasmid) state or population frequencies.
For the in-house DB, you can only filter based on carrier state as currently it is tracked how many carriers have sufficient coverage for each variant.
{% if form.genomebuild != "GRCh37" %}Thousand genomes and ExAC frequencies are only available GRCh37 cases.{% endif %}
{% if genomebuild != "GRCh37" %}Thousand genomes and ExAC frequencies are only available GRCh37 cases.{% endif %}
</div>

<table class="table table-striped table-hover sodar-card-table compact-form-groups">
Expand All @@ -24,15 +24,18 @@
</tr>
</thead>
<tbody>
<tr{% if form.genomebuild != "GRCh37" %} style="display: none;"{% endif %}>
<tr>
<td colspan="6">{{ genomebuild }}</td>
</tr>
<tr{% if genomebuild != "GRCh37" %} style="display: none;"{% endif %}>
<td>{{ form.thousand_genomes_enabled|as_crispy_field }}</td>
<td data-toggle="tooltip" title="Phase 3 data (healthy individuals)">1000 Genomes <small class="text-muted">(samples: 1000)</small></td>
<td>{{ form.thousand_genomes_homozygous|as_crispy_field }}</td>
<td>{{ form.thousand_genomes_heterozygous|as_crispy_field }}</td>
<td>{{ form.thousand_genomes_hemizygous|as_crispy_field }}</td>
<td>{{ form.thousand_genomes_frequency|as_crispy_field }}</td>
</tr>
<tr{% if form.genomebuild != "GRCh37" %} style="display: none;"{% endif %}>
<tr{% if genomebuild != "GRCh37" %} style="display: none;"{% endif %}>
<td>{{ form.exac_enabled|as_crispy_field }}</td>
<td data-toggle="tooltip" title="Exomes; project attempts to exclude pediatric disease cases">ExAC <small class="text-muted">(samples: 60,706)</small></td>
<td>{{ form.exac_homozygous|as_crispy_field }}</td>
Expand Down
16 changes: 16 additions & 0 deletions variants/views.py
Expand Up @@ -2172,6 +2172,7 @@ def get_context_data(self, **kwargs):
"""Put the ``Case`` object into the context."""
context = super().get_context_data(**kwargs)
context["object"] = self.get_case_object()
context["genomebuild"] = context["object"].release
context["num_small_vars"] = context["object"].num_small_vars
context["variant_set_exists"] = (
context["object"].smallvariantset_set.filter(state="active").exists()
Expand Down Expand Up @@ -2782,13 +2783,28 @@ def get_initial(self):
result[key] = value
return result

def _get_genomebuild(self, project_or_cohort):
"""Return genome build for case or cohort or project"""
if isinstance(project_or_cohort, Cohort):
cases = [
case for case in project_or_cohort.get_accessible_cases_for_user(self.request.user)
]
else: # project
cases = [case for case in project_or_cohort.case_set.all()]
if not cases:
return "GRCh37"
else:
return cases[0].release

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()
context["genomebuild"] = self._get_genomebuild(context["cohort"])
else:
context["case_count"] = context["project"].case_set.count()
context["genomebuild"] = self._get_genomebuild(context["project"])
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 de77b63

Please sign in to comment.