diff options
-rw-r--r-- | wqflask/base/webqtlCaseData.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/external_tools/send_to_geneweaver.py | 93 | ||||
-rw-r--r-- | wqflask/wqflask/show_trait/SampleList.py | 1 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/search_results.js | 2 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/show_trait.js | 18 | ||||
-rw-r--r-- | wqflask/wqflask/templates/collections/list.html | 17 | ||||
-rw-r--r-- | wqflask/wqflask/templates/collections/view.html | 21 | ||||
-rw-r--r-- | wqflask/wqflask/templates/correlation_page.html | 10 | ||||
-rw-r--r-- | wqflask/wqflask/templates/geneweaver_page.html | 35 | ||||
-rw-r--r-- | wqflask/wqflask/templates/gsearch_gene.html | 8 | ||||
-rw-r--r-- | wqflask/wqflask/templates/gsearch_pheno.html | 8 | ||||
-rw-r--r-- | wqflask/wqflask/templates/search_result_page.html | 16 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 22 |
13 files changed, 222 insertions, 31 deletions
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 += "<td id=\"" + the_id + "\" align=\"right\">foo</td>"; + row_line += "<td id=\"" + the_id + "\" align=\"right\">N/A</td>"; } row_line += "</tr>"; the_rows += row_line; @@ -619,7 +619,7 @@ }; sqrt_normalize_data = function() { - return $('.trait_value_input').each((function(_this) { + return $('.edit_sample_value').each((function(_this) { return function(_index, element) { current_value = parseFloat($(element).data("value")) + 1; if(isNaN(current_value)) { @@ -633,7 +633,7 @@ }; qnorm_data = function() { - return $('.trait_value_input').each((function(_this) { + return $('.edit_sample_value').each((function(_this) { return function(_index, element) { current_value = parseFloat($(element).data("value")) + 1; if(isNaN(current_value)) { @@ -1164,9 +1164,17 @@ return redraw_prob_plot(); }); + function isEmpty( el ){ + return !$.trim(el.html()) + } + $('.stats_panel').click(function() { - make_table(); - edit_data_change(); + if (isEmpty($('#stats_table'))){ + make_table(); + edit_data_change(); + } else { + edit_data_change(); + } }); $('#edit_sample_lists').change(edit_data_change); $('.edit_sample_value').change(edit_data_change); diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html index 83e74613..5372fa46 100644 --- a/wqflask/wqflask/templates/collections/list.html +++ b/wqflask/wqflask/templates/collections/list.html @@ -8,15 +8,16 @@ {% endblock %} {% block content %} <!-- Start of body --> - {% if g.user_session.logged_in %} - {{ header("Collections owned by {{ g.user_session.user_name }}", - 'You have {}.'.format(numify(collections|count, "collection", "collections"))) }} - {% else %} - {{ header("Your Collections", - 'You have {}.'.format(numify(collections|count, "collection", "collections"))) }} - {% endif %} - <div class="container"> + {% if g.user_session.logged_in %} + <h1>Collections owned by {{ g.user_session.user_name }}</h1> + {% else %} + <h1>Your Collections</h1> + {% endif %} + <h2>You have {{ '{}'.format(numify(collections|count, "collection", "collections")) }}.</h1> + + <hr style="height: 1px; background-color: #A9A9A9;"> + <!-- <div class="page-header"> {% if g.user_session.logged_in %} diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index a219b868..75b65b5a 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -9,16 +9,15 @@ <!-- Start of body --> <div class="container"> - {% if uc %} - <h2>{{ uc.name }}</h2> - <h3>{{ 'This collection has {}.'.format(numify(trait_obs|count, "record", "records")) }}</h3> - {% else %} - <h2> {{ collection_name }}</h2> - <h3>{{ 'This collection has {}.'.format(numify(trait_obs|count, "record", "records")) }}</h3> - {% endif %} - </div> + {% if uc %} + <h1>{{ uc.name }}</h1> + {% else %} + <h1>{{ collection_name }}</h1> + {% endif %} + <h2>This collection has {{ '{}'.format(numify(trait_obs|count, "record", "records")) }}</h2> + + <hr style="height: 1px; background-color: #A9A9A9;"> - <div class="container"> <div> <form id="collection_form" action="/delete" method="post"> {% if uc %} @@ -63,6 +62,10 @@ WebGestalt </button> + <button id="send_to_geneweaver" class="btn btn-primary submit_special" data-url="/geneweaver_page" title="GeneWeaver" > + GeneWeaver + </button> + <button id="send_to_bnw" class="btn btn-primary submit_special" data-url="/bnw_page" title="Bayesian Network" > BNW </button> diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 4786e379..76aa8d2d 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -4,12 +4,12 @@ <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> {% endblock %} {% block content %} - - {{ header("Correlation", 'Trait: {} Dataset: {}'.format(this_trait.name, dataset.name)) }} - <div class="container"> <div class="page-header"> <h1>Correlation Table</h1> + <h2>Trait: {{ this_trait.name }} + + <hr style="height: 1px; background-color: #A9A9A9;"> </div> <p>Values of record {{ this_trait.name }} in the <a href="http://genenetwork.org/webqtl/main.py?FormID=sharinginfo&GN_AccessionId={{ dataset.group.accession_id }}">{{ dataset.fullname }}</a> @@ -59,6 +59,10 @@ WebGestalt </button> + <button id="send_to_geneweaver" class="btn btn-primary submit_special" data-url="/geneweaver_page" title="GeneWeaver" > + GeneWeaver + </button> + <button id="send_to_bnw" class="btn btn-primary submit_special" data-url="/bnw_page" title="Bayesian Network" > BNW </button> diff --git a/wqflask/wqflask/templates/geneweaver_page.html b/wqflask/wqflask/templates/geneweaver_page.html new file mode 100644 index 00000000..91fca85b --- /dev/null +++ b/wqflask/wqflask/templates/geneweaver_page.html @@ -0,0 +1,35 @@ +{% extends "base.html" %} +{% block title %}{% if wrong_input == "True" %}WebGestalt Error{% else %}Opening WebGestalt{% endif %}{% endblock %} +{% block content %} + {% if wrong_input == "True" %} + {{ header("Error") }} + + <div class="container"> + {% if chip_name == "mixed" %} + <h3>Sorry, the analysis was interrupted because your selections from GeneNetwork apparently include data from more than one array platform (i.e., Affymetrix U74A and M430 2.0). Most WebGestalt analyses assume that you are using a single array type and compute statistical values on the basis of that particular array. Please reselect traits from a signle platform and submit again.</h3> + {% elif chip_name == "not_microarray" %} + <h3>You need to select at least one microarray trait to submit.</hr> + {% elif '_NA' in chip_name %} + <h3>Sorry, the analysis was interrupted because your selections from GeneNetwork apparently include data from platform {{ chip_name }} which is unknown by GeneWeaver. Please reselect traits and submit again.</h3> + {% else %} + <h3>Sorry, an error occurred while submitting your traits to GeneWeaver.</h3> + {% endif %} + </div> + {% else %} + <div class="container"> + <h3>Opening GeneWeaver...</h3> + </div> + <form method="post" action="http://ontologicaldiscovery.org/index.php?action=manage&cmd=importGeneSet" name="formODE"> + {% for key in hidden_vars %} + <input type="hidden" name="{{ key }}" value="{{ hidden_vars[key] }}"> + {% endfor %} + </form> + {% endif %} +{% endblock %} +{% block js %} +{% if wrong_input == "False" %} +<script type="text/javascript"> + setTimeout('document.formODE.submit()', 1000); +</script> +{% endif %} +{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 66073555..ebebd044 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -62,6 +62,13 @@ } ); }; + $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $(td).text(); + } ); + } + $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -115,6 +122,7 @@ 'title': "Record", 'type': "natural", 'data': null, + 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.name + '</a>' } diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html index 168b2846..96a5d71a 100644 --- a/wqflask/wqflask/templates/gsearch_pheno.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -62,6 +62,13 @@ } ); }; + $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $(td).text(); + } ); + } + $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -144,6 +151,7 @@ 'title': "Year", 'type': "natural", 'data': null, + 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { if (data.pubmed_id != "N/A"){ return '<a href="' + data.pubmed_link + '">' + data.pubmed_text + '</a>' diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index db6bc15d..36a25665 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -44,6 +44,9 @@ </p> <p>To study a record click on its ID below, and to view the whole description {% if dataset.type == "Publish" %}or list of authors {% endif %} hover over the table cell. Check records below and click Add button to add to selection.</p> + + <hr style="height: 1px; background-color: #A9A9A9;"> + </div> <div> @@ -86,6 +89,10 @@ WebGestalt </button> + <button id="send_to_geneweaver" class="btn btn-primary submit_special" data-url="/geneweaver_page" title="GeneWeaver" > + GeneWeaver + </button> + <button id="send_to_bnw" class="btn btn-primary submit_special" data-url="/bnw_page" title="Bayesian Network" > BNW </button> @@ -149,6 +156,13 @@ } ); }; + $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $(td).text(); + } ); + } + $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -261,6 +275,7 @@ 'title': "Record", 'type': "natural", 'data': null, + 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.name + '</a>' } @@ -316,6 +331,7 @@ { 'title': "Year", 'type': "natural", + 'orderDataType': "dom-inner-text", 'data': null, 'render': function(data, type, row, meta) { if (data.pubmed_id != "N/A"){ diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 7c2ed80d..cd2e047b 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -43,7 +43,7 @@ from base.data_set import DataSet # Used by YAML in marker_regression from wqflask.show_trait import show_trait from wqflask.show_trait import export_trait_data from wqflask.heatmap import heatmap -from wqflask.external_tools import send_to_bnw, send_to_webgestalt +from wqflask.external_tools import send_to_bnw, send_to_webgestalt, send_to_geneweaver from wqflask.comparison_bar_chart import comparison_bar_chart from wqflask.marker_regression import run_mapping from wqflask.marker_regression import display_mapping_results @@ -499,7 +499,25 @@ def webgestalt_page(): result = template_vars.__dict__ rendered_template = render_template("webgestalt_page.html", **result) else: - rendered_template = render_template("empty_collection.html", **{'tool':'BNW'}) + rendered_template = render_template("empty_collection.html", **{'tool':'WebGestalt'}) + + return rendered_template + +@app.route("/geneweaver_page", methods=('POST',)) +def geneweaver_page(): + logger.info("In run WebGestalt, request.form is:", pf(request.form)) + logger.info(request.url) + + start_vars = request.form + + traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] + if traits[0] != "": + template_vars = send_to_geneweaver.SendToGeneWeaver(request.form) + + result = template_vars.__dict__ + rendered_template = render_template("geneweaver_page.html", **result) + else: + rendered_template = render_template("empty_collection.html", **{'tool':'GeneWeaver'}) return rendered_template |