From 0cf9ca406c71d268860171d7fef20867af8b8581 Mon Sep 17 00:00:00 2001 From: adkinsrs Date: Thu, 30 Nov 2023 14:18:41 -0500 Subject: [PATCH] fixing bugs, changing gene list previews. refactoring --- www/cgi/get_unweighted_gene_cart_preview.cgi | 59 +++ www/cgi/get_weighted_gene_cart_preview.cgi | 10 +- www/css/common.v2.css | 12 +- www/css/compare_datasets.v2.css | 8 - www/css/curator_common.css | 8 - www/css/gene_collection_manager.css | 9 - www/css/user_profile.v2.css | 8 - www/gene_collection_manager.html | 6 +- www/js/common.v2.js | 50 ++ www/js/compare_datasets.v2.js | 39 -- www/js/curator_common.js | 44 -- www/js/gene_collection_manager.js | 499 ++++++++++--------- www/js/user_profile.v2.js | 44 -- 13 files changed, 404 insertions(+), 392 deletions(-) create mode 100755 www/cgi/get_unweighted_gene_cart_preview.cgi diff --git a/www/cgi/get_unweighted_gene_cart_preview.cgi b/www/cgi/get_unweighted_gene_cart_preview.cgi new file mode 100755 index 00000000..2075c6bf --- /dev/null +++ b/www/cgi/get_unweighted_gene_cart_preview.cgi @@ -0,0 +1,59 @@ +#!/opt/bin/python3 + +""" + +""" + +import cgi +import json +import os +import string +import sys + +lib_path = os.path.abspath(os.path.join('..', '..', 'lib')) +sys.path.append(lib_path) +import geardb + +def main(): + print('Content-Type: application/json\n\n') + + form = cgi.FieldStorage() + share_id = form.getvalue('share_id') + valid_chars = "%s%s" % (string.ascii_letters, string.digits) + share_id = ''.join(c for c in share_id if c in valid_chars) + + result = { 'success': 0 } + + # Get genes from the gene cart + if not share_id: + result['message'] = 'No share ID provided' + result["success"] = 0 + print(json.dumps(result)) + return + + gene_cart = geardb.get_gene_cart_by_share_id(share_id) + if not gene_cart: + result['message'] = 'Invalid share ID' + result["success"] = 0 + print(json.dumps(result)) + return + + genes = gene_cart.genes + organism_id = gene_cart.organism_id + + # Get the Gene objects for this gene cart + gene_collection = geardb.GeneCollection() + gene_collection.get_by_gene_symbol(gene_symbol=' '.join(genes), organism_id=organism_id, exact=True) + + + gene_dict = {} # Key is ensembl ID, value is dict of gene symbol and product. + # Create an dict of gene symbol to gene object + for gene in gene_collection.genes: + gene_dict[gene.ensembl_id] = { 'gene_symbol': gene.gene_symbol, 'product': gene.product } + + result["gene_info"] = gene_dict + result['success'] = 1 + print(json.dumps(result)) + +if __name__ == '__main__': + main() diff --git a/www/cgi/get_weighted_gene_cart_preview.cgi b/www/cgi/get_weighted_gene_cart_preview.cgi index 38e52c56..4524061b 100755 --- a/www/cgi/get_weighted_gene_cart_preview.cgi +++ b/www/cgi/get_weighted_gene_cart_preview.cgi @@ -6,13 +6,13 @@ import cgi import json +import os import string import sys import pandas as pd import scanpy as sc -import os, sys gene_cart_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'carts') ROWS_TO_SHOW = 5 @@ -35,21 +35,21 @@ def main(): except OSError as e: message = "Unable to open file for genecart {}".format(share_id) success = -1 - result = { 'preview_json':[], 'success': success, 'message': message } + result = { 'preview_json':[], 'num_genes':-1, 'weights':[], 'success': success, 'message': message } print(json.dump(result)) sys.exit() adata.var_names_make_unique() - df1 = pd.DataFrame(adata.X, adata.obs.index, adata.var.index).transpose() + # df1 = pd.DataFrame(adata.X, adata.obs.index, adata.var.index).transpose() # Merge df1 into adata.var, using the index of df1 as the index of adata.var # Reset index so that all column levels are the same. Numerical index is later dropped for displaying. - df = pd.concat([adata.var, df1], axis=1).reset_index()[:ROWS_TO_SHOW] + #df = pd.concat([adata.var, df1], axis=1).reset_index()[:ROWS_TO_SHOW] result["num_genes"] = len(adata.var) result["weights"] = adata.obs.index.tolist() - result['preview_json'] = df.to_html(classes=['weighted-list'], index=False) + #result['preview_json'] = df.to_html(classes=['weighted-list'], index=False) result['success'] = 1 print(json.dumps(result)) diff --git a/www/css/common.v2.css b/www/css/common.v2.css index 1bd088fb..f9a4e9e0 100644 --- a/www/css/common.v2.css +++ b/www/css/common.v2.css @@ -87,7 +87,7 @@ p.menu-label { background-color: lightgrey; } -.select.is-success select, .input.is-success{ +.select.is-success select, .input.is-success, .textarea.is-success{ border-color: #539400; /* overwrite default success for .select */ } @@ -95,7 +95,7 @@ p.menu-label { border-color: #539400; /* overwrite default success for .select */ } -.select.is-danger select, .input.is-danger{ +.select.is-danger select, .input.is-danger, .textarea.is-danger{ border-color: #942400; /* overwrite default success for .select */ } @@ -106,3 +106,11 @@ p.menu-label { .js-tree { max-height: 200px; /* a) addresses long lists and b) addresses https://github.com/mar10/wunderbaum/issues/57 */ } + +/* Toast-style notifications for actual alerts */ +.notification.js-toast { + position: fixed; + top: 30px; + right: 10px; + z-index:999; +} diff --git a/www/css/compare_datasets.v2.css b/www/css/compare_datasets.v2.css index 7f6e1e46..6ff09530 100644 --- a/www/css/compare_datasets.v2.css +++ b/www/css/compare_datasets.v2.css @@ -56,14 +56,6 @@ input[type=number] { height:92vh; } -/* Toast-style notifications for actual alerts */ -.notification.js-toast { - position: fixed; - top: 30px; - right: 10px; - z-index:999; -} - /* override loader from the themed CSS */ .button.is-loading::after, .loader, .select.is-loading::after, .control.is-loading::after { border-color: black; diff --git a/www/css/curator_common.css b/www/css/curator_common.css index 599322ea..4f16fb50 100644 --- a/www/css/curator_common.css +++ b/www/css/curator_common.css @@ -29,14 +29,6 @@ background-color: lightgrey; } -/* Toast-style notifications for actual alerts */ -.notification.js-toast { - position: fixed; - top: 30px; - right: 10px; - z-index:999; -} - #post_plot_adjustments select { width: 100px; white-space: nowrap; diff --git a/www/css/gene_collection_manager.css b/www/css/gene_collection_manager.css index eb13fcc1..f3e0d6f4 100644 --- a/www/css/gene_collection_manager.css +++ b/www/css/gene_collection_manager.css @@ -7,7 +7,6 @@ } hr.gc-list-element-divider { - width: 90%; background-color: #000000; margin-left: auto; margin-right: auto; @@ -20,14 +19,6 @@ hr.gc-list-element-divider { border-radius: 4px; } -/* Toast-style notifications for actual alerts */ -.notification.js-toast { - position: fixed; - top: 30px; - right: 10px; - z-index:999; -} - /* CSS for Floating UI components */ #delete_gc_popover { diff --git a/www/css/user_profile.v2.css b/www/css/user_profile.v2.css index 2df2c652..c635bc0f 100644 --- a/www/css/user_profile.v2.css +++ b/www/css/user_profile.v2.css @@ -23,11 +23,3 @@ img#submit_wait_indicator { width: 30px; margin-right: 10px; } - -/* Toast-style notifications for actual alerts */ -.notification.js-toast { - position: fixed; - top: 30px; - right: 10px; - z-index:999; -} diff --git a/www/gene_collection_manager.html b/www/gene_collection_manager.html index 2a48c3d1..2484cb67 100644 --- a/www/gene_collection_manager.html +++ b/www/gene_collection_manager.html @@ -159,7 +159,7 @@
- Upload a gene list with associated weights, for example from a principal component analysis + Upload a gene list with associated weights. For example, from a dataset's principal component analysis