aboutsummaryrefslogtreecommitdiff
path: root/wqflask/wqflask
diff options
context:
space:
mode:
authorPjotr Prins2016-06-16 17:08:50 +0000
committerPjotr Prins2016-06-16 17:08:50 +0000
commiteb84f7c0e384e08b810e052fd3935f6d977b7ea2 (patch)
tree466a2daf1583aa9fb34a9f8b4214874fe820fdde /wqflask/wqflask
parent08800d16cccb03685a4f325fa950a402d1d5b455 (diff)
downloadgenenetwork2-eb84f7c0e384e08b810e052fd3935f6d977b7ea2.tar.gz
Introduce behaviour parameters to facilitate development
Diffstat (limited to 'wqflask/wqflask')
-rw-r--r--wqflask/wqflask/search_results.py2
-rw-r--r--wqflask/wqflask/views.py52
2 files changed, 30 insertions, 24 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 8a0485b3..39f6d62c 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -31,7 +31,7 @@ from base.data_set import create_dataset
from base.trait import GeneralTrait
from wqflask import parser
from wqflask import do_search
-from utility import webqtlUtil
+from utility import webqtlUtil,tools
from dbFunction import webqtlDatabaseFunction
from utility import formatting
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index df1f77bc..ba250d4f 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -52,7 +52,7 @@ from wqflask.wgcna import wgcna_analysis
from wqflask.ctl import ctl_analysis
from utility import temp_data
-from utility.tools import TEMPDIR
+from utility.tools import TEMPDIR,USE_REDIS
from base import webqtlFormData
from base.webqtlConfig import GENERATED_IMAGE_DIR
@@ -138,11 +138,16 @@ def search_page():
else:
key = "search_results:v1:" + json.dumps(request.args, sort_keys=True)
print("key is:", pf(key))
- with Bench("Loading cache"):
- result = Redis.get(key)
+ if USE_REDIS:
+ with Bench("Trying Redis cache"):
+ result = Redis.get(key)
+ else:
+ print("Skipping Redis cache (USE_REDIS=False)")
+ result = None
if result:
- print("Cache hit!!!")
+ print("Cache hit on search results!!!")
+ print("USE_REDIS=",USE_REDIS)
with Bench("Loading results"):
result = pickle.loads(result)
else:
@@ -152,8 +157,9 @@ def search_page():
result = the_search.__dict__
print("result: ", pf(result))
- Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL))
- Redis.expire(key, 60*60)
+ if USE_REDIS:
+ Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL))
+ Redis.expire(key, 60*60)
if result['search_term_exists']:
return render_template("search_result_page.html", **result)
@@ -168,7 +174,7 @@ def gsearchact():
return render_template("gsearch_gene.html", **result)
elif type == "phenotype":
return render_template("gsearch_pheno.html", **result)
-
+
@app.route("/gsearch_updating", methods=('POST',))
def gsearch_updating():
print("REQUEST ARGS:", request.values)
@@ -179,7 +185,7 @@ def gsearch_updating():
# return render_template("gsearch_gene_updating.html", **result)
# elif type == "phenotype":
# return render_template("gsearch_pheno.html", **result)
-
+
@app.route("/docedit")
def docedit():
doc = docs.Docs(request.args['entry'])
@@ -294,13 +300,13 @@ def export_trait_csv():
return Response(csv_data,
mimetype='text/csv',
headers={"Content-Disposition":"attachment;filename=sample_data.csv"})
-
+
@app.route('/export_perm_data', methods=('POST',))
def export_perm_data():
"""CSV file consisting of the permutation data for the mapping results"""
num_perm = float(request.form['num_perm'])
perm_data = json.loads(request.form['perm_results'])
-
+
buff = StringIO.StringIO()
writer = csv.writer(buff)
writer.writerow(["Suggestive LRS (p=0.63) = " + str(perm_data[int(num_perm*0.37-1)])])
@@ -338,10 +344,10 @@ def show_trait_page():
@app.route("/heatmap", methods=('POST',))
def heatmap_page():
print("In heatmap, request.form is:", pf(request.form))
-
+
start_vars = request.form
temp_uuid = uuid.uuid4()
-
+
traits = [trait.strip() for trait in start_vars['trait_list'].split(',')]
if traits[0] != "":
version = "v5"
@@ -349,33 +355,33 @@ def heatmap_page():
print("key is:", pf(key))
with Bench("Loading cache"):
result = Redis.get(key)
-
+
if result:
print("Cache hit!!!")
with Bench("Loading results"):
result = pickle.loads(result)
-
+
else:
print("Cache miss!!!")
-
+
template_vars = heatmap.Heatmap(request.form, temp_uuid)
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
indent=" ")
-
+
result = template_vars.__dict__
for item in template_vars.__dict__.keys():
print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item))
-
+
pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)
print("pickled result length:", len(pickled_result))
Redis.set(key, pickled_result)
Redis.expire(key, 60*60)
-
+
with Bench("Rendering template"):
rendered_template = render_template("heatmap.html", **result)
-
+
else:
rendered_template = render_template("empty_collection.html", **{'tool':'Heatmap'})
@@ -468,18 +474,18 @@ def marker_regression_page():
imgB64 = imgdata.encode("base64")
bytesarray = array.array('B', imgB64)
result['pair_scan_array'] = bytesarray
- rendered_template = render_template("pair_scan_results.html", **result)
+ rendered_template = render_template("pair_scan_results.html", **result)
else:
#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)
@@ -542,7 +548,7 @@ def corr_matrix_page():
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
indent=" ")
-
+
return render_template("correlation_matrix.html", **template_vars.__dict__)
else:
return render_template("empty_collection.html", **{'tool':'Correlation Matrix'})