From 27a08a81107705f213d13fb7334a2b8eb4fd68d2 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 12 Feb 2019 13:20:18 -0600 Subject: Added GeneWeaver linkout Fixed some issues with sorting in various tables Changed header appearance for some pages Fixed bug where basic stats table would sometimes be duplicated or show up with empty fields --- wqflask/base/webqtlCaseData.py | 2 +- .../wqflask/external_tools/send_to_geneweaver.py | 93 +++++++++++++++++++++- wqflask/wqflask/show_trait/SampleList.py | 1 - .../static/new/javascript/search_results.js | 2 +- .../wqflask/static/new/javascript/show_trait.js | 18 +++-- wqflask/wqflask/templates/collections/list.html | 17 ++-- wqflask/wqflask/templates/collections/view.html | 21 ++--- wqflask/wqflask/templates/correlation_page.html | 10 ++- wqflask/wqflask/templates/geneweaver_page.html | 35 ++++++++ wqflask/wqflask/templates/gsearch_gene.html | 8 ++ wqflask/wqflask/templates/gsearch_pheno.html | 8 ++ wqflask/wqflask/templates/search_result_page.html | 16 ++++ wqflask/wqflask/views.py | 22 ++++- 13 files changed, 222 insertions(+), 31 deletions(-) create mode 100644 wqflask/wqflask/templates/geneweaver_page.html diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 76f06cc6..aa34024c 100644 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -49,7 +49,7 @@ class webqtlCaseData(object): if self.variance != None: str += " variance=%2.3f" % self.variance if self.num_cases: - str += " ndata=%d" % self.num_cases + str += " ndata=%s" % self.num_cases if self.name: str += " name=%s" % self.name if self.name2: diff --git a/wqflask/wqflask/external_tools/send_to_geneweaver.py b/wqflask/wqflask/external_tools/send_to_geneweaver.py index 956286af..7a5dba73 100644 --- a/wqflask/wqflask/external_tools/send_to_geneweaver.py +++ b/wqflask/wqflask/external_tools/send_to_geneweaver.py @@ -18,4 +18,95 @@ # # This module is used by GeneNetwork project (www.genenetwork.org) -from __future__ import absolute_import, print_function, division \ No newline at end of file +from __future__ import absolute_import, print_function, division + +import string + +from flask import Flask, g + +from base.trait import GeneralTrait, retrieve_trait_info +from base.species import TheSpecies +from utility import helper_functions, corr_result_helpers + +import utility.logger +logger = utility.logger.getLogger(__name__ ) + +class SendToGeneWeaver(object): + def __init__(self, start_vars): + trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')] + helper_functions.get_trait_db_obs(self, trait_db_list) + + self.chip_name = test_chip(self.trait_list) + self.wrong_input = "False" + if self.chip_name == "mixed" or self.chip_name == "not_microarray" or '_NA' in self.chip_name: + self.wrong_input = "True" + else: + species = self.trait_list[0][1].group.species + if species == "rat": + species_name = "Rattus norvegicus" + elif species == "human": + species_name = "Homo sapiens" + elif species == "mouse": + species_name = "Mus musculus" + else: + species_name = "" + + trait_name_list = get_trait_name_list(self.trait_list) + + self.hidden_vars = { + 'client' : "genenetwork", + 'species' : species_name, + 'idtype' : self.chip_name, + 'list' : string.join(trait_name_list, ","), + } + +def get_trait_name_list(trait_list): + name_list = [] + for trait_db in trait_list: + name_list.append(trait_db[0].name) + + return name_list + +def test_chip(trait_list): + final_chip_name = "" + + for trait_db in trait_list: + dataset = trait_db[1] + result = g.db.execute("""SELECT GeneChip.GO_tree_value + FROM GeneChip, ProbeFreeze, ProbeSetFreeze + WHERE GeneChip.Id = ProbeFreeze.ChipId and + ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and + ProbeSetFreeze.Name = '%s'""" % dataset.name).fetchone() + + if result: + chip_name = result[0] + if chip_name: + if chip_name != final_chip_name: + if final_chip_name: + return "mixed" + else: + final_chip_name = chip_name + else: + pass + else: + result = g.db.execute("""SELECT GeneChip.Name + FROM GeneChip, ProbeFreeze, ProbeSetFreeze + WHERE GeneChip.Id = ProbeFreeze.ChipId and + ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and + ProbeSetFreeze.Name = '%s'""" % dataset.name).fetchone() + chip_name = '%s_NA' % result[0] + return chip_name + else: + query = """SELECT GeneChip.Name + FROM GeneChip, ProbeFreeze, ProbeSetFreeze + WHERE GeneChip.Id = ProbeFreeze.ChipId and + ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and + ProbeSetFreeze.Name = '%s'""" % dataset.name + result = g.db.execute(query).fetchone() + if result == None: + return "not_microarray" + else: + chip_name = '%s_NA' % result[0] + return chip_name + + return chip_name \ No newline at end of file diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index f2259b55..50d7b6c0 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -75,7 +75,6 @@ class SampleList(object): logger.debug("self.attributes is", pf(self.attributes)) self.do_outliers() - #do_outliers(the_samples) logger.debug("*the_samples are [%i]: %s" % (len(self.sample_list), pf(self.sample_list))) def __repr__(self): diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 2277a157..ebb1651d 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -272,7 +272,7 @@ $(function() { return submit_special(url) }); - $("#send_to_webgestalt, #send_to_bnw").on("click", function() { + $("#send_to_webgestalt, #send_to_bnw, #send_to_geneweaver").on("click", function() { traits = $("#trait_table input:checked").map(function() { return $(this).val(); }).get(); diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 717d98b9..2f846642 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -342,7 +342,7 @@ if (!__hasProp.call(_ref1, key)) continue; value = _ref1[key]; the_id = process_id(key, row.vn); - row_line += "