aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchristian2016-08-10 16:50:40 +0200
committerchristian2016-08-10 16:50:40 +0200
commit0f53cad8629a7f2d15b3f49d305949da13fb3e8a (patch)
treeab367ced6d4c319c53232530b5df4e89aebbf298
parent5f1a06f531a2da78360bd121707d911b6e4abb88 (diff)
downloadgenenetwork2-0f53cad8629a7f2d15b3f49d305949da13fb3e8a.tar.gz
Serve QTL data as CSV
-rw-r--r--wqflask/wqflask/static/new/javascript/chr_lod_chart.js2
-rw-r--r--wqflask/wqflask/views.py17
2 files changed, 14 insertions, 5 deletions
diff --git a/wqflask/wqflask/static/new/javascript/chr_lod_chart.js b/wqflask/wqflask/static/new/javascript/chr_lod_chart.js
index 01bb4601..6603b534 100644
--- a/wqflask/wqflask/static/new/javascript/chr_lod_chart.js
+++ b/wqflask/wqflask/static/new/javascript/chr_lod_chart.js
@@ -65,8 +65,6 @@ Chr_Lod_Chart = (function() {
} else {
this_chr = result.chr;
}
- console.log("this_chr is:", this_chr);
- console.log("@chr[0] is:", parseInt(this.chr[0]));
if (this_chr > parseInt(this.chr[0])) {
break;
}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index fa64a7b7..0a2fa83a 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -16,6 +16,7 @@ import uuid
import simplejson as json
import yaml
+import csv
#Switching from Redis to StrictRedis; might cause some issues
import redis
@@ -463,15 +464,24 @@ def marker_regression_page():
with Bench("Total time in MarkerRegression"):
template_vars = marker_regression.MarkerRegression(start_vars, temp_uuid)
+
+ qtl_results = template_vars.js_data['qtl_results']
+
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
indent=" ")
+
json_filename = webqtlUtil.genRandStr("") + ".json"
+ with open(GENERATED_TEXT_DIR + "/" + json_filename, "wb") as json_file:
+ json_file.write(template_vars.js_data)
- json_file = open(GENERATED_TEXT_DIR + "/" + json_filename, "w")
- json_file.write(template_vars.js_data)
- json_file.close()
+ csv_filename = webqtlUtil.genRandStr("") + ".csv"
+ with open(GENERATED_TEXT_DIR + "/" + csv_filename, "wb") as csv_file:
+ writer = csv.writer(csv_file)
+ writer.writerow(("Locus", "Chr", "Mb", "LOD"))
+ for (row) in qtl_results:
+ writer.writerow((row["name"], row["chr"], row["Mb"], row["lod_score"]))
result = template_vars.__dict__
@@ -494,6 +504,7 @@ def marker_regression_page():
gn1_template_vars = marker_regression_gn1.MarkerRegression(result).__dict__
gn1_template_vars['json_filename'] = json_filename;
+ gn1_template_vars['csv_filename'] = csv_filename;
pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)
logger.info("pickled result length:", len(pickled_result))