Skip to content

Commit

Permalink
#1243 - HGNC search + link to gene symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Jan 30, 2025
1 parent 50b22cc commit 6b4720a
Showing 5 changed files with 15 additions and 3 deletions.
11 changes: 11 additions & 0 deletions ontology/models/models_ontology.py
Original file line number Diff line number Diff line change
@@ -529,7 +529,18 @@ def padded_index(self) -> str:
def external_url(self):
return OntologyService.URLS[self.ontology_service].replace("${1}", self.padded_index)

def gene_symbol_url(self) -> Optional[str]:
""" Only for HGNC, get link to gene_symbol """
url = None
if self.ontology_service == OntologyService.HGNC:
if gene_symbol := GeneSymbol.cast(self.name):
url = gene_symbol.get_absolute_url()
return url

def get_absolute_url(self):
if settings.ONTOLOGY_HGNC_REDIRECT_TO_GENE_SYMBOL:
if url := self.gene_symbol_url():
return url
return reverse('ontology_term', kwargs={"term": self.url_safe_id})

@property
1 change: 0 additions & 1 deletion ontology/models/ontology_search.py
Original file line number Diff line number Diff line change
@@ -57,7 +57,6 @@ def ontology_search_id(search_input: SearchInputInstance):
search_type=OntologyTerm,
pattern=re.compile(r"^HGNC\s*:\s*(.*)$", re.IGNORECASE),
sub_name="Gene Disease Relationships",
admin_only=True,
example=SearchExample(
note="HGNC: followed by an ID or gene symbol",
examples=["HGNC:BRCA1", "HGNC:4171"]
3 changes: 1 addition & 2 deletions ontology/views.py
Original file line number Diff line number Diff line change
@@ -47,8 +47,7 @@ def get_context_data(self, **kwargs):
term_link = None

if is_gene:
if gene_symbol := GeneSymbol.cast(term.name):
term_link = gene_symbol.get_absolute_url()
term_link = term.gene_symbol_url()
else:
regular_relationships = []
all_relationships: list[OntologyTermRelation] = OntologyTermRelation.relations_of(term)
1 change: 1 addition & 0 deletions variantgrid/settings/components/default_settings.py
Original file line number Diff line number Diff line change
@@ -361,6 +361,7 @@
"""

ONTOLOGY_EXTERNAL_LINKS = False # Generate external or internal links for ontology terms
ONTOLOGY_HGNC_REDIRECT_TO_GENE_SYMBOL = False

PATHOLOGY_TESTS_ENABLED = False
PATHOLOGY_TEST_REQUESTS_REDIRECT_URL = None
2 changes: 2 additions & 0 deletions variantgrid/settings/env/shariantcommon.py
Original file line number Diff line number Diff line change
@@ -129,6 +129,8 @@
LOGIN_REDIRECT_URL = '/classification/dashboard'
LOGO_VIEW_NAME = "classification_dashboard"

ONTOLOGY_HGNC_REDIRECT_TO_GENE_SYMBOL = True

SHARIANT_STATIC_FILES_DIR = os.path.join(VARIANTGRID_APP_DIR, "static_files", "shariant_static")
STATICFILES_DIRS = (SHARIANT_STATIC_FILES_DIR,) + STATICFILES_DIRS

0 comments on commit 6b4720a

Please sign in to comment.