Skip to content

Commit

Permalink
Fixed smallvariant flags filter query. (#544)
Browse files Browse the repository at this point in the history
Added flags `segregates`, `doesnt_segregate` and `no_disease_association` to file export.

Closes: #502
Related-Issue: #502
Projected-Results-Impact: none
  • Loading branch information
stolpeo committed Jun 20, 2022
1 parent 07c2015 commit f038816
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 12 deletions.
12 changes: 8 additions & 4 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ End-User Summary
- Adjusting default frequency filters for "clinvar pathogenic" filter: remove all threshold (#464).
- Adding note about difference with upstream Clinvar (#464).
- Switching scoring to MutationTaster 85 interface, added back MT 85 link-out alongside MT 2021 link-out (#509).
- Made flag filter and flag form nomenclature consistent (#297)
- Made flag filter and flag form nomenclature consistent (#297).
- Improved developer setup documentation and added Windows installation instructions (#533).
- Fixed broken VariantValidator query (#523)
- Fixed broken VariantValidator query (#523).
- Fixed smallvariant flags filter query (#502).
- Added flags `segregates`, `doesnt_segregate` and `no_disease_association` to file export (#502).

Full Change List
================
Expand All @@ -47,12 +49,14 @@ Full Change List
- Adding note about difference with upstream Clinvar (#464).
- Switching scoring to MutationTaster 85 interface, added back MT 85 link-out alongside MT 2021 link-out (#509).
- CADD setup fix for documentation (#520)
- Made flag filter and flag form nomenclature consistent (#297)
- Made flag filter and flag form nomenclature consistent (#297).
- Updating ``utility/*.sh`` scripts from "upstream" sodar-server (#531).
- Improved developer setup documentation and added Windows installation instructions (#533).
- Skip commit trailer checks for dependabot (#537).
- Fixed broken VariantValidator query (#523)
- Fixed broken VariantValidator query (#523).
- Converted not cooperative tooltip to standard title on Filter & Display button (#508).
- Fixed smallvariant flags filter query (#502).
- Added flags `segregates`, `doesnt_segregate` and `no_disease_association` to file export (#502).

------
v1.2.0
Expand Down
3 changes: 3 additions & 0 deletions svs/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class Meta:
flag_candidate = False
flag_final_causative = False
flag_for_validation = False
flag_no_disease_association = False
flag_segregates = False
flag_doesnt_segregate = False

flag_molecular = "empty"
flag_visual = "empty"
Expand Down
8 changes: 7 additions & 1 deletion varfish/static/js/flags_comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function clickVariantBookmark() {
dataType: "json",
}).done(function(data) {
// successfully updated flags, update bookmark display
if (data["flag_bookmarked"] || data["flag_for_validation"] || data["flag_candidate"] || data["flag_final_causative"]) {
if (data["flag_bookmarked"] || data["flag_for_validation"] || data["flag_candidate"] || data["flag_final_causative"] || data["flag_no_disease_association"] || data["flag_segregates"] || data["flag_doesnt_segregate"]) {
icon_bookmark.attr("src", "/icons/fa-solid/bookmark.svg");
} else {
icon_bookmark.attr("src", "/icons/fa-regular/bookmark.svg");
Expand Down Expand Up @@ -635,6 +635,9 @@ function clickVariantAcmgRatingModal(event) {
flag_for_validation: false,
flag_candidate: false,
flag_final_causative: false,
flag_no_disease_association: false,
flag_segregates: false,
flag_doesnt_segregate: false,
flag_visual: "empty",
flag_validation: "empty",
flag_phenotype_match: "empty",
Expand Down Expand Up @@ -776,6 +779,9 @@ function clickVariantAcmgRating() {
flag_for_validation: false,
flag_candidate: false,
flag_final_causative: false,
flag_no_disease_association: false,
flag_segregates: false,
flag_doesnt_segregate: false,
flag_visual: "empty",
flag_validation: "empty",
flag_phenotype_match: "empty",
Expand Down
3 changes: 3 additions & 0 deletions variants/file_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def to_str(val):
("flag_candidate", "Flag: selected as candidate disease-causing", str),
("flag_final_causative", "Flag: selected as final causative variant", str),
("flag_for_validation", "Flag: selected for validation", str),
("flag_no_disease_association", "Flag: selected for no known disease association", str),
("flag_segregates", "Flag: selected as segregating variant", str),
("flag_doesnt_segregate", "Flag: selected as not segregating variant", str),
("flag_molecular", "Rating: variant is molecular", str),
("flag_visual", "Rating: visual inspection of alignment", str),
("flag_validation", "Rating: validation result", str),
Expand Down
19 changes: 15 additions & 4 deletions variants/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,14 +1219,25 @@ class ExtendQueryPartsFlagsJoinAndFilter(ExtendQueryPartsFlagsJoin):
def extend_conditions(self, _query_parts):
"""Build WHERE clause for the query based on the ``SmallVariantFlags`` and ``SmallVariantComment``."""
terms = []
not_terms = [true()]
none_terms = [true()]
# Add terms for the simple, boolean-valued flags.
flag_names = ("bookmarked", "candidate", "final_causative", "for_validation")
flag_names = (
"bookmarked",
"candidate",
"final_causative",
"for_validation",
"segregates",
"doesnt_segregate",
"no_disease_association",
)
for flag in flag_names:
flag_name = "flag_%s" % flag
if self.kwargs.get(flag_name):
terms.append(column(flag_name))
if self.kwargs.get("flag_simple_empty"):
terms.append(and_(not_(column("flag_%s" % flag))))
if self.kwargs.get("flag_simple_empty"):
not_terms.append(not_(column(flag_name)))
none_terms.append(column(flag_name).is_(None))
# Add terms for the valued flags.
flag_names = ("visual", "validation", "molecular", "phenotype_match", "summary")
for flag in flag_names:
Expand All @@ -1237,7 +1248,7 @@ def extend_conditions(self, _query_parts):
terms.append(column(flag_name) == value)
if value == "empty":
terms.append(column(flag_name).is_(None))
return [or_(*terms)]
return [or_(*terms, and_(*not_terms), and_(*none_terms))]


class ExtendQueryPartsAcmgCriteriaJoin(ExtendQueryPartsBase):
Expand Down
6 changes: 6 additions & 0 deletions variants/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class FormDataFactory(FormDataFactoryBase):
flag_candidate: bool = True
flag_final_causative: bool = True
flag_for_validation: bool = True
flag_no_disease_association: bool = True
flag_segregates: bool = True
flag_doesnt_segregate: bool = True
flag_phenotype_match_empty: bool = True
flag_phenotype_match_negative: bool = True
flag_phenotype_match_positive: bool = True
Expand Down Expand Up @@ -946,6 +949,9 @@ class Meta:
flag_candidate = False
flag_final_causative = False
flag_for_validation = False
flag_no_disease_association = False
flag_segregates = False
flag_doesnt_segregate = False
flag_molecular = ""
flag_visual = ""
flag_validation = ""
Expand Down
6 changes: 3 additions & 3 deletions variants/tests/test_file_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_export_tsv(self):
def _test_tabular(self, arrs, has_trailing):
self.assertEquals(len(arrs), 4 + int(has_trailing))
# TODO: also test without flags and comments
self.assertEquals(len(arrs[0]), 46)
self.assertEquals(len(arrs[0]), 49)
self.assertSequenceEqual(arrs[0][:3], ["Chromosome", "Position", "Reference bases"])
self.assertSequenceEqual(
arrs[0][-5:],
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_export_tsv(self):
def _test_tabular(self, arrs, has_trailing):
self.assertEquals(len(arrs), 5 + int(has_trailing))
# TODO: also test without flags and comments
self.assertEquals(len(arrs[0]), 47)
self.assertEquals(len(arrs[0]), 50)
self.assertSequenceEqual(arrs[0][:3], ["Sample", "Chromosome", "Position"])
self.assertEqual(arrs[0][-1], "sample Alternate allele fraction")
members = sorted(self.project.get_members())
Expand Down Expand Up @@ -411,7 +411,7 @@ def test_export_tsv_as_contributor_for_cohort_by_superuser(self):
def _test_tabular(self, arrs, ref, has_trailing, smallvars):
self.assertEquals(len(arrs), ref + int(has_trailing))
# TODO: also test without flags and comments
self.assertEquals(len(arrs[0]), 47)
self.assertEquals(len(arrs[0]), 50)
self.assertSequenceEqual(arrs[0][:3], ["Sample", "Chromosome", "Position"])
self.assertEqual(arrs[0][-1], "sample Alternate allele fraction")
for i, small_var in enumerate(sorted(smallvars, key=lambda x: (x.chromosome_no, x.start))):
Expand Down

0 comments on commit f038816

Please sign in to comment.