Skip to content

Commit

Permalink
Merge pull request PGScatalog#284 from ens-lgil/feature/updates_oct23
Browse files Browse the repository at this point in the history
Feature/updates oct23
  • Loading branch information
ens-lgil authored Oct 10, 2023
2 parents 3015a05 + 11cdd87 commit c322094
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 54 deletions.
68 changes: 34 additions & 34 deletions catalog/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,40 +453,40 @@ class Meta:
template_name = 'catalog/pgs_catalog_django_table.html'


class Browse_SampleSetTable(tables.Table):
'''Table to browse SampleSets (PSS; used in PGS evaluations) in the PGS Catalog'''
sample_merged = Column_sample_merged(accessor='display_samples_for_table', verbose_name='Sample Numbers', orderable=False)
sample_ancestry = Column_ancestry(accessor='display_ancestry', verbose_name='Sample Ancestry', orderable=False)
sampleset = tables.Column(accessor='display_sampleset', verbose_name=format_html('PGS Sample Set ID<br /><span>(PSS)</span>'), orderable=False)
phenotyping_free = Column_shorten_text_content(accessor='phenotyping_free', verbose_name='Phenotype Definitions and Methods')
cohorts = Column_cohorts(accessor='cohorts', verbose_name='Cohort(s)')

class Meta:
model = Sample
attrs = {
"id": "sampleset_table",
"data-show-columns" : "true",
"data-page-size" : page_size,
"data-export-options" : '{"fileName": "pgs_samplesets_data"}'
}
fields = [
'sampleset',
'phenotyping_free',
'sample_merged',
'sample_ancestry','ancestry_additional',
'cohorts', 'cohorts_additional',
]

template_name = 'catalog/pgs_catalog_django_table.html'

def render_sampleset(self, value):
sampleset = f'<a href="/sampleset/{value.id}">{value.id}</a>'
if is_pgs_on_curation_site == 'True' and value.name:
sampleset += f' <div class="small">({value.name})</div>'
return format_html(sampleset)

def render_cohorts_additional(self, value):
return format_html('<span class="more">{}</span>', value)
# class Browse_SampleSetTable(tables.Table):
# '''Table to browse SampleSets (PSS; used in PGS evaluations) in the PGS Catalog'''
# sample_merged = Column_sample_merged(accessor='display_samples_for_table', verbose_name='Sample Numbers', orderable=False)
# sample_ancestry = Column_ancestry(accessor='display_ancestry', verbose_name='Sample Ancestry', orderable=False)
# sampleset = tables.Column(accessor='display_sampleset', verbose_name=format_html('PGS Sample Set ID<br /><span>(PSS)</span>'), orderable=False)
# phenotyping_free = Column_shorten_text_content(accessor='phenotyping_free', verbose_name='Phenotype Definitions and Methods')
# cohorts = Column_cohorts(accessor='cohorts', verbose_name='Cohort(s)')
#
# class Meta:
# model = Sample
# attrs = {
# "id": "sampleset_table",
# "data-show-columns" : "true",
# "data-page-size" : page_size,
# "data-export-options" : '{"fileName": "pgs_samplesets_data"}'
# }
# fields = [
# 'sampleset',
# 'phenotyping_free',
# 'sample_merged',
# 'sample_ancestry','ancestry_additional',
# 'cohorts', 'cohorts_additional',
# ]
#
# template_name = 'catalog/pgs_catalog_django_table.html'
#
# def render_sampleset(self, value):
# sampleset = f'<a href="/sampleset/{value.id}">{value.id}</a>'
# if is_pgs_on_curation_site == 'True' and value.name:
# sampleset += f' <div class="small">({value.name})</div>'
# return format_html(sampleset)
#
# def render_cohorts_additional(self, value):
# return format_html('<span class="more">{}</span>', value)


class SampleTable_variants(tables.Table):
Expand Down
2 changes: 1 addition & 1 deletion catalog/templates/catalog/includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<!-- Copyright -->
</footer>

{% if is_pgs_live_site %}
{% if is_pgs_live_site == 'True' %}
<!-- Google Analytics details... -->
<script type="text/javascript">!function(e,a,n,t,i,o,c){e.GoogleAnalyticsObject=i,e[i]=e[i]||function(){(e[i].q=e[i].q||[]).push(arguments)},e[i].l=1*new Date,o=a.createElement(n),c=a.getElementsByTagName(n)[0],o.async=1,o.src="//www.google-analytics.com/analytics.js",c.parentNode.insertBefore(o,c)}(window,document,"script",0,"ga"),ga("create","UA-145149243-1",{cookieDomain:"auto"}),ga("require","linkid","linkid.js"),ga("set","anonymizeIp",!0),ga("send","pageview");</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
Expand Down
5 changes: 3 additions & 2 deletions catalog/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ def test_urls(self):
'/browse/scores/',
'/browse/traits/',
'/browse/studies/',
'/browse/sample_set/',
# '/browse/sample_set/',
'/docs/',
'/docs/ancestry/',
'/downloads/',
'/latest_release/',
'/rest/',
'/robots.txt'
'/robots.txt',
'/search/'
]
self.url_response(urls, 200)

Expand Down
14 changes: 8 additions & 6 deletions catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ def browseby(request, view_selection):
'view_name': 'Pending Publications',
'table': table
}
elif view_selection == 'sample_set':
context['view_name'] = 'Sample Sets'
table = Browse_SampleSetTable(Sample.objects.defer(*pgs_defer['sample']).filter(sampleset__isnull=False).prefetch_related('sampleset', pgs_prefetch['cohorts']).order_by('sampleset__num'))
context['table'] = table
# elif view_selection == 'sample_set':
# context['view_name'] = 'Sample Sets'
# table = Browse_SampleSetTable(Sample.objects.defer(*pgs_defer['sample']).filter(sampleset__isnull=False).prefetch_related('sampleset', pgs_prefetch['cohorts']).order_by('sampleset__num'))
# context['table'] = table
elif view_selection == 'scores' :
score_only_attributes = ['id','name','trait_efo','trait_reported','variants_number','ancestries','license','publication__id','publication__date_publication','publication__journal','publication__firstauthor']
table = Browse_ScoreTable(Score.objects.only(*score_only_attributes).select_related('publication').all().order_by('num').prefetch_related(pgs_prefetch['trait']))
Expand Down Expand Up @@ -537,7 +537,7 @@ def efo(request, efo_id):
exclude_children = True

try:
ontology_trait = EFOTrait_Ontology.objects.prefetch_related('scores_direct_associations','scores_child_associations','child_traits').get(id__exact=efo_id)
ontology_trait = EFOTrait_Ontology.objects.prefetch_related('scores_direct_associations','scores_child_associations','child_traits','traitcategory').get(id__exact=efo_id)
except EFOTrait_Ontology.DoesNotExist:
raise Http404("Trait: \"{}\" does not exist".format(efo_id))

Expand All @@ -547,7 +547,9 @@ def efo(request, efo_id):
if exclude_children:
related_scores = related_direct_scores
else:
related_scores = list(related_direct_scores) + list(related_child_scores)
merged_related_scores = list(related_direct_scores) + list(related_child_scores)
# Remove potential duplicates (e.g. one of the trait is also a child of the second trait)
related_scores = list(set(merged_related_scores))
related_scores.sort(key=lambda x: x.id)

context = {
Expand Down
2 changes: 1 addition & 1 deletion pgs_web/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
re_path(r'^search/', search_views.search, name="PGS Catalog Search"),
re_path(r'^autocomplete/', search_views.autocomplete, name="PGS Catalog Autocomplete")
]
if settings.PGS_ON_CURATION_SITE == 'True':
if settings.PGS_ON_CURATION_SITE == True:
from django.contrib import admin
urlpatterns.append(path('admin/', admin.site.urls))
10 changes: 5 additions & 5 deletions release/scripts/shell/copy2ftp_and_update_write_access.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ else
# Update write access on FTP
echo "# Update write access on FTP"
cd ${ftp_dir}
find pgs_scores_list.txt -type f -exec chmod 664 {} +
find pgs_scores_list.txt -type f -exec chmod -f 664 {} +
echo " > pgs_scores_list.txt file - done"
find scores/ -type d -exec chmod 775 {} +
find scores/ -type d -exec chmod -f 775 {} +
echo " > scores directories - done"
find scores/ -type f -exec chmod 664 {} +
find scores/ -type f -exec chmod -f 664 {} +
echo " > scores files - done"
find metadata/ -type d -exec chmod 775 {} +
find metadata/ -type d -exec chmod -f 775 {} +
echo " > metadata directories - done"
find metadata/ -type f -exec chmod 664 {} +
find metadata/ -type f -exec chmod -f 664 {} +
echo " > metadata files - done"
else
echo "Directory '${local_data_dir}' can't be found"
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### Django library
Django==4.1.10
Django==4.1.11
#### Compress SCSS/SASS files in CSS
django-compressor==4.3
#### Library to build the HTML tables
Expand All @@ -10,6 +10,6 @@ psycopg2-binary==2.9.6
djangorestframework==3.14.0
django-cors-headers==3.13.0
#### Python & Django Elasticsearch libraries
elasticsearch==7.17.8
elasticsearch-dsl==7.4.0
django-elasticsearch-dsl==7.2.2
elasticsearch==7.17.9
elasticsearch-dsl==7.4.1
django-elasticsearch-dsl==7.3
2 changes: 1 addition & 1 deletion requirements_local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ google-cloud-storage==2.4.0
pandas==1.5.3

#### For webpage testing ####
django-debug-toolbar==3.8.1
django-debug-toolbar==4.2.0

0 comments on commit c322094

Please sign in to comment.