Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClinVar Records Expert Panels / Allele UI tidy #862

Merged
merged 45 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7b7ae35
Show ClinVar details on allele apge at all times
TheMadBug Jul 28, 2023
feef42c
Migrate clinvar display code to clinvar_tag
TheMadBug Jul 28, 2023
4b6be6b
Tidy up presentation of clinvar_tag
TheMadBug Jul 28, 2023
7d1bb73
Display XML (unformatted) of ClinVar data
TheMadBug Jul 28, 2023
3a3abd9
Start parsing the XML of the CLinVar URLs to get the specific classif…
TheMadBug Jul 30, 2023
7d680c7
Change most of the ClinVar data to be ajax loaded in detail from Clinvar
TheMadBug Jul 31, 2023
1174e91
Fix my config file re new fasta
TheMadBug Jul 31, 2023
a82f209
Merge branch 'refs/heads/master' into feature/clinvar_xml_import
TheMadBug Jul 31, 2023
1946023
ClinVar display: Load all relevant RCVs, better display
TheMadBug Aug 1, 2023
9d12aa1
Use proper Entrez for fetching ClinVar data
TheMadBug Aug 1, 2023
b2de142
ClinVarIn: Fix orphanet conditions, sort order
TheMadBug Aug 1, 2023
4d96eb1
ClinVarExpertPanel: Only show records when user toggles
TheMadBug Aug 1, 2023
e16f9c7
Have the clinvar_tag work in expert panel mode or normal mode
TheMadBug Aug 3, 2023
36bc315
Fixed issue where only expert panels were being retrieved regardless …
TheMadBug Aug 3, 2023
a238004
Merge branch 'refs/heads/master' into feature/clinvar_xml_import
TheMadBug Aug 4, 2023
9f72d0a
ClinVarRecords: Cache individual records
TheMadBug Aug 4, 2023
2a5f427
Provide expert panel compare export (admin only for now)
TheMadBug Aug 7, 2023
7f5813a
Merge branch 'refs/heads/master' into feature/clinvar_xml_import
TheMadBug Aug 7, 2023
8bbd36a
Slight improvements to ClinVar Admin Screen
TheMadBug Aug 7, 2023
512ec82
Merge branch 'refs/heads/master' into feature/clinvar_xml_import
TheMadBug Aug 7, 2023
966cd42
Update re-match testing code
TheMadBug Aug 8, 2023
906bf65
Make imported allele info comprae print as it goes
TheMadBug Aug 8, 2023
58d6354
Clinvar XML Parser - handle dates with timezones in them
TheMadBug Aug 8, 2023
a79687a
Remove unused imports
TheMadBug Aug 8, 2023
4a8bd63
Better admin screens for ClinVar data
TheMadBug Aug 8, 2023
be944c1
Put a retry in retrieving ClinVar records
TheMadBug Aug 8, 2023
fcbf9ad
Tidy up display on allele page
TheMadBug Aug 10, 2023
6d9fd2d
View allele UI fixes (removing old code)
TheMadBug Aug 10, 2023
f925d22
Merge branch 'refs/heads/master' into feature/allele_tidy_2
TheMadBug Aug 10, 2023
b3be370
Tidy up ClinVar Expert Panels a little
TheMadBug Aug 10, 2023
b3aca4b
Fix the style of some links
TheMadBug Aug 10, 2023
df8180d
Allele page: Don't show g.HGVS, renamed Resolved From to Imported As
TheMadBug Aug 11, 2023
4f0f10b
Allele page - fix font size of table to be more readable
TheMadBug Aug 11, 2023
7f8a92d
ClinVar Expert Panels - tidy up/comment code
TheMadBug Aug 11, 2023
467a45b
Merge branch 'refs/heads/master' into feature/allele_tidy_2
TheMadBug Aug 13, 2023
c920fe8
ClinVar Records: comment code, delete dead code
TheMadBug Aug 13, 2023
95b9835
Merge branch 'refs/heads/master' into feature/allele_tidy_2
TheMadBug Aug 14, 2023
4e9134e
Remove links to allele/ClinVar in ClinVar admin as just too database …
TheMadBug Aug 14, 2023
19e095c
Merge branch 'refs/heads/master' into feature/allele_tidy_2
TheMadBug Aug 15, 2023
6a67f21
ClinVarRecords - simplify code by removing min_stars on caching
TheMadBug Aug 15, 2023
97cd9ee
Allele page - tidy up, g.HGVS, allele infos
TheMadBug Aug 15, 2023
e8ad556
Remove dead code
TheMadBug Aug 15, 2023
4084b6a
Fix sort order of Imported Allele Infos
TheMadBug Aug 15, 2023
6a347a0
Link externally for ontology terms we don't store
TheMadBug Aug 15, 2023
0e22e70
Display ClinVar record curated date rather than updated date
TheMadBug Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 83 additions & 3 deletions annotation/admin.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,97 @@
from datetime import timedelta

from django.contrib import admin
from django.contrib.admin import TabularInline
from django.db.models import QuerySet
from django.utils.safestring import SafeString

from annotation import models
from annotation.models import Citation, CitationFetchRequest
from snpdb.admin_utils import ModelAdminBasics, admin_action
from annotation.clinvar_xml_parser import ClinVarFetchRequest, CLINVAR_RECORD_CACHE_DAYS
from annotation.models import Citation, CitationFetchRequest, ClinVarRecordCollection, ClinVarRecord, VariantAnnotation, \
ClinVar
from snpdb.admin_utils import ModelAdminBasics, admin_action, admin_list_column, get_admin_url
from snpdb.models import VariantAllele

admin.site.register(models.AnnotationRun)
admin.site.register(models.AnnotationVersion)
admin.site.register(models.ClinVar)
admin.site.register(models.VariantAnnotationVersion)


@admin.register(ClinVar)
class ClinVarAdmin(ModelAdminBasics):

list_display = ("pk", "version", "clinvar_variation_id", "variant", "clinvar_review_status")

def has_change_permission(self, request, obj=None):
return False

def has_add_permission(self, request):
return False


class ClinVarRecordAdmin(TabularInline):
model = ClinVarRecord

fields = ("record_id", "submitter", "stars", "date_last_evaluated", "clinical_significance")

def has_change_permission(self, request, obj=None):
return False

def has_add_permission(self, request, obj=None):
return False


@admin.register(ClinVarRecordCollection)
class ClinVarRecordCollectionAdmin(ModelAdminBasics):
inlines = (ClinVarRecordAdmin, )
list_per_page = 20

list_display = ("pk", "clinvar_variation_id", "last_loaded")

"""
# these took prohibitively long to load

@admin_list_column(limit=0)
def clinvar(self, obj: ClinVarRecordCollection):
try:
clinvar = ClinVar.objects.filter(clinvar_variation_id=obj.clinvar_variation_id).order_by('-version').first()
href = get_admin_url(clinvar)
return SafeString(f"<a href=\"{href}\">{clinvar.clinvar_variation_id}</a>")
except Exception as ex:
return str(ex)

@admin_list_column(limit=0)
def allele(self, obj: ClinVarRecordCollection):
try:
allele = ClinVar.objects.filter(clinvar_variation_id=obj.clinvar_variation_id).order_by('-version').first().variant.allele
href = get_admin_url(allele)
return SafeString(f"<a href=\"{href}\">{allele}</a>")
except Exception as ex:
return str(ex)
"""

def has_change_permission(self, request, obj=None):
return False

def has_add_permission(self, request):
return False

@admin_action(f"Refresh: If Older than {CLINVAR_RECORD_CACHE_DAYS} days")
def refresh_old(self, request, queryset: QuerySet[ClinVarRecordCollection]):
for obj in queryset:
ClinVarFetchRequest(
clinvar_variation_id=obj.clinvar_variation_id,
).fetch()

@admin_action("Refresh: Force")
def refresh_force(self, request, queryset: QuerySet[ClinVarRecordCollection]):
for obj in queryset:
ClinVarFetchRequest(
clinvar_variation_id=obj.clinvar_variation_id,
max_cache_age=timedelta(seconds=0)
).fetch()


class HasErrorFilter(admin.SimpleListFilter):
title = "Has Errors"
parameter_name = "error_mode"
Expand Down
Loading
Loading