From 360954ff82c002da18e3c9b2756065c6f9718f0d Mon Sep 17 00:00:00 2001 From: Isaac Jandalala Date: Mon, 12 Jan 2026 14:59:42 +0000 Subject: [PATCH 1/7] Add Litsumm summaries to genes. --- rnacentral/portal/static/css/gene.css | 119 ++++++++++++++++++ .../gene-detail/gene-detail.component.js | 15 ++- .../gene-detail/gene-detail.module.js | 2 +- .../gene-detail/gene-detail.template.html | 17 +++ .../portal/templates/portal/gene_detail.html | 30 +++++ rnacentral/portal/views.py | 36 +++++- 6 files changed, 215 insertions(+), 4 deletions(-) diff --git a/rnacentral/portal/static/css/gene.css b/rnacentral/portal/static/css/gene.css index 748f2350d..99aa3ae81 100644 --- a/rnacentral/portal/static/css/gene.css +++ b/rnacentral/portal/static/css/gene.css @@ -595,4 +595,123 @@ text-decoration: none; font-size: 0.9rem; padding: 0.5rem 0.75rem; } +} + +/* LitSumm Carousel Section */ +.gene__litsumm-section { + background: #f8f9fa; + padding: 1.5rem 0; + border-bottom: 1px solid #e9ecef; + overflow: visible; +} + +.gene__litsumm-header { + text-align: center; + margin-bottom: 1rem; +} + +.gene__litsumm-title { + font-size: 1.5rem; + font-weight: 600; + color: #2c3e50; + margin-bottom: 0.25rem; + margin-top: 0; +} + +.gene__litsumm-subtitle span { + color: #BF8E3E; +} + +.gene__litsumm-caution { + color: #8a6d3b; + background-color: #fcf8e3; + border-color: #faebcc; + padding: 15px; + border-radius: 4px; + margin-block-end: 20px; +} + +.gene__litsumm-caution a { + color: #3498db; + text-decoration: none; +} + +.gene__litsumm-caution a:hover { + text-decoration: underline; +} + +.gene__litsumm-carousel { + margin: 0 auto; + padding: 0 40px; + position: relative; +} + +.gene__litsumm-panel { + padding: 20px; + margin: 0 0.5rem; + cursor: pointer; + transition: transform 0.2s ease, box-shadow 0.2s ease; + border-radius: 8px; +} + +.gene__litsumm-panel:hover { + box-shadow: 0 4px 12px rgba(0,0,0,0.15); +} + +.gene__litsumm-id { + margin: 0 0 10px 0; + font-size: 18px; + font-weight: 500; +} + +.gene__litsumm-summary { + font-size: 14px; + line-height: 1.6; + color: #333; + margin: 0; +} + +.gene__litsumm-summary a { + color: #3498db; + text-decoration: none; +} + +.gene__litsumm-summary a:hover { + text-decoration: underline; +} + +/* Slick carousel overrides for litsumm */ +.gene__litsumm-carousel .slick-prev { + left: 0; +} + +.gene__litsumm-carousel .slick-next { + right: 0; +} + +.gene__litsumm-carousel .slick-prev:before, +.gene__litsumm-carousel .slick-next:before { + color: #9e9e9e; +} + +.gene__litsumm-carousel .slick-dots { + bottom: -30px; +} + +.gene__litsumm-carousel .slick-dots li button:before { + color: #3498db; +} + +@media (max-width: 768px) { + .gene__litsumm-section { + padding: 1rem 0; + } + + .gene__litsumm-title { + font-size: 1.25rem; + } + + .gene__litsumm-panel { + padding: 1rem; + } } \ No newline at end of file diff --git a/rnacentral/portal/static/js/components/gene-detail/gene-detail.component.js b/rnacentral/portal/static/js/components/gene-detail/gene-detail.component.js index 1dde6bcd4..ae8959ffc 100644 --- a/rnacentral/portal/static/js/components/gene-detail/gene-detail.component.js +++ b/rnacentral/portal/static/js/components/gene-detail/gene-detail.component.js @@ -9,7 +9,7 @@ var geneDetail = { geneFound: '@?' }, controllerAs: 'vm', - controller: ['$timeout', '$element', '$scope', '$http', function($timeout, $element, $scope, $http) { + controller: ['$timeout', '$element', '$scope', '$http', '$sce', function($timeout, $element, $scope, $http, $sce) { var vm = this; // State management @@ -49,6 +49,7 @@ var geneDetail = { vm.transcripts = []; vm.externalLinks = []; + vm.litsummSummaries = []; vm.$onInit = function() { @@ -70,10 +71,20 @@ var geneDetail = { if (globalData.geneData) { processGeneData(globalData.geneData); - // Set transcripts and external links from global data + // Set transcripts, external links, and litsumm summaries from global data vm.transcripts = globalData.transcriptsData || []; vm.externalLinks = globalData.externalLinksData || []; + // Process litsumm summaries and trust HTML content + var rawSummaries = globalData.litsummSummaries || []; + vm.litsummSummaries = rawSummaries.map(function(item) { + return { + id: item.id, + urs: item.urs, + summary: $sce.trustAsHtml(item.summary) + }; + }); + // parse urs and taxid for each transcript if(vm.transcripts && vm.transcripts.length > 0) { diff --git a/rnacentral/portal/static/js/components/gene-detail/gene-detail.module.js b/rnacentral/portal/static/js/components/gene-detail/gene-detail.module.js index 316f90d96..85ac3339f 100644 --- a/rnacentral/portal/static/js/components/gene-detail/gene-detail.module.js +++ b/rnacentral/portal/static/js/components/gene-detail/gene-detail.module.js @@ -1,5 +1,5 @@ (function() { 'use strict'; - angular.module('geneDetail', []); + angular.module('geneDetail', ['ngSanitize']); })(); \ No newline at end of file diff --git a/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html b/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html index 12b064e63..6c451f9ab 100644 --- a/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html +++ b/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html @@ -45,6 +45,23 @@

Gene Summary

+
+
+
+

{{ vm.litsummSummaries[0].urs }} - {{vm.geneData.summary}}

+

+ Caution, this is an AI generated summary based on literature. This may have errors, see here for more. Please share your feedback with us. +

+
+ +
+
+
diff --git a/rnacentral/portal/templates/portal/gene_detail.html b/rnacentral/portal/templates/portal/gene_detail.html index 889383fee..fe0b3329b 100644 --- a/rnacentral/portal/templates/portal/gene_detail.html +++ b/rnacentral/portal/templates/portal/gene_detail.html @@ -34,7 +34,37 @@

Gene Not Found

transcriptsData: {{ transcriptsData|safe }}, externalLinksData: {{ externalLinksData|safe }}, transcriptsPagination: {{ transcriptsPagination|safe }}, + litsummSummaries: {{ litsummSummaries|safe }}, geneFound: {{ geneFound|yesno:'true,false' }} }; + +// Initialize litsumm carousel after AngularJS renders the content +$(document).ready(function() { + var litsummData = window.geneDetailData.litsummSummaries || []; + if (litsummData.length > 1) { + // Wait for AngularJS to render the carousel items + var initCarousel = function() { + var $carousel = $('#gene-litsumm-carousel'); + var itemCount = $carousel.children('.gene__litsumm-panel').length; + + if (itemCount >= litsummData.length && !$carousel.hasClass('slick-initialized')) { + $carousel.slick({ + draggable: true, + rows: 1, + dots: true, + infinite: true, + lazyLoad: 'ondemand', + slidesToShow: 1, + slidesToScroll: 1, + arrows: true + }); + } else if (itemCount < litsummData.length) { + // Retry if items not yet rendered + setTimeout(initCarousel, 100); + } + }; + setTimeout(initCarousel, 500); + } +}); {% endblock %} \ No newline at end of file diff --git a/rnacentral/portal/views.py b/rnacentral/portal/views.py index 73eec3626..c0e44f134 100644 --- a/rnacentral/portal/views.py +++ b/rnacentral/portal/views.py @@ -504,6 +504,7 @@ def gene_detail(request, name): "transcriptsData": [], "externalLinksData": [], "transcriptsPagination": {}, + "litsummSummaries": [], }) metadata = getattr(gene, "metadata", None) @@ -586,9 +587,41 @@ def gene_detail(request, name): } - # External links data + # External links data external_links_data = [] + # Fetch litsumm summaries for all transcripts of this gene + litsumm_summaries_data = [] + + # Get all transcript IDs for this gene (not just current page) + all_transcript_ids = [] + with connection.cursor() as cursor: + cursor.execute(""" + SELECT DISTINCT locus.urs_taxid + FROM rnc_gene_members gm + JOIN rnc_genes g ON(gm.rnc_gene_id=g.id) + JOIN rnc_sequence_regions locus ON locus.id = gm.locus_id + WHERE g.public_name = %s + """, [gene.name]) + all_transcript_ids = [row[0] for row in cursor.fetchall()] + + if all_transcript_ids: + # Get all litsumm summaries for transcripts of this gene + litsumm_records = LitSumm.objects.filter(primary_id__in=all_transcript_ids) + pmc_regex = re.compile(r"PMC[0-9]+") + + for record in litsumm_records: + # Convert PMC IDs to links + summary_with_links = pmc_regex.sub( + r'\g<0>', + record.summary, + ) + litsumm_summaries_data.append({ + "id": record.display_id, + "urs": record.primary_id, + "summary": summary_with_links, + }) + return render(request, "portal/gene_detail.html", { "geneName": base_name, "geneVersion": version, @@ -597,6 +630,7 @@ def gene_detail(request, name): 'transcriptsData': json.dumps(transcripts_data), 'externalLinksData': json.dumps(external_links_data), 'transcriptsPagination': json.dumps(pagination), + 'litsummSummaries': json.dumps(litsumm_summaries_data), }) From 082306d8ad0a280cd5637c69f00f6a10e2fd16be Mon Sep 17 00:00:00 2001 From: Isaac Jandalala Date: Mon, 12 Jan 2026 16:29:34 +0000 Subject: [PATCH 2/7] Move subtitle inside panel. --- rnacentral/portal/static/css/gene.css | 10 ++++++++-- .../components/gene-detail/gene-detail.template.html | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rnacentral/portal/static/css/gene.css b/rnacentral/portal/static/css/gene.css index 99aa3ae81..801901536 100644 --- a/rnacentral/portal/static/css/gene.css +++ b/rnacentral/portal/static/css/gene.css @@ -617,9 +617,15 @@ text-decoration: none; margin-bottom: 0.25rem; margin-top: 0; } - +.gene__litsumm-subtitle { + padding-inline: 10px; + padding-block-end: 20px; + margin: 0; +} .gene__litsumm-subtitle span { - color: #BF8E3E; + color: rgb(38, 183, 231); + font-size: 1.4rem; + font-weight: bold; } .gene__litsumm-caution { diff --git a/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html b/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html index 6c451f9ab..0a07dab00 100644 --- a/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html +++ b/rnacentral/portal/static/js/components/gene-detail/gene-detail.template.html @@ -48,7 +48,6 @@

Gene Summary

-

{{ vm.litsummSummaries[0].urs }} - {{vm.geneData.summary}}

Caution, this is an AI generated summary based on literature. This may have errors, see here for more. Please share your feedback with us.

@@ -56,6 +55,10 @@

{{ vm.litsummSummaries[0].urs }} - {{vm From 6fccc70ee33095cd8775312e960c56e4aada8073 Mon Sep 17 00:00:00 2001 From: Isaac Jandalala Date: Mon, 12 Jan 2026 16:35:08 +0000 Subject: [PATCH 3/7] Refactor gene widget. --- rnacentral/portal/static/css/gene.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/rnacentral/portal/static/css/gene.css b/rnacentral/portal/static/css/gene.css index 801901536..6af015f12 100644 --- a/rnacentral/portal/static/css/gene.css +++ b/rnacentral/portal/static/css/gene.css @@ -115,8 +115,6 @@ border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); - border-left: 4px solid #3498db; } .gene__widget-header { From 5d371aab8a01fe9bb9c15000cf803290e3c90020 Mon Sep 17 00:00:00 2001 From: Isaac Jandalala Date: Tue, 13 Jan 2026 15:17:37 +0000 Subject: [PATCH 4/7] Refactor transcripts query. --- rnacentral/portal/views.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/rnacentral/portal/views.py b/rnacentral/portal/views.py index c0e44f134..572fafbd6 100644 --- a/rnacentral/portal/views.py +++ b/rnacentral/portal/views.py @@ -593,32 +593,34 @@ def gene_detail(request, name): # Fetch litsumm summaries for all transcripts of this gene litsumm_summaries_data = [] - # Get all transcript IDs for this gene (not just current page) - all_transcript_ids = [] + # Get all litsumm summaries for transcripts of this gene with connection.cursor() as cursor: cursor.execute(""" - SELECT DISTINCT locus.urs_taxid + SELECT ls.primary_id, ls.display_id, ls.summary FROM rnc_gene_members gm - JOIN rnc_genes g ON(gm.rnc_gene_id=g.id) + JOIN rnc_genes g ON gm.rnc_gene_id = g.id JOIN rnc_sequence_regions locus ON locus.id = gm.locus_id + JOIN litsumm_summaries ls ON ls.primary_id = locus.urs_taxid WHERE g.public_name = %s """, [gene.name]) - all_transcript_ids = [row[0] for row in cursor.fetchall()] + rows = cursor.fetchall() - if all_transcript_ids: - # Get all litsumm summaries for transcripts of this gene - litsumm_records = LitSumm.objects.filter(primary_id__in=all_transcript_ids) pmc_regex = re.compile(r"PMC[0-9]+") - - for record in litsumm_records: + seen_ids = set() + for row in rows: + primary_id, display_id, summary = row + # Skip duplicates + if primary_id in seen_ids: + continue + seen_ids.add(primary_id) # Convert PMC IDs to links summary_with_links = pmc_regex.sub( r'\g<0>', - record.summary, + summary, ) litsumm_summaries_data.append({ - "id": record.display_id, - "urs": record.primary_id, + "id": display_id, + "urs": primary_id, "summary": summary_with_links, }) From aeb79fb57437c2d6969b0c455051835294eebdc8 Mon Sep 17 00:00:00 2001 From: Isaac Jandalala Date: Tue, 13 Jan 2026 16:19:47 +0000 Subject: [PATCH 5/7] Fix carousel for genes with multiple summaries. --- rnacentral/portal/static/css/gene.css | 28 ++++++++++++++ .../portal/templates/portal/gene_detail.html | 38 +++++++++++-------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/rnacentral/portal/static/css/gene.css b/rnacentral/portal/static/css/gene.css index 6af015f12..c4c9ebe43 100644 --- a/rnacentral/portal/static/css/gene.css +++ b/rnacentral/portal/static/css/gene.css @@ -685,6 +685,26 @@ text-decoration: none; } /* Slick carousel overrides for litsumm */ +.gene__litsumm-carousel .slick-list { + overflow: hidden; +} + +.gene__litsumm-carousel .slick-track { + display: flex; + align-items: stretch; +} + +.gene__litsumm-carousel .slick-slide { + visibility: hidden; + opacity: 0; + transition: opacity 0.3s ease; +} + +.gene__litsumm-carousel .slick-slide.slick-active { + visibility: visible; + opacity: 1; +} + .gene__litsumm-carousel .slick-prev { left: 0; } @@ -698,6 +718,14 @@ text-decoration: none; color: #9e9e9e; } +.gene__litsumm-carousel .slick-disabled { + cursor:not-allowed; +} + +.gene__litsumm-carousel .slick-disabled:before { + opacity: 0.25; +} + .gene__litsumm-carousel .slick-dots { bottom: -30px; } diff --git a/rnacentral/portal/templates/portal/gene_detail.html b/rnacentral/portal/templates/portal/gene_detail.html index fe0b3329b..5f27d83c8 100644 --- a/rnacentral/portal/templates/portal/gene_detail.html +++ b/rnacentral/portal/templates/portal/gene_detail.html @@ -37,32 +37,38 @@

Gene Not Found

litsummSummaries: {{ litsummSummaries|safe }}, geneFound: {{ geneFound|yesno:'true,false' }} }; + +{% endblock %} -// Initialize litsumm carousel after AngularJS renders the content +{% block extra_js_uncompressed %} +