diff options
author | zsloan | 2024-07-03 20:55:37 +0000 |
---|---|---|
committer | zsloan | 2024-07-03 20:55:37 +0000 |
commit | 92e0c8b492e96f5875bc2bb1df3e043abde2f280 (patch) | |
tree | 4a243545b9cb48d92eb3e02f82882f21644f7203 /gn2 | |
parent | 0ba243e6ed4af57c8638bfe8a81ec5551589d96a (diff) | |
download | genenetwork2-92e0c8b492e96f5875bc2bb1df3e043abde2f280.tar.gz |
Add link to GeneCup to tool buttons
This also includes a function for converting a list of traits/datasets to symbols, which was added to trait.py
Diffstat (limited to 'gn2')
-rw-r--r-- | gn2/base/trait.py | 31 | ||||
-rw-r--r-- | gn2/base/webqtlConfig.py | 2 | ||||
-rw-r--r-- | gn2/wqflask/static/new/javascript/search_results.js | 2 | ||||
-rw-r--r-- | gn2/wqflask/templates/tool_buttons.html | 4 | ||||
-rw-r--r-- | gn2/wqflask/views.py | 24 |
5 files changed, 58 insertions, 5 deletions
diff --git a/gn2/base/trait.py b/gn2/base/trait.py index 701958d7..24288ba1 100644 --- a/gn2/base/trait.py +++ b/gn2/base/trait.py @@ -611,3 +611,34 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): f"{repr(trait.name)} information is not found in the database " f"for dataset '{dataset.name}' with id '{dataset.id}'.") return trait + +def fetch_symbols(trait_db_list): + """ + Fetch list of trait symbols + + From a list of traits and datasets (where each item has + the trait and dataset name separated by a colon), return + + """ + + trimmed_trait_list = [trait_db for trait_db in trait_db_list + if 'Publish' not in trait_db and 'Geno' not in trait_db.split(":")[1]] + + symbol_list = [] + with database_connection(get_setting("SQL_URI")) as conn, conn.cursor() as cursor: + for trait_db in trimmed_trait_list: + symbol_query = """ + SELECT ps.Symbol + FROM ProbeSet as ps + INNER JOIN ProbeSetXRef psx ON psx.ProbeSetId = ps.Id + INNER JOIN ProbeSetFreeze psf ON psx.ProbeSetFreezeId = psf.Id + WHERE + ps.Name = %(trait_name)s AND + psf.Name = %(db_name)s + """ + + cursor.execute(symbol_query, {'trait_name': trait_db.split(":")[0], + 'db_name': trait_db.split(":")[1]}) + symbol_list.append(cursor.fetchone()[0]) + + return "+".join(symbol_list)
\ No newline at end of file diff --git a/gn2/base/webqtlConfig.py b/gn2/base/webqtlConfig.py index 998c0efc..8018bf40 100644 --- a/gn2/base/webqtlConfig.py +++ b/gn2/base/webqtlConfig.py @@ -68,6 +68,8 @@ RGD_URL = "https://rgd.mcw.edu/rgdweb/elasticResults.html?term=%s&category=Gene& PHENOGEN_URL = "https://phenogen.org/gene.jsp?speciesCB=Rn&auto=Y&geneTxt=%s&genomeVer=rn7§ion=geneEQTL" RRID_MOUSE_URL = "https://www.jax.org/strain/%s" RRID_RAT_URL = "https://rgd.mcw.edu/rgdweb/report/strain/main.html?id=%s" +GENE_CUP_URL = "https://genecup.org/progress?type=GWAS&type=addiction&type=drug&type=brain&type=stress&type=psychiatric&type=cell&type=function&query=%s" + # Temporary storage (note that this TMPDIR can be set as an # environment variable - use utility.tools.TEMPDIR when you diff --git a/gn2/wqflask/static/new/javascript/search_results.js b/gn2/wqflask/static/new/javascript/search_results.js index 29050c2b..c89b4ce3 100644 --- a/gn2/wqflask/static/new/javascript/search_results.js +++ b/gn2/wqflask/static/new/javascript/search_results.js @@ -309,7 +309,7 @@ $(function() { return submit_special("/loading") }); - $("#send_to_webgestalt, #send_to_bnw, #send_to_geneweaver").on("click", function() { + $("#send_to_webgestalt, #send_to_bnw, #send_to_geneweaver, #send_to_genecup").on("click", function() { traits = getTraitsFromTable() $("#trait_list").val(traits) url = $(this).data("url") diff --git a/gn2/wqflask/templates/tool_buttons.html b/gn2/wqflask/templates/tool_buttons.html index c6d1476c..3e716d70 100644 --- a/gn2/wqflask/templates/tool_buttons.html +++ b/gn2/wqflask/templates/tool_buttons.html @@ -18,6 +18,10 @@ BNW </button> +<button id="send_to_genecup" class="btn btn-primary submit_special" data-url="/genecup" > + GeneCup +</button> + <button id="wgcna_setup" class="btn btn-primary submit_special" data-url="/wgcna_setup" title="WGCNA Analysis" > WGCNA </button> diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 5d8a56e5..daddb442 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -46,12 +46,12 @@ from gn2.wqflask import search_results from gn2.wqflask import server_side # Used by YAML in marker_regression from gn2.base.data_set import create_dataset +from gn2.base.trait import fetch_symbols from gn2.wqflask.show_trait import show_trait from gn2.wqflask.show_trait import export_trait_data from gn2.wqflask.show_trait.show_trait import get_diff_of_vals from gn2.wqflask.heatmap import heatmap -from gn2.wqflask.external_tools import send_to_bnw -from gn2.wqflask.external_tools import send_to_webgestalt +from gn2.wqflask.external_tools import send_to_bnw, send_to_webgestalt from gn2.wqflask.external_tools import send_to_geneweaver from gn2.wqflask.comparison_bar_chart import comparison_bar_chart from gn2.wqflask.marker_regression import run_mapping @@ -88,8 +88,8 @@ from gn2.utility.redis_tools import get_redis_conn import gn2.utility.hmac as hmac -from gn2.base.webqtlConfig import TMPDIR -from gn2.base.webqtlConfig import GENERATED_IMAGE_DIR +from gn2.base.webqtlConfig import TMPDIR, GENERATED_IMAGE_DIR +from gn2.base.webqtlConfig import GENE_CUP_URL from gn2.wqflask.database import database_connection @@ -749,6 +749,22 @@ def geneweaver_page(): return rendered_template +@app.route("/genecup", methods=('POST',)) +def genecup_page(): + start_vars = request.form + + traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] + + if traits[0] != "": + symbol_string = fetch_symbols(traits) + return redirect(GENE_CUP_URL % symbol_string) + else: + rendered_template = render_template( + "empty_collection.html", **{'tool': 'GeneWeaver'}) + + return rendered_template + + @app.route("/comparison_bar_chart", methods=('POST',)) def comp_bar_chart_page(): start_vars = request.form |