diff options
author | zsloan | 2020-12-15 13:59:24 -0600 |
---|---|---|
committer | zsloan | 2020-12-15 13:59:24 -0600 |
commit | 18fd821aff77e4352f15f1f74acab2885ceeef67 (patch) | |
tree | 117fc8b8dcbf3249708878530d6d935814cdb1ca | |
parent | 9a6195abd1867e602234f182d73029e700612bd4 (diff) | |
parent | 93ba2a098a349977a8d54a75f7c871205ee2ddb1 (diff) | |
download | genenetwork2-18fd821aff77e4352f15f1f74acab2885ceeef67.tar.gz |
Resolved conflict from putting tool buttons in a separate template
-rw-r--r-- | test/requests/link_checker.py | 3 | ||||
-rw-r--r-- | wqflask/wqflask/correlation/corr_scatter_plot.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/correlation_matrix/show_corr_matrix.py | 43 | ||||
-rw-r--r-- | wqflask/wqflask/templates/admin/create_group.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/comparison_bar_chart.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/corr_scatterplot.html | 8 | ||||
-rw-r--r-- | wqflask/wqflask/templates/correlation_matrix.html | 22 | ||||
-rw-r--r-- | wqflask/wqflask/templates/correlation_page.html | 13 | ||||
-rw-r--r-- | wqflask/wqflask/templates/heatmap.html | 2 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/index_page_orig.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/pair_scan_results.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/snp_browser.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 11 |
14 files changed, 89 insertions, 27 deletions
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py index 36aeea83..a22c2b54 100644 --- a/test/requests/link_checker.py +++ b/test/requests/link_checker.py @@ -117,6 +117,8 @@ def check_packaged_js_files(args_obj, parser): "/js/nvd3/nv.d3.min.css", "/js/qtip2/jquery.qtip.min.js", "/js/js_alt/md5.min.js", + "/js/typeahead/typeahead.bundle.js", + "/js/underscore-string/underscore.string.min.js", "/js/js_alt/jstat.min.js", "/js/js_alt/parsley.min.js", "/js/js_alt/timeago.min.js", @@ -136,6 +138,7 @@ def check_packaged_js_files(args_obj, parser): "/js/cytoscape-panzoom/cytoscape.js-panzoom.css", "/js/cytoscape-qtip/cytoscape-qtip.js", "/css/d3-tip/d3-tip.css", + "/js/javascript-twitter-post-fetcher/js/twitterFetcher_min.js", "/js/DataTables/images/sort_asc_disabled.png", "/js/DataTables/images/sort_desc_disabled.png", ] diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py index 6ab8c3d8..c87776bb 100644 --- a/wqflask/wqflask/correlation/corr_scatter_plot.py +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -29,6 +29,8 @@ class CorrScatterPlot(object): self.trait_2 = create_trait(name=params['trait_2'], dataset=self.dataset_2) #self.trait_3 = create_trait(name=params['trait_3'], dataset=self.dataset_3) + self.method = params['method'] + primary_samples = self.dataset_1.group.samplelist if self.dataset_1.group.parlist != None: primary_samples += self.dataset_1.group.parlist diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py index 0269ce68..a77877d2 100644 --- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py +++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py @@ -20,24 +20,23 @@ import datetime import math +import random +import string + import numpy as np import scipy import rpy2.robjects as robjects -import utility.webqtlUtil # this is for parallel computing only. -import utility.logger +from rpy2.robjects.packages import importr from base import data_set +from base.webqtlConfig import GENERATED_TEXT_DIR from functools import reduce from functools import cmp_to_key -from rpy2.robjects.packages import importr - from utility import webqtlUtil from utility import helper_functions from utility import corr_result_helpers from utility.redis_tools import get_redis_conn -logger = utility.logger.getLogger(__name__) - Redis = get_redis_conn() THIRTY_DAYS = 60 * 60 * 24 * 30 @@ -135,6 +134,8 @@ class CorrelationMatrix(object): self.corr_results.append(corr_result_row) self.pca_corr_results.append(pca_corr_result_row) + self.export_filename, self.export_filepath = export_corr_matrix(self.corr_results) + self.trait_data_array = [] for trait_db in self.trait_list: this_trait = trait_db[0] @@ -232,6 +233,36 @@ class CorrelationMatrix(object): loadings_array.append(loadings_row) return loadings_array +def export_corr_matrix(corr_results): + corr_matrix_filename = "corr_matrix_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + matrix_export_path = "{}{}.csv".format(GENERATED_TEXT_DIR, corr_matrix_filename) + with open(matrix_export_path, "w+") as output_file: + output_file.write("Time/Date: " + datetime.datetime.now().strftime("%x / %X") + "\n") + output_file.write("\n") + output_file.write("Correlation ") + for i, item in enumerate(corr_results[0]): + output_file.write("Trait" + str(i + 1) + ": " + str(item[0].dataset.name) + "::" + str(item[0].name) + "\t") + output_file.write("\n") + for i, row in enumerate(corr_results): + output_file.write("Trait" + str(i + 1) + ": " + str(row[0][0].dataset.name) + "::" + str(row[0][0].name) + "\t") + for item in row: + output_file.write(str(item[1]) + "\t") + output_file.write("\n") + + output_file.write("\n") + output_file.write("\n") + output_file.write("N ") + for i, item in enumerate(corr_results[0]): + output_file.write("Trait" + str(i) + ": " + str(item[0].dataset.name) + "::" + str(item[0].name) + "\t") + output_file.write("\n") + for i, row in enumerate(corr_results): + output_file.write("Trait" + str(i) + ": " + str(row[0][0].dataset.name) + "::" + str(row[0][0].name) + "\t") + for item in row: + output_file.write(str(item[2]) + "\t") + output_file.write("\n") + + return corr_matrix_filename, matrix_export_path + def zScore(trait_data_array): NN = len(trait_data_array[0]) if NN < 10: diff --git a/wqflask/wqflask/templates/admin/create_group.html b/wqflask/wqflask/templates/admin/create_group.html index 38ae834c..21ef5653 100644 --- a/wqflask/wqflask/templates/admin/create_group.html +++ b/wqflask/wqflask/templates/admin/create_group.html @@ -82,7 +82,7 @@ {% block js %} <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/group_manager.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> <script type="text/javascript" charset="utf-8"> </script> diff --git a/wqflask/wqflask/templates/comparison_bar_chart.html b/wqflask/wqflask/templates/comparison_bar_chart.html index e3dd03d5..d77e0515 100644 --- a/wqflask/wqflask/templates/comparison_bar_chart.html +++ b/wqflask/wqflask/templates/comparison_bar_chart.html @@ -31,7 +31,7 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='d3js/d3.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='d3-tip/d3-tip.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/panelutil.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> <script type="text/javascript" src="{{ url_for('js', filename='plotly/plotly.min.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/comparison_bar_chart.js"></script> diff --git a/wqflask/wqflask/templates/corr_scatterplot.html b/wqflask/wqflask/templates/corr_scatterplot.html index a0436ade..f44350ab 100644 --- a/wqflask/wqflask/templates/corr_scatterplot.html +++ b/wqflask/wqflask/templates/corr_scatterplot.html @@ -118,17 +118,17 @@ {% endif %} <ul class="nav nav-tabs"> - <li class="active"> + <li {% if method == 'pearson' %}class="active"{% endif %}> <a href="#tp1" data-toggle="tab">Pearson</a> </li> - <li> + <li {% if method == 'spearman' %}class="active"{% endif %}> <a href="#tp2" data-toggle="tab">Spearman Rank</a> </li> </ul> <div class="tab-content" style="min-width: 800px;"> - <div class="tab-pane active" id="tp1"> + <div class="tab-pane {% if method == 'pearson' %}active{% endif %}" id="tp1"> <br> <div id="scatterplot2"></div> <br> @@ -243,7 +243,7 @@ </div> </div> - <div class="tab-pane" id="tp2"> + <div class="tab-pane {% if method == 'spearman' %}active{% endif %}" id="tp2"> <br> <div id="srscatterplot2"></div> <br> diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html index 96ad9c35..8275f1dd 100644 --- a/wqflask/wqflask/templates/correlation_matrix.html +++ b/wqflask/wqflask/templates/correlation_matrix.html @@ -1,10 +1,11 @@ {% extends "base.html" %} +{% block title %}Correlation Matrix{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> <link rel="stylesheet" type="text/css" href="/static/new/css/corr_matrix.css" /> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> <link rel="stylesheet" type="text/css" href="/static/new/css/panelutil.css" /> - <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='d3-tip/d3-tip.css') }}" /> + <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='d3-tip/d3-tip.css') }}" /> {% endblock %} {% block content %} @@ -32,6 +33,7 @@ {% endfor %} </tr> {% for trait in traits %} + {% set outer_loop = loop.index %} <tr> <td align="center"><input type="checkbox" class="checkbox" style="margin-left: 3px; margin-right: 1px;"></td> <td align="right" style="padding-right: 4px;" > @@ -54,7 +56,7 @@ {% if result[1] == 0 %} <td nowrap="ON" align="middle" bgcolor="#eeeeee" style="padding: 3px; line-height: 1.1;">N/A</td> {% else %} - <td nowrap="ON" align="middle" class="corr_cell" style="padding: 3px; line-height: 1.1;"><a href="/corr_scatter_plot?dataset_1={% if trait.dataset.name == 'Temp' %}Temp_{{ trait.dataset.group.name }}{% else %}{{ trait.dataset.name }}{% endif %}&dataset_2={% if result[0].dataset.name == 'Temp' %}Temp_{{ result[0].dataset.group.name }}{% else %}{{ result[0].dataset.name }}{% endif %}&trait_1={{ trait.name }}&trait_2={{ result[0].name }}"><font style="font-size: 12px; color: #3071a9; font-weight: bold;" ><span class="corr_value">{{ '%0.2f' % result[1] }}</span><br>{{ result[2] }}</font></a></td> + <td nowrap="ON" align="middle" class="corr_cell" style="padding: 3px; line-height: 1.1;"><a href="/corr_scatter_plot?method={% if loop.index > outer_loop %}spearman{% else %}pearson{% endif %}&dataset_1={% if trait.dataset.name == 'Temp' %}Temp_{{ trait.dataset.group.name }}{% else %}{{ trait.dataset.name }}{% endif %}&dataset_2={% if result[0].dataset.name == 'Temp' %}Temp_{{ result[0].dataset.group.name }}{% else %}{{ result[0].dataset.name }}{% endif %}&trait_1={{ trait.name }}&trait_2={{ result[0].name }}"><font style="font-size: 12px; color: #3071a9; font-weight: bold;" ><span class="corr_value">{{ '%0.2f' % result[1] }}</span><br>{{ result[2] }}</font></a></td> {% endif %} {% endif %} {% endfor %} @@ -63,6 +65,12 @@ </tbody> </table> <br> +<form method="post" target="_blank" action="/export_corr_matrix" id="matrix_export_form"> + <input type="hidden" name="export_filepath" value="{{ export_filepath }}"> + <input type="hidden" name="export_filename" value="{{ export_filename }}"> + <button class="btn btn-default" id="export">Download <span class="glyphicon glyphicon-download"></span></button> +</form> +<br> {% if pca_works == "True" %} <h2>PCA Traits</h2> <div style="margin-bottom: 20px; overflow:hidden;"> @@ -133,7 +141,7 @@ <script type="text/javascript" src="{{ url_for('js', filename='d3js/d3.min.js') }}"></script> <script type="text/javascript" src="{{ url_for('js', filename='d3-tip/d3-tip.js') }}"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/md5.min.js') }}"></script> <script type="text/javascript" src="/static/new/javascript/panelutil.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='chroma/chroma.min.js') }}"></script> @@ -172,6 +180,14 @@ "paging": false, "orderClasses": true } ); + + export_corr_matrix = function() { + $('#matrix_export_form').attr('action', '/export_corr_matrix'); + return $('#matrix_export_form').submit(); + } + + $('#export').click(export_corr_matrix); + </script> {% endblock %} diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index a9a3a2ca..8e2a23fd 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -32,9 +32,7 @@ {% for this_trait in trait_list %} {{ this_trait.name }}:{{ this_trait.dataset }}, {% endfor %}" > - {% include 'tool_buttons.html' %} - </form> </div> <br /> @@ -135,9 +133,10 @@ <script type="text/javascript" src="{{ url_for('js', filename='js_alt/md5.min.js') }}"></script> <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='jszip/jszip.min.js') }}"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> - + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.html5.min.js') }}"></script> @@ -313,7 +312,7 @@ 'orderSequence': [ "desc", "asc"], 'render': function(data, type, row, meta) { if (data.sample_r != "N/A") { - return "<a target\"_blank\" href=\"corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" + return "<a target\"_blank\" href=\"corr_scatter_plot?method={% if corr_method == 'spearman' %}spearman{% else %}pearson{% endif %}&dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" } else { return data.sample_r } @@ -434,7 +433,7 @@ 'orderSequence': [ "desc", "asc"], 'render': function(data, type, row, meta) { if (data.sample_r != "N/A") { - return "<a target\"_blank\" href=\"corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" + return "<a target\"_blank\" href=\"corr_scatter_plot?method={% if corr_method == 'spearman' %}spearman{% else %}pearson{% endif %}&dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" } else { return data.sample_r } @@ -488,7 +487,7 @@ 'orderSequence': [ "desc", "asc"], 'render': function(data, type, row, meta) { if (data.sample_r != "N/A") { - return "<a target\"_blank\" href=\"corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" + return "<a target\"_blank\" href=\"corr_scatter_plot?method={% if corr_method == 'spearman' %}spearman{% else %}pearson{% endif %}&dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" } else { return data.sample_r } diff --git a/wqflask/wqflask/templates/heatmap.html b/wqflask/wqflask/templates/heatmap.html index b16de42e..92754266 100644 --- a/wqflask/wqflask/templates/heatmap.html +++ b/wqflask/wqflask/templates/heatmap.html @@ -39,6 +39,6 @@ <script language="javascript" type="text/javascript" src="/static/new/javascript/lod_chart.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/curvechart.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/iplotMScanone_noeff.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> {% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html index 13ca52df..7efbdccf 100755 --- a/wqflask/wqflask/templates/index_page_orig.html +++ b/wqflask/wqflask/templates/index_page_orig.html @@ -326,7 +326,7 @@ } </script> - <script type="text/javascript" src="/twitter/js/twitterFetcher_min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='javascript-twitter-post-fetcher/js/twitterFetcher_min.js') }}"></script> <script type="text/javascript"> var configProfile = { diff --git a/wqflask/wqflask/templates/pair_scan_results.html b/wqflask/wqflask/templates/pair_scan_results.html index 38dca514..b31e3b7a 100644 --- a/wqflask/wqflask/templates/pair_scan_results.html +++ b/wqflask/wqflask/templates/pair_scan_results.html @@ -69,6 +69,6 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/underscore.min.js') }}"></script> {% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index c95a0522..32cf3c0a 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -130,7 +130,7 @@ <script type="text/javascript" src="https://d3js.org/d3.v3.min.js"></script> <script type="text/javascript" src="/static/new/js_external/underscore-min.js"></script> - <script type="text/javascript" src="/static/new/js_external/underscore.string.min.js"></script> + <script type="text/javascript" src="{{ url_for('js', filename='underscore-string/underscore.string.min.js') }}"></script> <script type="text/javascript" src="{{ url_for('js', filename='d3-tip/d3-tip.js') }}"></script> <script type="text/javascript" src="{{ url_for('js', filename='js_alt/jstat.min.js') }}"></script> <script type="text/javascript" src="/static/new/js_external/shapiro-wilk.js"></script> diff --git a/wqflask/wqflask/templates/snp_browser.html b/wqflask/wqflask/templates/snp_browser.html index fb564b28..a96b8e3b 100644 --- a/wqflask/wqflask/templates/snp_browser.html +++ b/wqflask/wqflask/templates/snp_browser.html @@ -217,7 +217,7 @@ {% block js %} <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> - <script language="javascript" type="text/javascript" src="/static/new/js_external/typeahead.bundle.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='typeahead/typeahead.bundle.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/typeahead_rn6.json"></script> diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 3557a62a..25563e86 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -799,6 +799,17 @@ def export_mapping_results(): return response +@app.route("/export_corr_matrix", methods = ('POST',)) +def export_corr_matrix(): + file_path = request.form.get("export_filepath") + file_name = request.form.get("export_filename") + results_csv = open(file_path, "r").read() + response = Response(results_csv, + mimetype='text/csv', + headers={"Content-Disposition":"attachment;filename=" + file_name + ".csv"}) + + return response + @app.route("/export", methods = ('POST',)) def export(): logger.info("request.form:", request.form) |