Skip to content

Commit

Permalink
fix: annotated sv not listed in case annotations (#2015)
Browse files Browse the repository at this point in the history
  • Loading branch information
stolpeo committed Oct 15, 2024
1 parent edcc966 commit 896c550
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
20 changes: 14 additions & 6 deletions backend/svs/views/ajax/user_annos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from iterable_orm import QuerySet
from projectroles.views_api import SODARAPIGenericProjectMixin, SODARAPIProjectPermission
from rest_framework.exceptions import ValidationError
from rest_framework.generics import ListAPIView, ListCreateAPIView, RetrieveUpdateDestroyAPIView

from svs.models import StructuralVariantComment, StructuralVariantFlags, SvQueryResultRow
Expand Down Expand Up @@ -142,12 +143,15 @@ def get_queryset(self):
return qs

def perform_create(self, serializer):
if not self.request.data.get("sodar_uuid"):
raise ValidationError(
detail={
"error": "`sodar_uuid` of SvQueryResultRow required. Aborting flag creation."
}
)
super().perform_create(serializer)
case = Case.objects.get(sodar_uuid=self.kwargs["case"])

if not self.request.data.get("sodar_uuid"):
return

result_row = SvQueryResultRow.objects.get(sodar_uuid=self.request.data.get("sodar_uuid"))
result_set = case.svqueryresultset_set.filter(svquery=None).first()
try:
Expand Down Expand Up @@ -277,12 +281,16 @@ def get_queryset(self):
return qs

def perform_create(self, serializer):
if not self.request.data.get("sodar_uuid"):
raise ValidationError(
detail={
"error": "`sodar_uuid` of SvQueryResultRow required. Aborting comment creation."
}
)

super().perform_create(serializer)
case = Case.objects.get(sodar_uuid=self.kwargs["case"])

if not self.request.data.get("sodar_uuid"):
return

result_row = SvQueryResultRow.objects.get(sodar_uuid=self.request.data.get("sodar_uuid"))
result_set = case.svqueryresultset_set.filter(svquery=None).first()
try:
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/svs/components/SvFilterResultsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,12 @@ watch(
<!-- comments -->
<i-fa-solid-comment
v-if="
svCommentsStore.hasComment({ chromosome, start, end, sv_type })
svCommentsStore.hasComment({
chrom: chromosome,
start: start,
stop: end,
svType: sv_type,
})
"
:class="`${svCommentsStore.hasProjectWideComments({ chromosome, start, end, sv_type }) ? 'text-warning' : 'text-muted'} ml-1`"
role="button"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/svs/stores/strucvarFlags/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const useSvFlagsStore = defineStore('svFlags', () => {
const createFlags = async (
strucvar: Strucvar,
payload: StructuralVariantFlags,
resultRowUuid: string,
): Promise<StructuralVariantFlags> => {
const svClient = new SvClient(ctxStore.csrfToken)
// Throw error if case UUID has not been set.
Expand Down Expand Up @@ -212,6 +213,7 @@ export const useSvFlagsStore = defineStore('svFlags', () => {
end,
sv_type: strucvar.svType,
sv_sub_type: strucvar.svType,
sodar_uuid: resultRowUuid,
},
...payload,
})
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/svs/stores/svComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const useSvCommentsStore = defineStore('svComments', () => {
const createComment = async (
strucvar: Strucvar,
text: string,
resultRowUuid: string,
): Promise<Strucvar> => {
const svClient = new SvClient(ctxStore.csrfToken)
// Error if case UUID is unset.
Expand Down Expand Up @@ -186,6 +187,7 @@ export const useSvCommentsStore = defineStore('svComments', () => {
end,
sv_type: strucvar.svType,
sv_sub_type: strucvar.svType,
sodar_uuid: resultRowUuid,
},
text,
})
Expand Down

0 comments on commit 896c550

Please sign in to comment.