From b87b300863bada0e61035453c9d5bcc9d60f165b Mon Sep 17 00:00:00 2001
From: Manuel Holtgrewe
Date: Mon, 31 Jan 2022 16:30:52 +0100
Subject: [PATCH] Make clinvar work with many user annotations (#302)
---
HISTORY.rst | 6 +-
clinvar_export/tests/test_permissions_ajax.py | 11 +-
clinvar_export/tests/test_views_ajax.py | 4 +-
clinvar_export/urls.py | 2 +-
clinvar_export/views_ajax.py | 6 +-
varfish/static/js/variant_validator.js | 2 +-
varfish/vueapp/src/api/clinvarExport.js | 4 +-
.../vueapp/src/components/SubmissionList.vue | 167 ++++++++++++++++--
.../vueapp/src/store/modules/clinvarExport.js | 65 +------
9 files changed, 179 insertions(+), 88 deletions(-)
diff --git a/HISTORY.rst b/HISTORY.rst
index 33895b20d..fb8ecc6bb 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -39,7 +39,8 @@ End-User Summary
- Improving performance of case listing (#304)
- Adding shortcut buttons to phenotype annotation (#289)
- Fixing issue with multiple added variants (#283)
-- Implementing several usability improvements for clinvar submission editor (#286).
+- Implementing several usability improvements for clinvar submission editor (#286)
+- Make clinvar UI work with many annotations (#302)
Full Change List
================
@@ -80,7 +81,8 @@ Full Change List
- Improving performance of case listing (#304)
- Adding shortcut buttons to phenotype annotation (#289)
- Fixing issue with multiple added variants (#283)
-- Implementing several usability improvements for clinvar submission editor (#286).
+- Implementing several usability improvements for clinvar submission editor (#286)
+- Make clinvar UI work with many annotations by making it load them lazily for one case at a time (#302)
-------
v0.23.9
diff --git a/clinvar_export/tests/test_permissions_ajax.py b/clinvar_export/tests/test_permissions_ajax.py
index 8b5233542..97dcfca26 100644
--- a/clinvar_export/tests/test_permissions_ajax.py
+++ b/clinvar_export/tests/test_permissions_ajax.py
@@ -5,7 +5,7 @@
from projectroles.tests.test_permissions_api import TestProjectAPIPermissionBase
from geneinfo.tests.factories import HpoNameFactory, HpoFactory
-from variants.tests.factories import SmallVariantCommentFactory
+from variants.tests.factories import CaseFactory, SmallVariantCommentFactory
from .factories import (
SubmissionSetFactory,
SubmissionFactory,
@@ -18,6 +18,7 @@
SubmittingOrgFactory,
SubmitterFactory,
)
+from ..models import Family
class TestOrganisationAjaxViews(TestProjectAPIPermissionBase):
@@ -681,10 +682,16 @@ def test(self):
class TestAnnotatedSmallVariantsAjaxViews(TestProjectAPIPermissionBase):
"""Permission tests for the AJAX views for querying user-annotated small variants."""
+ def setUp(self):
+ super().setUp()
+ self.case = CaseFactory(project=self.project)
+ self.family = Family.objects.get_or_create_in_project(project=self.project, case=self.case)
+
def test(self):
SmallVariantCommentFactory()
url = reverse(
- "clinvar_export:user-annotations", kwargs={"project": self.project.sodar_uuid,},
+ "clinvar_export:user-annotations",
+ kwargs={"project": self.project.sodar_uuid, "family": self.family.sodar_uuid},
)
good_users = [
self.superuser,
diff --git a/clinvar_export/tests/test_views_ajax.py b/clinvar_export/tests/test_views_ajax.py
index deadb0239..d58b71ae7 100644
--- a/clinvar_export/tests/test_views_ajax.py
+++ b/clinvar_export/tests/test_views_ajax.py
@@ -876,6 +876,7 @@ class TestAnnotatedSmallVariantsAjaxViews(TestProjectAPIPermissionBase):
def setUp(self):
super().setUp()
self.case = CaseFactory(project=self.project)
+ self.family = Family.objects.get_or_create_in_project(project=self.project, case=self.case)
self.small_variant = SmallVariantFactory(case_id=self.case.id)
kwargs = {
key: getattr(self.small_variant, key)
@@ -887,7 +888,8 @@ def setUp(self):
def test_query(self):
url = reverse(
- "clinvar_export:user-annotations", kwargs={"project": self.project.sodar_uuid,},
+ "clinvar_export:user-annotations",
+ kwargs={"project": self.project.sodar_uuid, "family": self.family.sodar_uuid},
)
with self.login(self.contributor_as.user):
response = self.client.get(url)
diff --git a/clinvar_export/urls.py b/clinvar_export/urls.py
index 66a2414c6..d6059c068 100644
--- a/clinvar_export/urls.py
+++ b/clinvar_export/urls.py
@@ -102,7 +102,7 @@
name="query-hpo-term",
),
url(
- regex=r"^ajax/(?P[0-9a-f-]+)/user-annotations/?$",
+ regex=r"^ajax/(?P[0-9a-f-]+)/user-annotations/(?P[0-9a-f-]+)/?$",
view=views_ajax.AnnotatedSmallVariantsApiView.as_view(),
name="user-annotations",
),
diff --git a/clinvar_export/views_ajax.py b/clinvar_export/views_ajax.py
index b0cd9f761..210291b7a 100644
--- a/clinvar_export/views_ajax.py
+++ b/clinvar_export/views_ajax.py
@@ -31,6 +31,7 @@
from variants.queries import SmallVariantUserAnnotationQuery
from .clinvar_xml import SubmissionXmlGenerator, XSD_URL_1_7
from .models import (
+ Case,
SubmissionSet,
Submission,
Organisation,
@@ -424,8 +425,9 @@ class AnnotatedSmallVariantsApiView(
permission_required = "clinvar_export.view_data"
allowed_methods = ("GET",)
- def get(self, *_args, **_kwargs):
+ def get(self, *_args, **kwargs):
+ family = Family.objects.get(project=self.get_project(), sodar_uuid=kwargs.get("family"))
serializer = AnnotatedSmallVariantsSerializer(
- SmallVariantUserAnnotationQuery(get_engine()).run(project=self.get_project())
+ SmallVariantUserAnnotationQuery(get_engine()).run(case=family.case)
)
return Response(serializer.data)
diff --git a/varfish/static/js/variant_validator.js b/varfish/static/js/variant_validator.js
index da554d0cb..e1c8a0284 100644
--- a/varfish/static/js/variant_validator.js
+++ b/varfish/static/js/variant_validator.js
@@ -4,7 +4,7 @@ function queryVariantValidatorApi(obj, release, chromosome, start, reference, al
let box = button.closest('.modal-content').find('.variant-validator-results');
button.attr('disabled', true);
icon.attr('src', '/icons/fa-solid/refresh.svg').addClass('spin');
- box.html('
');
+ box.html('
');
$.ajax({
type: 'POST',
url: variant_validator_url,
diff --git a/varfish/vueapp/src/api/clinvarExport.js b/varfish/vueapp/src/api/clinvarExport.js
index 27835a2a5..d768350bf 100644
--- a/varfish/vueapp/src/api/clinvarExport.js
+++ b/varfish/vueapp/src/api/clinvarExport.js
@@ -203,8 +203,8 @@ export default {
return await apiDelete('submitting_org', submittingOrg.sodar_uuid, appContext)
},
- async getUserAnnotations (appContext) {
- const response = await fetch(`${appContext.baseUrl}/user-annotations/`, {
+ async getUserAnnotations (appContext, familyUuid) {
+ const response = await fetch(`${appContext.baseUrl}/user-annotations/${familyUuid}`, {
method: 'GET',
credentials: 'same-origin',
headers: {
diff --git a/varfish/vueapp/src/components/SubmissionList.vue b/varfish/vueapp/src/components/SubmissionList.vue
index 7f78dceb9..9c39fcab1 100644
--- a/varfish/vueapp/src/components/SubmissionList.vue
+++ b/varfish/vueapp/src/components/SubmissionList.vue
@@ -47,12 +47,27 @@