aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Sloan2012-09-14 16:18:47 -0500
committerZachary Sloan2012-09-14 16:18:47 -0500
commit9ac815b8f6977743dacfe767aabdf4523895fe7c (patch)
tree56f4c168831c4ab054f5a6e8944b2082b6256720
parenta979480aae5eaa056c84dc3cb05a5e2443c4fbd0 (diff)
downloadgenenetwork2-9ac815b8f6977743dacfe767aabdf4523895fe7c.tar.gz
Got the dynamic javascript stats table working
-rwxr-xr-xwqflask/base/webqtlFormData.py1
-rwxr-xr-xwqflask/wqflask/show_trait/DataEditingPage.py1
-rw-r--r--wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee51
-rw-r--r--wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js58
-rw-r--r--wqflask/wqflask/templates/search_result_page.html10
-rw-r--r--wqflask/wqflask/templates/trait_data_and_analysis.html4
-rw-r--r--wqflask/wqflask/views.py19
7 files changed, 78 insertions, 66 deletions
diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py
index 9f58d437..a8aef2a5 100755
--- a/wqflask/base/webqtlFormData.py
+++ b/wqflask/base/webqtlFormData.py
@@ -45,6 +45,7 @@ from utility import webqtlUtil
class webqtlFormData:
'Represents data from a WebQTL form page, needed to generate the next page'
+
attrs = ('formID','RISet','genotype','strainlist','allstrainlist',
'suggestive','significance','submitID','identification', 'enablevariance',
'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo')
diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py
index 643db81d..8ee1d9c8 100755
--- a/wqflask/wqflask/show_trait/DataEditingPage.py
+++ b/wqflask/wqflask/show_trait/DataEditingPage.py
@@ -244,6 +244,7 @@ class DataEditingPage(templatePage):
self.sample_groups['primary_only'] = fd.RISet + " Only"
self.sample_groups['other_only'] = "Non-" + fd.RISet
self.sample_groups['all_cases'] = "All Cases"
+ self.js_data = dict(sample_groups = self.sample_groups)
#self.basic_table['columns'] = yaml.load("""
diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee
index 5c153ccb..16dd2571 100644
--- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee
+++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee
@@ -20,7 +20,7 @@ $ ->
$(".stats_mdp").change(stats_mdp_change)
update_stat_values = (the_values)->
- for category in ['primary', 'other', 'all']
+ for category in ['primary_only', 'other_only', 'all_cases']
id = "#" + process_id(category, "mean")
console.log("id:", id)
total = 0
@@ -52,9 +52,9 @@ $ ->
edit_data_change = ->
the_values =
- primary: []
- other: []
- all: []
+ primary_only: []
+ other_only: []
+ all_cases: []
console.log("at beginning:", the_values)
values = $('#value_table').find(".edit_strain_value")
#console.log("values are:", values)
@@ -73,20 +73,23 @@ $ ->
if is_number(real_value) and real_value != ""
real_value = parseFloat(real_value)
if _(category).startsWith("Primary")
- the_values.primary.push(real_value)
+ the_values.primary_only.push(real_value)
else if _(category).startsWith("Other")
- the_values.other.push(real_value)
- the_values.all.push(real_value)
- console.log("torwads end:", the_values)
+ the_values.other_only.push(real_value)
+ the_values.all_cases.push(real_value)
+ console.log("towards end:", the_values)
update_stat_values(the_values)
make_table = ->
header = "<thead><tr><th>&nbsp;</th>"
- for column in basic_table['columns']
- console.log("column:", column)
- the_id = process_id("column", column.t)
- header += """<th id="#{ the_id }">#{ column.n }</th>"""
+ console.log("js_data.sample_groups:", js_data.sample_groups)
+ for key, value of js_data.sample_groups
+ console.log("aa key:", key)
+ console.log("aa value:", value)
+ the_id = process_id("column", key)
+ header += """<th id="#{ the_id }">#{ value }</th>"""
header += "</thead>"
+ console.log("windex header is:", header)
rows = [
{
@@ -114,9 +117,10 @@ $ ->
console.log("rowing")
row_line = """<tr>"""
row_line += """<td id="#{ row.vn }">#{ row.pretty }</td>"""
- for column in basic_table['columns']
- console.log("apple:", column)
- the_id = process_id(column.t, row.vn)
+ console.log("box - js_data.sample_groups:", js_data.sample_groups)
+ for key, value of js_data.sample_groups
+ console.log("apple key:", key)
+ the_id = process_id(key, row.vn)
console.log("the_id:", the_id)
row_line += """<td id="#{ the_id }">foo</td>"""
row_line += """</tr>"""
@@ -152,10 +156,9 @@ $ ->
$('#show_hide_outliers').val("Hide Outliers")
console.log("Should be now Hide Outliers")
-
- ###
- Calculate Correlations Code
- ###
+
+ #Calculate Correlations Code
+
on_corr_method_change = ->
console.log("in beginning of on_corr_method_change")
@@ -181,9 +184,9 @@ $ ->
#
#$('#corr_compute').click(on_corr_submit)
- ###
- End Calculate Correlations Code
- ###
+
+ #End Calculate Correlations Code
+
console.log("before registering show_hide_outliers")
@@ -195,7 +198,7 @@ $ ->
console.log("loaded")
#console.log("basic_table is:", basic_table)
# Add back following two lines later
- #make_table()
- #edit_data_change() # Set the values at the beginning
+ make_table()
+ edit_data_change() # Set the values at the beginning
#$("#all-mean").html('foobar8')
console.log("end")
diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js
index 55acbada..0b49dde3 100644
--- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js
+++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js
@@ -29,7 +29,7 @@
$(".stats_mdp").change(stats_mdp_change);
update_stat_values = function(the_values) {
var category, current_mean, current_n_of_samples, id, in_box, n_of_samples, the_mean, total, value, _i, _j, _len, _len1, _ref, _ref1, _results;
- _ref = ['primary', 'other', 'all'];
+ _ref = ['primary_only', 'other_only', 'all_cases'];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
category = _ref[_i];
@@ -72,9 +72,9 @@
edit_data_change = function() {
var category, checkbox, checked, real_value, row, the_values, value, values, _i, _len;
the_values = {
- primary: [],
- other: [],
- all: []
+ primary_only: [],
+ other_only: [],
+ all_cases: []
};
console.log("at beginning:", the_values);
values = $('#value_table').find(".edit_strain_value");
@@ -94,27 +94,30 @@
if (is_number(real_value) && real_value !== "") {
real_value = parseFloat(real_value);
if (_(category).startsWith("Primary")) {
- the_values.primary.push(real_value);
+ the_values.primary_only.push(real_value);
} else if (_(category).startsWith("Other")) {
- the_values.other.push(real_value);
+ the_values.other_only.push(real_value);
}
- the_values.all.push(real_value);
+ the_values.all_cases.push(real_value);
}
}
- console.log("torwads end:", the_values);
+ console.log("towards end:", the_values);
return update_stat_values(the_values);
};
make_table = function() {
- var column, header, row, row_line, rows, table, the_id, the_rows, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
+ var header, key, row, row_line, rows, table, the_id, the_rows, value, _i, _len, _ref, _ref1;
header = "<thead><tr><th>&nbsp;</th>";
- _ref = basic_table['columns'];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- column = _ref[_i];
- console.log("column:", column);
- the_id = process_id("column", column.t);
- header += "<th id=\"" + the_id + "\">" + column.n + "</th>";
+ console.log("js_data.sample_groups:", js_data.sample_groups);
+ _ref = js_data.sample_groups;
+ for (key in _ref) {
+ value = _ref[key];
+ console.log("aa key:", key);
+ console.log("aa value:", value);
+ the_id = process_id("column", key);
+ header += "<th id=\"" + the_id + "\">" + value + "</th>";
}
header += "</thead>";
+ console.log("windex header is:", header);
rows = [
{
vn: "n_of_samples",
@@ -133,16 +136,17 @@
console.log("rows are:", rows);
the_rows = "<tbody>";
console.log("length of rows:", rows.length);
- for (_j = 0, _len1 = rows.length; _j < _len1; _j++) {
- row = rows[_j];
+ for (_i = 0, _len = rows.length; _i < _len; _i++) {
+ row = rows[_i];
console.log("rowing");
row_line = "<tr>";
row_line += "<td id=\"" + row.vn + "\">" + row.pretty + "</td>";
- _ref1 = basic_table['columns'];
- for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
- column = _ref1[_k];
- console.log("apple:", column);
- the_id = process_id(column.t, row.vn);
+ console.log("box - js_data.sample_groups:", js_data.sample_groups);
+ _ref1 = js_data.sample_groups;
+ for (key in _ref1) {
+ value = _ref1[key];
+ console.log("apple key:", key);
+ the_id = process_id(key, row.vn);
console.log("the_id:", the_id);
row_line += "<td id=\"" + the_id + "\">foo</td>";
}
@@ -186,10 +190,6 @@
return console.log("Should be now Hide Outliers");
}
};
- /*
- Calculate Correlations Code
- */
-
on_corr_method_change = function() {
var corr_method;
console.log("in beginning of on_corr_method_change");
@@ -199,16 +199,14 @@
return $('#' + corr_method + "_r_desc").show().effect("highlight");
};
$('select[name=corr_method]').change(on_corr_method_change);
- /*
- End Calculate Correlations Code
- */
-
console.log("before registering show_hide_outliers");
$('#show_hide_outliers').click(show_hide_outliers);
console.log("after registering show_hide_outliers");
_.mixin(_.str.exports());
$('#value_table').change(edit_data_change);
console.log("loaded");
+ make_table();
+ edit_data_change();
return console.log("end");
});
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 09094fc6..afcd06d0 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -39,7 +39,7 @@
<P>To add one or more records to your Selection window, use the checkbox and then click the <STRONG>Add to Collection</STRONG> button.</P>
</BLOCKQUOTE>
- <FORM METHOD="GET" ACTION="/search" ENCTYPE="multipart/form-data" NAME="showDatabaseBXD">
+ <FORM METHOD="GET" ACTION="/search" ENCTYPE="multipart/form-data" NAME="show_trait">
<INPUT TYPE="hidden" NAME="database" VALUE="_">
<INPUT TYPE="hidden" NAME="incparentsf1" VALUE="ON">
@@ -54,16 +54,16 @@
<TABLE border="0" cellpadding="0" cellspacing="2" width="20%">
<TR>
<TD width="25%">
- <A HREF="#" onClick="checkAll(document.getElementsByName('showDatabaseBXD')[0]);">
+ <A HREF="#" onClick="checkAll(document.getElementsByName('show_trait')[0]);">
<IMG src="/images/select_all2_final.jpg" alt="Select All" name="selectall" style="border:none;" title="Select All"></A>
</TD>
<TD width="25%">
- <A HREF="#" onClick="checkNone(document.getElementsByName('showDatabaseBXD')[0]);">
+ <A HREF="#" onClick="checkNone(document.getElementsByName('show_trait')[0]);">
<IMG src="/images/select_none2_final.jpg" alt="Select None" style="border:none;" title="Select None">
</A>
</TD>
<TD width="25%">
- <A HREF="#" onClick="checkInvert(document.getElementsByName('showDatabaseBXD')[0]);">
+ <A HREF="#" onClick="checkInvert(document.getElementsByName('show_trait')[0]);">
<IMG src="/images/invert_selection2_final.jpg" alt="Invert Selection" name="selectinvert" style="border:none;" title="Invert Selection">
</A>
</TD>
@@ -173,7 +173,7 @@
</TD>
<TD class="fs12 fwn b1 c222">
{# <A HREF="javascript:showDatabase3('{{ thisFormName }}','{{thisTrait.db.name}}','{{ thisTrait.name }}','{{ thisTrait.cellid }}')" class="fs12 fwn"> - </a> #}
- <a href="{{ url_for('showDatabaseBXD', database=thisTrait.db.name, ProbeSetID=thisTrait.name, incparentsf1='ON', RISet='BXD')}}" class="fs12 fwn">
+ <a href="{{ url_for('show_trait', database=thisTrait.db.name, ProbeSetID=thisTrait.name, incparentsf1='ON', RISet='BXD')}}" class="fs12 fwn">
{{ thisTrait.name.upper() }}
</a>
</TD>
diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html
index c25db7c4..59dfedb3 100644
--- a/wqflask/wqflask/templates/trait_data_and_analysis.html
+++ b/wqflask/wqflask/templates/trait_data_and_analysis.html
@@ -1305,8 +1305,8 @@
</td>
</tr>
-<!-- <script>
- basic_table = {{ basic_table | safe }}
+ <script>
+ js_data = {{ js_data | safe }}
</script>-->
<script type="text/javascript" src="/static/new/js_external/underscore-min.js"></script>-->
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 677c7f43..1b60f255 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -1,5 +1,8 @@
from __future__ import absolute_import, division, print_function
+import json
+import yaml
+
import flask
from wqflask import app
@@ -16,10 +19,9 @@ from base import webqtlFormData
from pprint import pformat as pf
-import yaml
-
print("latest blue")
+
@app.route("/")
def index_page():
print("Sending index_page")
@@ -41,6 +43,7 @@ def data_sharing():
info=info,
htmlfilelist=htmlfilelist)
+
@app.route("/search")
def search():
if 'info_database' in request.args:
@@ -67,14 +70,19 @@ def whats_new():
print("\nnews_item is: %s\n" % (news_item))
return render_template("whats_new.html", news_items=news_items)
-@app.route("/showDatabaseBXD")
-def showDatabaseBXD():
+
+@app.route("/show_trait")
+def show_trait():
# Here it's currently too complicated not to use an fd that is a webqtlFormData
fd = webqtlFormData.webqtlFormData(request.args)
template_vars = show_trait_page.ShowTraitPage(fd)
- print("showDatabaseBXD template_vars:", pf(template_vars.__dict__))
+
+ template_vars.js_data = json.dumps(template_vars.js_data)
+
+ print("show_trait template_vars:", pf(template_vars.__dict__))
return render_template("trait_data_and_analysis.html", **template_vars.__dict__)
+
@app.route("/corr_compute", methods=('POST',))
def corr_compute():
#print("In corr_compute, request.args is:", pf(request.form))
@@ -84,6 +92,7 @@ def corr_compute():
print("Made it to rendering")
return render_template("corr_compute.html", **template_vars.__dict__)
+
# Todo: Can we simplify this? -Sam
def sharing_info_page():
print("In sharing_info_page")