From 93dcba89f7e424a759e3177a74b1ce322cdd7c57 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 25 Mar 2015 16:11:56 +0000 Subject: Pair scan image now loads properly --- wqflask/base/webqtlConfig.py | 2 +- .../wqflask/marker_regression/marker_regression.py | 6 +-- wqflask/wqflask/templates/pair_scan_results.html | 55 ++++------------------ wqflask/wqflask/templates/show_image.html | 5 ++ wqflask/wqflask/views.py | 23 ++++++++- 5 files changed, 38 insertions(+), 53 deletions(-) create mode 100644 wqflask/wqflask/templates/show_image.html diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py index e74b9ce5..49a596aa 100755 --- a/wqflask/base/webqtlConfig.py +++ b/wqflask/base/webqtlConfig.py @@ -58,7 +58,7 @@ SNP_PATH = '/home/zas1024/snps/' IMGDIR = GNROOT + '/wqflask/wqflask/images/' IMAGESPATH = HTMLPATH + 'images/' UPLOADPATH = IMAGESPATH + 'upload/' -TMPDIR = '/tmp/' +TMPDIR = '/home/zas1024/tmp/' # Will remove this and dependent items later GENODIR = HTMLPATH + 'genotypes/' NEWGENODIR = HTMLPATH + 'new_genotypes/' GENO_ARCHIVE_DIR = GENODIR + 'archive/' diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index af441489..3fb9915b 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -321,9 +321,9 @@ class MarkerRegression(object): print("No covariates"); result_data_frame = scantwo(cross_object, pheno = "the_pheno", model=self.model, method=self.method, n_cluster = 16) print("Pair scan results:", result_data_frame) - - self.pair_scan_filename = webqtlUtil.genRandStr("scantwo_") - png(file=webqtlConfig.IMGDIR+self.pair_scan_filename+".png") + + self.pair_scan_filename = webqtlUtil.genRandStr("scantwo_") + ".png" + png(file=webqtlConfig.TMPDIR+self.pair_scan_filename) plot(result_data_frame) dev_off() diff --git a/wqflask/wqflask/templates/pair_scan_results.html b/wqflask/wqflask/templates/pair_scan_results.html index a0041e11..869dabed 100644 --- a/wqflask/wqflask/templates/pair_scan_results.html +++ b/wqflask/wqflask/templates/pair_scan_results.html @@ -1,13 +1,13 @@ {% extends "base.html" %} -{% block title %}Interval Mapping{% endblock %} +{% block title %}Pair Scan{% endblock %} {% block css %} - {% endblock %} + {% block content %} {{ header("Mapping", @@ -21,7 +21,12 @@
- + + Embedded Image
@@ -31,30 +36,12 @@
- - {% endblock %} {% block js %} - - - - - - - - - @@ -62,30 +49,4 @@ - {% endblock %} \ No newline at end of file diff --git a/wqflask/wqflask/templates/show_image.html b/wqflask/wqflask/templates/show_image.html new file mode 100644 index 00000000..521f5414 --- /dev/null +++ b/wqflask/wqflask/templates/show_image.html @@ -0,0 +1,5 @@ +Embedded Image \ No newline at end of file diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 4b7bd639..7fec0456 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import sys @@ -20,6 +21,8 @@ import redis Redis = redis.StrictRedis() import flask +import base64 +import array import sqlalchemy #import config @@ -83,11 +86,18 @@ def index_page(): return render_template("index_page.html") -@app.route("/tmp") -def tmp_page(): +@app.route("/tmp/") +def tmp_page(img_path): print("In tmp_page") + print("img_path:", img_path) initial_start_vars = request.form print("initial_start_vars:", initial_start_vars) + imgfile = open('/home/zas1024/tmp/' + img_path, 'rb') + imgdata = imgfile.read() + imgB64 = imgdata.encode("base64") + bytesarray = array.array('B', imgB64) + return render_template("show_image.html", + img_base64 = bytesarray ) @app.route("/data_sharing") @@ -344,6 +354,15 @@ def marker_regression_page(): 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('/home/zas1024/tmp/' + 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) -- cgit v1.2.3