aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2015-03-25 16:11:56 +0000
committerzsloan2015-03-25 16:11:56 +0000
commit93dcba89f7e424a759e3177a74b1ce322cdd7c57 (patch)
tree3037a8ccc1812752e0ebbf3454b01d47b53f3d8e /wqflask
parentdecc68a3ba819b69c005cfb42275d85f1e6db9bd (diff)
downloadgenenetwork2-93dcba89f7e424a759e3177a74b1ce322cdd7c57.tar.gz
Pair scan image now loads properly
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/webqtlConfig.py2
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py6
-rw-r--r--wqflask/wqflask/templates/pair_scan_results.html55
-rw-r--r--wqflask/wqflask/templates/show_image.html5
-rwxr-xr-xwqflask/wqflask/views.py23
5 files changed, 38 insertions, 53 deletions
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 %}
-<!-- <link rel="stylesheet" type="text/css" href="/static/new/css/interval_mapping.css" />-->
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" />
<link rel="stylesheet" type="text/css" href="/static/new/css/d3-tip.min.css" />
<link rel="stylesheet" type="text/css" href="/static/new/css/panelutil.css" />
{% endblock %}
+
{% block content %} <!-- Start of body -->
{{ header("Mapping",
@@ -21,7 +21,12 @@
</div>
<div id="chart_container">
<div class="pair_scan_figure" id="pair_scan_figure">
- <img src="/images/{{ pair_scan_filename }}.png">
+ <a href="/tmp/{{ pair_scan_filename }}">
+ <img alt="Embedded Image" src="data:image/png;base64,
+ {% for elem in pair_scan_array -%}
+ {% print("%c"|format(elem)) %}
+ {%- endfor %}
+ " /></a>
</div>
</div>
<div>
@@ -31,30 +36,12 @@
</div>
</div>
- <!-- End of body -->
-
{% endblock %}
{% block js %}
- <script>
- js_data = {{ js_data | safe }}
- </script>
- <!--[if lt IE 9]>
-<!-- <script language="javascript" type="text/javascript" src="/static/packages/jqplot/excanvas.js"></script>-->
- <![endif]-->
<script language="javascript" type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/js_external/d3-tip.min.js"></script>
-<!-- <script language="javascript" type="text/javascript" src="/static/new/packages/jsPDF/jspdf.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/packages/jsPDF/libs/FileSaver.js/FileSaver.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/packages/jsPDF/libs/Blob.js/BlobBuilder.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/packages/jsPDF/jspdf.plugin.standard_fonts_metrics.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/packages/jsPDF/jspdf.plugin.from_html.js"></script>-->
- <script language="javascript" type="text/javascript" src="/static/new/javascript/panelutil.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/javascript/chr_lod_chart.js"></script>
-<!-- <script language="javascript" type="text/javascript" src="/static/new/javascript/manhattan_plot.js"></script>-->
- <script language="javascript" type="text/javascript" src="/static/new/javascript/lod_chart.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/javascript/create_lodchart.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.scientific.js"></script>
@@ -62,30 +49,4 @@
<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 type="text/javascript" charset="utf-8">
- $(document).ready( function () {
- console.time("Creating table");
- $('#qtl_results').dataTable( {
- //"sDom": "<<'span3'l><'span3'T><'span4'f>'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>",
- "sDom": "lTftipr",
- "oTableTools": {
- "aButtons": [
- "copy",
- "print",
- {
- "sExtends": "collection",
- "sButtonText": 'Save <span class="caret" />',
- "aButtons": [ "csv", "xls", "pdf" ]
- }
- ],
- "sSwfPath": "/static/packages/TableTools/media/swf/copy_csv_xls_pdf.swf"
- },
- "iDisplayLength": 50,
- "bLengthChange": true,
- "bDeferRender": true,
- "bSortClasses": false
- } );
- console.timeEnd("Creating table");
- });
- </script>
{% 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 @@
+<img alt="Embedded Image" src="data:image/png;base64,
+{% for elem in img_base64 -%}
+ {% print("%c"|format(elem)) %}
+{%- endfor %}
+" /> \ 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/<img_path>")
+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)