aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDannyArends2015-09-20 13:05:37 +0200
committerDannyArends2015-09-20 13:05:37 +0200
commit8a5dbce3273ba296a342054e2b2c23866006b5b4 (patch)
treec2ed4aeb3dffdcfc64680e11680aaa92402225f7
parent30f314c1572aeea2576c54c5c4c8f304932a5303 (diff)
downloadgenenetwork2-8a5dbce3273ba296a342054e2b2c23866006b5b4.tar.gz
Using the webqtlConfig.TMPDIR constant and the webqtlUtil.genRandStr function
-rw-r--r--wqflask/wqflask/templates/wgcna_results.html2
-rwxr-xr-xwqflask/wqflask/views.py2
-rw-r--r--wqflask/wqflask/wgcna/wgcna_analysis.py14
3 files changed, 11 insertions, 7 deletions
diff --git a/wqflask/wqflask/templates/wgcna_results.html b/wqflask/wqflask/templates/wgcna_results.html
index 9592c25f..b8a4a4f5 100644
--- a/wqflask/wqflask/templates/wgcna_results.html
+++ b/wqflask/wqflask/templates/wgcna_results.html
@@ -12,7 +12,7 @@
{% endfor %}
</table>
<h2>WGCNA module plot</h2>
- <a href="{{ results['imgurl'] }}">
+ <a href="/tmp/{{ results['imgurl'] }}">
<img alt="Embedded Image" src="data:image/png;base64,
{% for elem in results['imgdata'] -%}
{% print("%c"|format(elem)) %}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 73899316..dc199ab2 100755
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -96,7 +96,7 @@ def tmp_page(img_path):
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')
+ imgfile = open(webqtlConfig.TMPDIR + img_path, 'rb')
imgdata = imgfile.read()
imgB64 = imgdata.encode("base64")
bytesarray = array.array('B', imgB64)
diff --git a/wqflask/wqflask/wgcna/wgcna_analysis.py b/wqflask/wqflask/wgcna/wgcna_analysis.py
index 74bb6f8e..9ab7950b 100644
--- a/wqflask/wqflask/wgcna/wgcna_analysis.py
+++ b/wqflask/wqflask/wgcna/wgcna_analysis.py
@@ -7,6 +7,7 @@ import rpy2.robjects as ro # R Objects
import rpy2.rinterface as ri
from base import webqtlConfig # For paths and stuff
+from utility import webqtlUtil # Random number for the image
import base64
import array
@@ -97,22 +98,24 @@ class WGCNA(object):
# Create block wise modules using WGCNA
network = self.r_blockwiseModules(rM, power = 6, verbose = 3)
+ # Save the network for the GUI
self.results['network'] = network
# How many modules and how many gene per module ?
print(r_table(network[1]))
# The iconic WCGNA plot of the modules in the hanging tree
- self.results['imgurl'] = webqtlConfig.TMPDIR + "WGCNAoutput.png"
- r_png(self.results['imgurl'])
+ self.results['imgurl'] = webqtlUtil.genRandStr("WGCNAoutput_") + ".png"
+ self.results['imgloc'] = webqtlConfig.TMPDIR + self.results['imgurl']
+ r_png(self.results['imgloc'])
mergedColors = self.r_labels2colors(network[1])
- self.r_plotDendroAndColors(network[5][0], mergedColors, "Module colors",dendroLabels = False, hang = 0.03, addGuide = True, guideHang = 0.05)
+ self.r_plotDendroAndColors(network[5][0], mergedColors, "Module colors", dendroLabels = False, hang = 0.03, addGuide = True, guideHang = 0.05)
r_dev_off()
sys.stdout.flush()
def render_image(self, results):
- print("pre-loading imgage results:", self.results['imgurl'])
- imgfile = open(self.results['imgurl'], 'rb')
+ print("pre-loading imgage results:", self.results['imgloc'])
+ imgfile = open(self.results['imgloc'], 'rb')
imgdata = imgfile.read()
imgB64 = imgdata.encode("base64")
bytesarray = array.array('B', imgB64)
@@ -124,6 +127,7 @@ class WGCNA(object):
template_vars["input"] = self.input
template_vars["results"] = self.results
self.render_image(results)
+ sys.stdout.flush()
#r_sink(type = "message") # This restores R output to the stdout/stderr
#r_sink() # We should end the Rpy session more or less
return(dict(template_vars))