Skip to content

Commit

Permalink
Code enhancements
Browse files Browse the repository at this point in the history
- Made all the secondary tables AJAX
- Implemented column showing/hiding
  • Loading branch information
adsilb committed Aug 27, 2021
1 parent 8ec955d commit 6f997f1
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 171 deletions.
Binary file modified search/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified search/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified search/__pycache__/views.cpython-39.pyc
Binary file not shown.
12 changes: 12 additions & 0 deletions search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ class Meta:
managed = False
db_table = 'vw_DrugTargets'

class vwDiseases(models.Model):
hgnc_id = models.TextField(db_column='HGNC_ID', primary_key=True)
gene_symbol = models.TextField(db_column='gene_symbol')
disease_name = models.TextField(db_column='condition')
concept_id = models.TextField(db_column='concept_id')
disease_id = models.TextField(db_column='disease_id')
source = models.TextField(db_column='Source')

class Meta:
managed = False
db_table = 'vw_Diseases'

class vwGeneInfo(models.Model):
gene_symbol = models.TextField(db_column='gene_symbol')
approved_name = models.TextField(db_column='approved_name')
Expand Down
459 changes: 293 additions & 166 deletions search/templates/search/index.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion search/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.urls import path

from django.conf.urls import url
from . import views

app_name='search'
urlpatterns = [
path('', views.index, name='index'),
url(r'^ajax/gene_details/$', views.gene_details, name='gene_details')
]
21 changes: 17 additions & 4 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from django.urls import reverse
from django.views import generic
from django.http import HttpResponse
from django.http import JsonResponse

from search.models import vwGeneInfo, vwDrugTargets, vwProteinInteractions
from search.models import vwGeneInfo, vwDrugTargets, vwDiseases, vwProteinInteractions

def index(request):
# print("genelist:", genelist)
Expand All @@ -12,7 +13,7 @@ def index(request):

genelist = []
if search_terms != None:
gene_symbols = search_terms.split('\r\n')
gene_symbols = search_terms.upper().split('\r\n')
for gene_symbol in gene_symbols:
match = vwGeneInfo.objects.filter(gene_symbol = gene_symbol)
if len(match) == 1:
Expand All @@ -23,18 +24,30 @@ def index(request):

return render(request, 'search/index.html', context)

def gene_details(request):
symbol = request.GET.get('gene_symbol')
data = {
'drug_targets': list(vwDrugTargets.objects.filter(gene_symbol = symbol).values()),
'diseases': list(vwDiseases.objects.filter(gene_symbol = symbol).values()),
'protein_interactions': list(vwProteinInteractions.objects.filter(geneSymbol1 = symbol).values())
}

return JsonResponse(data)


class SearchResult:

hgnc_id = None
gene_symbol = None
gene_info = None
drug_targets = None
diseases = None
protein_interactions = None

def __init__(self, gene_info_record):
self.hgnc_id = gene_info_record.hgnc_id
self.gene_symbol = gene_info_record.gene_symbol
self.gene_info = gene_info_record
self.drug_targets = vwDrugTargets.objects.filter(gene_symbol = self.gene_symbol)
self.protein_interactions = vwProteinInteractions.objects.filter(geneSymbol1 = self.gene_symbol)
# self.drug_targets = vwDrugTargets.objects.filter(gene_symbol = self.gene_symbol)
# self.diseases = vwDiseases.objects.filter(gene_symbol = self.gene_symbol)
# self.protein_interactions = vwProteinInteractions.objects.filter(geneSymbol1 = self.gene_symbol)

0 comments on commit 6f997f1

Please sign in to comment.