aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/trait.py25
-rw-r--r--wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee39
-rw-r--r--wqflask/wqflask/static/new/javascript/get_traits_from_collection.js39
3 files changed, 77 insertions, 26 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 9e4f0944..712d9af5 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -12,10 +12,13 @@ from base.data_set import create_dataset
from dbFunction import webqtlDatabaseFunction
from utility import webqtlUtil
+from wqflask import app
+
+import simplejson as json
from MySQLdb import escape_string as escape
from pprint import pformat as pf
-from flask import Flask, g
+from flask import Flask, g, request
def print_mem(stage=""):
mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
@@ -70,6 +73,7 @@ class GeneralTrait(object):
Actual turning into json doesn't happen here though"""
return dict(name=self.name,
+ dataset=self.dataset.name,
description=self.description_display,
mean=self.mean)
@@ -626,3 +630,22 @@ class GeneralTrait(object):
ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation))
ZValue = ZValue*sqrt(self.overlap-3)
self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue)))
+
+
+
+@app.route("/trait/get_sample_data")
+def get_sample_data():
+ params = request.args
+ trait = params['trait']
+ dataset = params['dataset']
+
+ trait_ob = GeneralTrait(name=trait, dataset_name=dataset)
+
+ return json.dumps({key: value.value for key, value in trait_ob.data.iteritems() })
+
+ #jsonable_sample_data = {}
+ #for sample in trait_ob.data.iteritems():
+ # jsonable_sample_data[sample] = trait_ob.data[sample].value
+ #
+ #return jsonable_sample_data
+ \ No newline at end of file
diff --git a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
index c178d60d..f1d41cbe 100644
--- a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
+++ b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
@@ -1,50 +1,60 @@
console.log("before get_traits_from_collection")
+# Going to be used to hold collection list
+# So we can repopulate it when the back button is clicked
+collection_list = null
collection_click = () ->
console.log("Clicking on:", $(this))
this_collection_url = $(this).find('.collection_name').prop("href")
this_collection_url += "&json"
console.log("this_collection_url", this_collection_url)
+ collection_list = $("#collections_holder").html()
$.ajax(
dataType: "json",
url: this_collection_url,
success: process_traits
)
+
+trait_click = () ->
+ console.log("Clicking on:", $(this))
+ trait = $(this).find('.trait').text()
+ dataset = $(this).find('.dataset').text()
+ this_trait_url = "/trait/get_sample_data?trait="+trait+"&dataset="+dataset
+ console.log("this_trait_url", this_trait_url)
+ $.ajax(
+ dataType: "json",
+ url: this_trait_url,
+ success: color_by_trait
+ )
-# Going to be used to hold collection list
-# So we can repopulate it when the back button is clicked
-collection_list = null
+color_by_trait = (trait_sample_data, textStatus, jqXHR) ->
+ console.log('in color_by_trait:', trait_sample_data)
process_traits = (trait_data, textStatus, jqXHR) ->
console.log('in process_traits with trait_data:', trait_data)
- the_html = "<div id='collections_holder'>"
-
- the_html += "<button id='back_to_collections' class='btn btn-inverse btn-small'>"
+ the_html = "<button id='back_to_collections' class='btn btn-inverse btn-small'>"
the_html += "<i class='icon-white icon-arrow-left'></i> Back </button>"
the_html += "<table class='table table-hover'>"
- the_html += "<thead><tr><th>Record</th><th>Description</th><th>Mean</th></tr></thead>"
+ the_html += "<thead><tr><th>Record</th><th>Data Set</th><th>Description</th><th>Mean</th></tr></thead>"
the_html += "<tbody>"
for trait in trait_data
- the_html += "<tr><td>#{ trait.name }</td>"
+ the_html += "<tr class='trait_line'><td class='trait'>#{ trait.name }</td>"
+ the_html += "<td class='dataset'>#{ trait.dataset }</td>"
the_html += "<td>#{ trait.description }</td>"
the_html += "<td>#{ trait.mean or '&nbsp;' }</td></tr>"
the_html += "</tbody>"
the_html += "</table>"
- the_html += "</div>"
- collection_list = $("#collections_holder").html()
- $("#collections_holder").replaceWith(the_html)
+ $("#collections_holder").html(the_html)
$('#collections_holder').colorbox.resize()
back_to_collections = () ->
console.log("collection_list:", collection_list)
- $("#collections_holder").replaceWith(collection_list)
-
- $("#trait_table").wrap("<div id='collections_holder'></div>")
+ $("#collections_holder").html(collection_list)
$(document).on("click", ".collection_line", collection_click)
$('#collections_holder').colorbox.resize()
@@ -53,4 +63,5 @@ $ ->
console.log("inside get_traits_from_collection")
$(document).on("click", ".collection_line", collection_click)
+ $(document).on("click", ".trait_line", trait_click)
$(document).on("click", "#back_to_collections", back_to_collections)
diff --git a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
index c0fb7c54..104c411d 100644
--- a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
+++ b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
@@ -1,15 +1,18 @@
// Generated by CoffeeScript 1.6.1
(function() {
- var back_to_collections, collection_click, collection_list, process_traits;
+ var back_to_collections, collection_click, collection_list, color_by_trait, process_traits, trait_click;
console.log("before get_traits_from_collection");
+ collection_list = null;
+
collection_click = function() {
var this_collection_url;
console.log("Clicking on:", $(this));
this_collection_url = $(this).find('.collection_name').prop("href");
this_collection_url += "&json";
console.log("this_collection_url", this_collection_url);
+ collection_list = $("#collections_holder").html();
return $.ajax({
dataType: "json",
url: this_collection_url,
@@ -17,35 +20,48 @@
});
};
- collection_list = null;
+ trait_click = function() {
+ var dataset, this_trait_url, trait;
+ console.log("Clicking on:", $(this));
+ trait = $(this).find('.trait').text();
+ dataset = $(this).find('.dataset').text();
+ this_trait_url = "/trait/get_sample_data?trait=" + trait + "&dataset=" + dataset;
+ console.log("this_trait_url", this_trait_url);
+ return $.ajax({
+ dataType: "json",
+ url: this_trait_url,
+ success: color_by_trait
+ });
+ };
+
+ color_by_trait = function(trait_sample_data, textStatus, jqXHR) {
+ return console.log('in color_by_trait:', trait_sample_data);
+ };
process_traits = function(trait_data, textStatus, jqXHR) {
var the_html, trait, _i, _len;
console.log('in process_traits with trait_data:', trait_data);
- the_html = "<div id='collections_holder'>";
- the_html += "<button id='back_to_collections' class='btn btn-inverse btn-small'>";
+ the_html = "<button id='back_to_collections' class='btn btn-inverse btn-small'>";
the_html += "<i class='icon-white icon-arrow-left'></i> Back </button>";
the_html += "<table class='table table-hover'>";
- the_html += "<thead><tr><th>Record</th><th>Description</th><th>Mean</th></tr></thead>";
+ the_html += "<thead><tr><th>Record</th><th>Data Set</th><th>Description</th><th>Mean</th></tr></thead>";
the_html += "<tbody>";
for (_i = 0, _len = trait_data.length; _i < _len; _i++) {
trait = trait_data[_i];
- the_html += "<tr><td>" + trait.name + "</td>";
+ the_html += "<tr class='trait_line'><td class='trait'>" + trait.name + "</td>";
+ the_html += "<td class='dataset'>" + trait.dataset + "</td>";
the_html += "<td>" + trait.description + "</td>";
the_html += "<td>" + (trait.mean || '&nbsp;') + "</td></tr>";
}
the_html += "</tbody>";
the_html += "</table>";
- the_html += "</div>";
- collection_list = $("#collections_holder").html();
- $("#collections_holder").replaceWith(the_html);
+ $("#collections_holder").html(the_html);
return $('#collections_holder').colorbox.resize();
};
back_to_collections = function() {
console.log("collection_list:", collection_list);
- $("#collections_holder").replaceWith(collection_list);
- $("#trait_table").wrap("<div id='collections_holder'></div>");
+ $("#collections_holder").html(collection_list);
$(document).on("click", ".collection_line", collection_click);
return $('#collections_holder').colorbox.resize();
};
@@ -53,6 +69,7 @@
$(function() {
console.log("inside get_traits_from_collection");
$(document).on("click", ".collection_line", collection_click);
+ $(document).on("click", ".trait_line", trait_click);
return $(document).on("click", "#back_to_collections", back_to_collections);
});