From f3396740863f6f64713a9c761d2bfd089785170d Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 7 Jun 2016 18:15:51 +0000 Subject: R/qtl pair scan now works again, though it takes a while (10-15 minutes). Added pop-up warning user about run-time for pair scan Fixed links to GN2 github on the index page Fixed a couple issues with the search result page text Changed the appearance of the trait sample data table to match other tables (darker headers, etc) --- .../wqflask/marker_regression/marker_regression.py | 11 ++-- .../new/javascript/show_trait_mapping_tools.js | 18 +++++- wqflask/wqflask/templates/index_page.html | 6 +- wqflask/wqflask/templates/pair_scan_results.html | 2 +- wqflask/wqflask/templates/search_result_page.html | 36 ++++-------- .../wqflask/templates/show_trait_edit_data.html | 17 +++--- wqflask/wqflask/views.py | 66 +++++++++++++--------- 7 files changed, 86 insertions(+), 70 deletions(-) diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 1e0a618e..26da95b9 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -37,7 +37,7 @@ from utility import temp_data from utility.benchmark import Bench from wqflask.marker_regression import gemma_mapping -from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, PLINK_COMMAND +from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, PLINK_COMMAND, TEMPDIR from utility.external import shell from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR @@ -213,7 +213,8 @@ class MarkerRegression(object): if 'lod_score' in marker.keys(): self.qtl_results.append(marker) - self.trimmed_markers = trim_markers_for_table(results) + + self.trimmed_markers = results for qtl in enumerate(self.qtl_results): self.json_data['chr1'].append(str(qtl['chr1'])) @@ -228,7 +229,7 @@ class MarkerRegression(object): maf = self.maf, manhattan_plot = self.manhattan_plot, mapping_scale = self.mapping_scale, - qtl_results = self.qtl_results, + qtl_results = self.qtl_results ) else: @@ -388,7 +389,7 @@ class MarkerRegression(object): r_sum = ro.r["sum"] # Map the sum function plot = ro.r["plot"] # Map the plot function postscript = ro.r["postscript"] # Map the postscript function - png = ro.r["png"] # Map the png function + png = ro.r["png"] # Map the png function dev_off = ro.r["dev.off"] # Map the device off function print(r_library("qtl")) # Load R/qtl @@ -430,7 +431,7 @@ class MarkerRegression(object): #print("Pair scan results:", result_data_frame) self.pair_scan_filename = webqtlUtil.genRandStr("scantwo_") + ".png" - png(file=TMPDIR+self.pair_scan_filename) + png(file=TEMPDIR+self.pair_scan_filename) plot(result_data_frame) dev_off() diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js index 519d1304..3b1a1205 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -135,6 +135,8 @@ outlier_text = "One or more outliers exist in this data set. Please review values before mapping. Including outliers when mapping may lead to misleading results. We recommend winsorising the outliers or simply deleting them."; + runtime_warning_text = "This function could take as long as 10-20 minutes to run, so please do not close your browser window until it finishes." + showalert = function(message, alerttype) { return $('#alert_placeholder').append('
' + message + '
'); }; @@ -187,8 +189,20 @@ $('input[name=do_control]').val($('input[name=do_control_rqtl]:checked').val()); form_data = $('#trait_data_form').serialize(); console.log("form_data is:", form_data); - return submit_special(url); - //return do_ajax_post(url, form_data); + if ($('input[name=pair_scan]:checked').val() == "true") { + console.log("PAIR SCAN:", $('input[name=pair_scan]:checked').val()) + run_pair_scan = confirm(runtime_warning_text) + if (run_pair_scan == true) { + submit_special(url); + } + else { + return false + } + } + else { + return submit_special(url); + //return do_ajax_post(url, form_data); + } }; })(this)); diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index 5cc15682..9e029911 100755 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -207,12 +207,12 @@
  • Galaxy at UTHSC
  • -
  • GeneNetwork at Amazon +
  • GeneNetwork 1 at Amazon Cloud (EC2)
  • -
  • GeneNetwork Source Code at SourceForge
  • +
  • GeneNetwork 1 Source Code at SourceForge
  • -
  • GeneNetwork Source Code at GitHub
  • +
  • GeneNetwork 2 Source Code at GitHub
  • GN1 Mirror and development sites

    diff --git a/wqflask/wqflask/templates/pair_scan_results.html b/wqflask/wqflask/templates/pair_scan_results.html index ab4a36bb..1ccb2b27 100644 --- a/wqflask/wqflask/templates/pair_scan_results.html +++ b/wqflask/wqflask/templates/pair_scan_results.html @@ -44,7 +44,7 @@ - {% for marker in filtered_markers %} + {% for marker in trimmed_markers %} {{loop.index}} {{marker.name}} diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 4b4f3584..02c97862 100755 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -21,44 +21,30 @@ to find all records {% for word in search_terms %} {% if word.key|lower == "rif" %} - with GeneRIF containing {{ word.search_term[0] }}{% if not loop.last %} and {% endif %} + with GeneRIF containing {{ word.search_term[0] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.key|lower == "go" %} - with Gene Ontology ID {{ word.search_term[0] }}{% if not loop.last %} and {% endif %} + with Gene Ontology ID {{ word.search_term[0] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.key|lower == "wiki" %} - with GeneWiki containing {{ word.search_term[0] }}{% if not loop.last %} and {% endif %} + with GeneWiki containing {{ word.search_term[0] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.key|lower == "mean" %} - with MEAN between {{ word.search_term[0] }} and {{ word.search_term[1] }}{% if not loop.last %} and {% endif %} + with MEAN between {{ word.search_term[0] }} and {{ word.search_term[1] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.key|lower == "lrs" or word.key|lower == "translrs" or word.key|lower == "cislrs" %} {% if word.search_term|length == 1 %} - with {% if word.key|lower == "translrs" %}trans{% elif word.key|lower == "cislrs" %}cis{% endif %}LRS {% if word.separator == ">" %} greater than {% elif word.separator == "<" %} less than {% elif word.separator == ">=" %} greater than or equal to {% elif word.separator == "<=" %} less than or equal to {% endif %} {{ word.search_term[0] }}{% if not loop.last %} and {% endif %} + with {% if word.key|lower == "translrs" %}trans{% elif word.key|lower == "cislrs" %}cis{% endif %}LRS {% if word.separator == ">" %} greater than {% elif word.separator == "<" %} less than {% elif word.separator == ">=" %} greater than or equal to {% elif word.separator == "<=" %} less than or equal to {% endif %} {{ word.search_term[0] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.search_term|length == 2 %} - with LRS between {{ word.search_term[0] }} and {{ word.search_term[1] }}{% if not loop.last %} and {% endif %} + with LRS between {{ word.search_term[0] }} and {{ word.search_term[1] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.search_term|length == 3 %} - with LRS between {{ word.search_term[0] }} and {{ word.search_term[1] }} on chromosome {{ word.search_term[2] }}{% if not loop.last %} and {% endif %} + with LRS between {{ word.search_term[0] }} and {{ word.search_term[1] }} on chromosome {{ word.search_term[2] }}{% if loop.last %}.{% else %} and {% endif %} {% elif word.search_term|length == 5 %} - with LRS between {{ word.search_term[0] }} and {{ word.search_term[1] }} on chromosome {{ word.search_term[2] }} between {{ word.search_term[3] }} and {{ word.search_term[4] }} Mb{% if not loop.last %} and {% endif %} + with LRS between {{ word.search_term[0] }} and {{ word.search_term[1] }} on chromosome {{ word.search_term[2] }} between {{ word.search_term[3] }} and {{ word.search_term[4] }} Mb{% if loop.last %}.{% else %} and {% endif %} {% endif %} {% elif word.key|lower == "position" %} - with target genes on chromosome {% if word.search_term[0].split('chr')|length > 1 %}{{ word.search_term[0].split('chr')[1] }}{% elif word.search_term[0].split('CHR')|length > 1 %}{{ word.search_term[0].split('CHR')[1] }}{% else %}{{ word.search_term[0] }}{% endif %} between {{ word.search_term[1] }} and {{ word.search_term[2] }} Mb{% if not loop.last %} and {% endif %} + with target genes on chromosome {% if word.search_term[0].split('chr')|length > 1 %}{{ word.search_term[0].split('chr')[1] }}{% elif word.search_term[0].split('CHR')|length > 1 %}{{ word.search_term[0].split('CHR')[1] }}{% else %}{{ word.search_term[0] }}{% endif %} between {{ word.search_term[1] }} and {{ word.search_term[2] }} Mb{% if loop.last %}.{% else %} and {% endif %} {% else %} - with {{ word.key|lower }} matching {{ word.search_term[0] }} + that match the term {{ word.search_term[0] }}. {% endif %} - - {% endfor %}. - -

    - - +

    To study a record, click on its ID below. Check records below and click Add button to add to selection.

    diff --git a/wqflask/wqflask/templates/show_trait_edit_data.html b/wqflask/wqflask/templates/show_trait_edit_data.html index 228ef362..ff5f0c87 100755 --- a/wqflask/wqflask/templates/show_trait_edit_data.html +++ b/wqflask/wqflask/templates/show_trait_edit_data.html @@ -77,20 +77,20 @@ {% for sample_type in sample_groups %}

    {{ sample_type.header }}

    - +
    - - - - + + + + {% if sample_type.se_exists() %} - - + + {% endif %} {% for attribute in sample_type.attributes|sort() %} - {% endfor %} @@ -144,6 +144,7 @@ {% endfor %}
    IndexSampleValueIndexSampleValue SE SE + {{ sample_type.attributes[attribute].name }}
    +
    {% endfor %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index b7fcfa1d..df1f77bc 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -457,33 +457,47 @@ def marker_regression_page(): result = template_vars.__dict__ - #for item in template_vars.__dict__.keys(): - # print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item)) - - gn1_template_vars = marker_regression_gn1.MarkerRegression(result).__dict__ - - #qtl_length = len(result['js_data']['qtl_results']) - #print("qtl_length:", qtl_length) - pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL) - #print("pickled result length:", len(pickled_result)) - Redis.set(key, pickled_result) - Redis.expire(key, 1*60) - - with Bench("Rendering template"): - if result['pair_scan'] == True: - img_path = result['pair_scan_filename'] - print("img_path:", img_path) - initial_start_vars = request.form - print("initial_start_vars:", initial_start_vars) - imgfile = open(TEMPDIR + '/' + img_path, 'rb') - imgdata = imgfile.read() - imgB64 = imgdata.encode("base64") - bytesarray = array.array('B', imgB64) - result['pair_scan_array'] = bytesarray - rendered_template = render_template("pair_scan_results.html", **result) + if result['pair_scan']: + with Bench("Rendering template"): + img_path = result['pair_scan_filename'] + print("img_path:", img_path) + initial_start_vars = request.form + print("initial_start_vars:", initial_start_vars) + imgfile = open(TEMPDIR + img_path, 'rb') + imgdata = imgfile.read() + imgB64 = imgdata.encode("base64") + bytesarray = array.array('B', imgB64) + result['pair_scan_array'] = bytesarray + rendered_template = render_template("pair_scan_results.html", **result) else: - #rendered_template = render_template("marker_regression.html", **result) - rendered_template = render_template("marker_regression_gn1.html", **gn1_template_vars) + #for item in template_vars.__dict__.keys(): + # print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item)) + + gn1_template_vars = marker_regression_gn1.MarkerRegression(result).__dict__ + + pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL) + print("pickled result length:", len(pickled_result)) + Redis.set(key, pickled_result) + Redis.expire(key, 1*60) + + with Bench("Rendering template"): + rendered_template = render_template("marker_regression_gn1.html", **gn1_template_vars) + + # with Bench("Rendering template"): + # if result['pair_scan'] == True: + # img_path = result['pair_scan_filename'] + # print("img_path:", img_path) + # initial_start_vars = request.form + # print("initial_start_vars:", initial_start_vars) + # imgfile = open(TEMPDIR + '/' + img_path, 'rb') + # imgdata = imgfile.read() + # imgB64 = imgdata.encode("base64") + # bytesarray = array.array('B', imgB64) + # result['pair_scan_array'] = bytesarray + # rendered_template = render_template("pair_scan_results.html", **result) + # else: + # rendered_template = render_template("marker_regression.html", **result) + # rendered_template = render_template("marker_regression_gn1.html", **gn1_template_vars) return rendered_template -- cgit v1.2.3