From fe9082941a9c3a7815fb986a4717144f3ae7c021 Mon Sep 17 00:00:00 2001
From: Zachary Sloan
Date: Tue, 2 Oct 2012 17:24:09 -0500
Subject: Finished getting the dropdowns for the black samples by attribute
value function working
---
wqflask/wqflask/show_trait/SampleList.py | 4 +-
wqflask/wqflask/show_trait/show_trait.py | 103 ++++-----
.../static/new/javascript/show_trait.coffee | 28 ++-
.../wqflask/static/new/javascript/show_trait.js | 236 +++++++++++++++++++++
wqflask/wqflask/templates/show_trait.html | 16 +-
wqflask/wqflask/views.py | 43 ++--
6 files changed, 361 insertions(+), 69 deletions(-)
create mode 100644 wqflask/wqflask/static/new/javascript/show_trait.js
diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py
index 62bc63c3..d39559d3 100644
--- a/wqflask/wqflask/show_trait/SampleList.py
+++ b/wqflask/wqflask/show_trait/SampleList.py
@@ -24,7 +24,7 @@ class SampleList(object):
self.sample_list = [] # The actual list
- self.calc_attributes()
+ self.get_attributes()
print("camera: attributes are:", pf(self.attributes))
@@ -85,7 +85,7 @@ class SampleList(object):
sample.outlier = False
- def calc_attributes(self):
+ def get_attributes(self):
"""Finds which extra attributes apply to this dataset"""
#ZS: Id and name values for this trait's extra attributes
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 743e4ad6..9bad6154 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -161,7 +161,10 @@ class ShowTrait(templatePage):
self.sample_group_types['primary_only'] = fd.RISet + " Only"
self.sample_group_types['other_only'] = "Non-" + fd.RISet
self.sample_group_types['all_cases'] = "All Cases"
- self.js_data = dict(sample_groups = self.sample_group_types)
+ js_data = dict(sample_groups = self.sample_group_types,
+ attribute_names = self.sample_groups[0].attributes)
+ print("js_data:", pf(js_data))
+ self.js_data = js_data
def get_this_trait(self):
@@ -989,55 +992,55 @@ class ShowTrait(templatePage):
except:
plotTitle = str(this_trait.name)
- #normalplot_img = BasicStatisticsFunctions.plotNormalProbability(vals=vals, RISet=fd.RISet, title=plotTitle, specialStrains=specialStrains)
- #normalplot.append(HT.TR(HT.TD(normalplot_img)))
- #normalplot.append(HT.TR(HT.TD(HT.BR(),HT.BR(),"This plot evaluates whether data are \
- #normally distributed. Different symbols represent different groups.",HT.BR(),HT.BR(),
- #"More about ", HT.Href(url="http://en.wikipedia.org/wiki/Normal_probability_plot",
- # target="_blank", text="Normal Probability Plots"), " and more about interpreting these plots from the ", HT.Href(url="/glossary.html#normal_probability", target="_blank", text="glossary"))))
- #normalplot_container.append(normalplot)
- #normalplot_div.append(normalplot_container)
- #stats_container.append(normalplot_div)
-
- #boxplot_div = HT.Div(id="statstabs-2")
- #boxplot_container = HT.Paragraph()
- #boxplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
- #boxplot_img, boxplot_link = BasicStatisticsFunctions.plotBoxPlot(vals)
- #boxplot.append(HT.TR(HT.TD(boxplot_img, HT.P(), boxplot_link, align="left")))
- #boxplot_container.append(boxplot)
- #boxplot_div.append(boxplot_container)
- #stats_container.append(boxplot_div)
-
-
- #barName_div = HT.Div(id="statstabs-3")
- #barName_container = HT.Paragraph()
- #barName = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
- #barName_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="name")
- #barName.append(HT.TR(HT.TD(barName_img)))
- #barName_container.append(barName)
- #barName_div.append(barName_container)
- #stats_container.append(barName_div)
- #
- #barRank_div = HT.Div(id="statstabs-4")
- #barRank_container = HT.Paragraph()
- #barRank = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
- #barRank_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="rank")
- #barRank.append(HT.TR(HT.TD(barRank_img)))
- #barRank_container.append(barRank)
- #barRank_div.append(barRank_container)
- #stats_container.append(barRank_div)
-
- # stats_cell.append(stats_container)
- #
- #stats_script.append(stats_script_text)
- #
- #submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2")
- #stats_row.append(stats_cell)
-
- #submitTable.append(stats_row)
- #submitTable.append(stats_script)
-
- #title2Body.append(submitTable)
+ #normalplot_img = BasicStatisticsFunctions.plotNormalProbability(vals=vals, RISet=fd.RISet, title=plotTitle, specialStrains=specialStrains)
+ #normalplot.append(HT.TR(HT.TD(normalplot_img)))
+ #normalplot.append(HT.TR(HT.TD(HT.BR(),HT.BR(),"This plot evaluates whether data are \
+ #normally distributed. Different symbols represent different groups.",HT.BR(),HT.BR(),
+ #"More about ", HT.Href(url="http://en.wikipedia.org/wiki/Normal_probability_plot",
+ # target="_blank", text="Normal Probability Plots"), " and more about interpreting these plots from the ", HT.Href(url="/glossary.html#normal_probability", target="_blank", text="glossary"))))
+ #normalplot_container.append(normalplot)
+ #normalplot_div.append(normalplot_container)
+ #stats_container.append(normalplot_div)
+
+ #boxplot_div = HT.Div(id="statstabs-2")
+ #boxplot_container = HT.Paragraph()
+ #boxplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+ #boxplot_img, boxplot_link = BasicStatisticsFunctions.plotBoxPlot(vals)
+ #boxplot.append(HT.TR(HT.TD(boxplot_img, HT.P(), boxplot_link, align="left")))
+ #boxplot_container.append(boxplot)
+ #boxplot_div.append(boxplot_container)
+ #stats_container.append(boxplot_div)
+
+
+ #barName_div = HT.Div(id="statstabs-3")
+ #barName_container = HT.Paragraph()
+ #barName = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+ #barName_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="name")
+ #barName.append(HT.TR(HT.TD(barName_img)))
+ #barName_container.append(barName)
+ #barName_div.append(barName_container)
+ #stats_container.append(barName_div)
+ #
+ #barRank_div = HT.Div(id="statstabs-4")
+ #barRank_container = HT.Paragraph()
+ #barRank = HT.TableLite(cellspacing=0, cellpadding=0, width="100%")
+ #barRank_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="rank")
+ #barRank.append(HT.TR(HT.TD(barRank_img)))
+ #barRank_container.append(barRank)
+ #barRank_div.append(barRank_container)
+ #stats_container.append(barRank_div)
+
+ # stats_cell.append(stats_container)
+ #
+ #stats_script.append(stats_script_text)
+ #
+ #submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2")
+ #stats_row.append(stats_cell)
+
+ #submitTable.append(stats_row)
+ #submitTable.append(stats_script)
+
+ #title2Body.append(submitTable)
def build_correlation_tools(self, fd, this_trait):
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee
index 803045d5..a91e9681 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee
@@ -69,7 +69,7 @@ $ ->
make_table = ->
header = " "
console.log("js_data.sample_groups:", js_data.sample_groups)
- for key, value of js_data.sample_groups
+ for own key, value of js_data.sample_groups
console.log("aa key:", key)
console.log("aa value:", value)
the_id = process_id("column", key)
@@ -108,7 +108,7 @@ $ ->
row_line = """"""
row_line += """ #{ row.pretty } """
console.log("box - js_data.sample_groups:", js_data.sample_groups)
- for key, value of js_data.sample_groups
+ for own 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)
@@ -166,6 +166,30 @@ $ ->
#End Calculate Correlations Code
+ #Populate Samples Attribute Values Code
+
+ create_value_dropdown = (value) ->
+ return """"""
+
+ populate_sample_attributes_values_dropdown = ->
+ console.log("in beginning of psavd")
+ $('#attribute_values').empty()
+ sample_attributes = {}
+ for own key, attribute_info of js_data.attribute_names
+ sample_attributes[attribute_info.name] = attribute_info.distinct_values
+ console.log("[visa] attributes is:", sample_attributes)
+ selected_attribute = $('#exclude_menu').val()
+ for value in sample_attributes[selected_attribute]
+ $(create_value_dropdown(value))
+ .appendTo($('#attribute_values'))
+
+ # Must run once at beginning
+ populate_sample_attributes_values_dropdown()
+ $('#exclude_menu').change(populate_sample_attributes_values_dropdown)
+
+
+
+ #End Populate Samples Attribute Values Code
console.log("before registering show_hide_outliers")
$('#show_hide_outliers').click(show_hide_outliers)
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
new file mode 100644
index 00000000..039a5e04
--- /dev/null
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -0,0 +1,236 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var is_number,
+ __hasProp = {}.hasOwnProperty,
+ __slice = [].slice;
+
+ console.log("start_b");
+
+ is_number = function(o) {
+ return !isNaN((o - 0) && o !== null);
+ };
+
+ $(function() {
+ var change_stats_value, create_value_dropdown, edit_data_change, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, show_hide_outliers, stats_mdp_change, update_stat_values;
+ hide_tabs = function(start) {
+ var x, _i, _results;
+ _results = [];
+ for (x = _i = start; start <= 10 ? _i <= 10 : _i >= 10; x = start <= 10 ? ++_i : --_i) {
+ _results.push($("#stats_tabs" + x).hide());
+ }
+ return _results;
+ };
+ hide_tabs(1);
+ stats_mdp_change = function() {
+ var selected;
+ selected = $(this).val();
+ hide_tabs(0);
+ return $("#stats_tabs" + selected).show();
+ };
+ $(".stats_mdp").change(stats_mdp_change);
+ change_stats_value = function(sample_sets, category, value_type, decimal_places) {
+ var current_value, id, in_box, the_value;
+ id = "#" + process_id(category, value_type);
+ console.log("the_id:", id);
+ in_box = $(id).html;
+ current_value = parseFloat($(in_box)).toFixed(decimal_places);
+ the_value = sample_sets[category][value_type]();
+ if (decimal_places > 0) {
+ the_value = the_value.toFixed(decimal_places);
+ }
+ if (the_value !== current_value) {
+ return $(id).html(the_value).effect("highlight");
+ }
+ };
+ update_stat_values = function(sample_sets) {
+ var category, stat, _i, _len, _ref, _results;
+ _ref = ['primary_only', 'other_only', 'all_cases'];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ category = _ref[_i];
+ change_stats_value(sample_sets, category, "n_of_samples", 0);
+ _results.push((function() {
+ var _j, _len1, _ref1, _results1;
+ _ref1 = ["mean", "median", "std_dev", "std_error"];
+ _results1 = [];
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ stat = _ref1[_j];
+ _results1.push(change_stats_value(sample_sets, category, stat, 2));
+ }
+ return _results1;
+ })());
+ }
+ return _results;
+ };
+ edit_data_change = function() {
+ var category, checkbox, checked, real_value, row, sample_sets, value, values, _i, _len;
+ sample_sets = {
+ primary_only: new Stats([]),
+ other_only: new Stats([]),
+ all_cases: new Stats([])
+ };
+ console.log("at beginning:", sample_sets);
+ values = $('#value_table').find(".edit_sample_value");
+ for (_i = 0, _len = values.length; _i < _len; _i++) {
+ value = values[_i];
+ real_value = $(value).val();
+ row = $(value).closest("tr");
+ category = row[0].id;
+ checkbox = $(row).find(".edit_sample_checkbox");
+ checked = $(checkbox).attr('checked');
+ if (checked && is_number(real_value) && real_value !== "") {
+ real_value = parseFloat(real_value);
+ if (_(category).startsWith("Primary")) {
+ sample_sets.primary_only.add_value(real_value);
+ } else if (_(category).startsWith("Other")) {
+ sample_sets.other_only.add_value(real_value);
+ }
+ sample_sets.all_cases.add_value(real_value);
+ }
+ }
+ console.log("towards end:", sample_sets);
+ return update_stat_values(sample_sets);
+ };
+ make_table = function() {
+ var header, key, row, row_line, rows, table, the_id, the_rows, value, _i, _len, _ref, _ref1;
+ header = " ";
+ console.log("windex header is:", header);
+ rows = [
+ {
+ vn: "n_of_samples",
+ pretty: "N of Samples"
+ }, {
+ vn: "mean",
+ pretty: "Mean"
+ }, {
+ vn: "median",
+ pretty: "Median"
+ }, {
+ vn: "std_error",
+ pretty: "Standard Error (SE)"
+ }, {
+ vn: "std_dev",
+ pretty: "Standard Deviation (SD)"
+ }
+ ];
+ console.log("rows are:", rows);
+ the_rows = " ";
+ console.log("js_data.sample_groups:", js_data.sample_groups);
+ _ref = js_data.sample_groups;
+ for (key in _ref) {
+ if (!__hasProp.call(_ref, key)) continue;
+ value = _ref[key];
+ console.log("aa key:", key);
+ console.log("aa value:", value);
+ the_id = process_id("column", key);
+ header += "" + value + " ";
+ }
+ header += "