From f228a25356ccebdb036982d1ad862eda77ec6346 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 20 Sep 2012 17:22:11 -0500 Subject: Simplified stats table coffeescript code --- .../new/javascript/trait_data_and_analysis.coffee | 47 ++----- .../new/javascript/trait_data_and_analysis.js | 43 ++---- wqflask/wqflask/templates/search_result_page.html | 16 +-- .../wqflask/templates/trait_data_and_analysis.html | 154 ++++++++++----------- 4 files changed, 111 insertions(+), 149 deletions(-) (limited to 'wqflask') 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 c44582db..fcd9e255 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -21,6 +21,7 @@ $ -> change_stats_value = (category, value_type, the_value)-> id = "#" + process_id(category, value_type) + console.log("the_id:", id) in_box = $(id).html current_value = parseFloat($(in_box)).toFixed(2) @@ -33,50 +34,30 @@ $ -> # Number of samples n_of_samples = sample_sets[category].n_of_samples() - id = "#" + process_id(category, "n_of_samples") - current_n_of_samples = $(id).html() - if n_of_samples != current_n_of_samples - $(id).html(n_of_samples).effect("highlight") + change_stats_value(category, "n_of_samples", n_of_samples) # Mean - #id = "#" + process_id(category, "mean") - the_mean = sample_sets[category].mean() the_mean = the_mean.toFixed(2) change_stats_value(category, "mean", the_mean) - #in_box = $(id).html - - #current_mean = parseFloat($(in_box)).toFixed(2) - - #if the_mean != current_mean - # $(id).html(the_mean).effect("highlight") # Median - id = "#" + process_id(category, "median") + #id = "#" + process_id(category, "median") the_median = sample_sets[category].median() the_median = the_median.toFixed(2) - in_box = $(id).html - - current_median = parseFloat($(in_box)).toFixed(2) - - if the_median != current_median - $(id).html(the_median).effect("highlight") + change_stats_value(category, "median", the_median) # Todo: Compare stat values to genenetwork.org current code / sample vs. population # Standard deviation - sum = 0 - for value in sample_sets[category] - step_a = Math.pow(value - the_mean, 2) - sum += step_a - step_b = sum / sample_sets[category].length - sd = Math.sqrt(step_b) - sd = sd.toFixed(2) - - id = "#" + process_id(category, "sd") - current_sd = $(id).html() - if sd != current_sd - $(id).html(sd).effect("highlight") + the_std_dev = sample_sets[category].std_dev() + the_std_dev = the_std_dev.toFixed(2) + change_stats_value(category, "std_dev", the_std_dev) + # Standard Error + the_std_error = sample_sets[category].std_error() + the_std_error = the_std_error.toFixed(2) + change_stats_value(category, "std_error", the_std_error) + edit_data_change = -> sample_sets = @@ -130,11 +111,11 @@ $ -> pretty: "Median" }, { - vn: "se" + vn: "std_error" pretty: "Standard Error (SE)" }, { - vn: "sd" + vn: "std_dev" pretty: "Standard Deviation (SD)" } ] 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 b4eed350..170d6e4f 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -30,6 +30,7 @@ change_stats_value = function(category, value_type, the_value) { var current_value, id, in_box; id = "#" + process_id(category, value_type); + console.log("the_id:", id); in_box = $(id).html; current_value = parseFloat($(in_box)).toFixed(2); if (the_value !== current_value) { @@ -37,45 +38,25 @@ } }; update_stat_values = function(sample_sets) { - var category, current_median, current_n_of_samples, current_sd, id, in_box, n_of_samples, sd, step_a, step_b, sum, the_mean, the_median, value, _i, _j, _len, _len1, _ref, _ref1, _results; + var category, n_of_samples, the_mean, the_median, the_std_dev, the_std_error, _i, _len, _ref, _results; _ref = ['primary_only', 'other_only', 'all_cases']; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { category = _ref[_i]; n_of_samples = sample_sets[category].n_of_samples(); - id = "#" + process_id(category, "n_of_samples"); - current_n_of_samples = $(id).html(); - if (n_of_samples !== current_n_of_samples) { - $(id).html(n_of_samples).effect("highlight"); - } + change_stats_value(category, "n_of_samples", n_of_samples); the_mean = sample_sets[category].mean(); the_mean = the_mean.toFixed(2); change_stats_value(category, "mean", the_mean); - id = "#" + process_id(category, "median"); the_median = sample_sets[category].median(); the_median = the_median.toFixed(2); - in_box = $(id).html; - current_median = parseFloat($(in_box)).toFixed(2); - if (the_median !== current_median) { - $(id).html(the_median).effect("highlight"); - } - sum = 0; - _ref1 = sample_sets[category]; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - value = _ref1[_j]; - step_a = Math.pow(value - the_mean, 2); - sum += step_a; - } - step_b = sum / sample_sets[category].length; - sd = Math.sqrt(step_b); - sd = sd.toFixed(2); - id = "#" + process_id(category, "sd"); - current_sd = $(id).html(); - if (sd !== current_sd) { - _results.push($(id).html(sd).effect("highlight")); - } else { - _results.push(void 0); - } + change_stats_value(category, "median", the_median); + the_std_dev = sample_sets[category].std_dev(); + the_std_dev = the_std_dev.toFixed(2); + change_stats_value(category, "std_dev", the_std_dev); + the_std_error = sample_sets[category].std_error(); + the_std_error = the_std_error.toFixed(2); + _results.push(change_stats_value(category, "std_error", the_std_error)); } return _results; }; @@ -133,10 +114,10 @@ vn: "median", pretty: "Median" }, { - vn: "se", + vn: "std_error", pretty: "Standard Error (SE)" }, { - vn: "sd", + vn: "std_dev", pretty: "Standard Deviation (SD)" } ]; diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index afcd06d0..572f7fcc 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -2,8 +2,8 @@ {% block title %}Search Results{% endblock %} {% block content %} - - + +
@@ -172,10 +172,10 @@ - {# - #} - - {{ thisTrait.name.upper() }} - + {# - #} + + {{ thisTrait.name.upper() }} + @@ -199,8 +199,8 @@
- - + + {% endblock %} diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 110559bc..3d2ec636 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -18,39 +18,39 @@ - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - + + - - + + - - - - - - - - - + + + + + + + + + - #} + #} {% for key in hddn %} {% endfor %} @@ -103,13 +103,13 @@ - - - BLAT specificity - : {{ "%.1f" % (thisTrait.probe_set_specificity) }}    - Score: {{ "%i" % (thisTrait.probe_set_blat_score) }}   - - + + + BLAT specificity + : {{ "%.1f" % (thisTrait.probe_set_specificity) }}    + Score: {{ "%i" % (thisTrait.probe_set_blat_score) }}   + + @@ -126,8 +126,8 @@ - {{ thisTrait.database.name }} - + {{ thisTrait.database.name }} + @@ -140,14 +140,14 @@ - - - + + - Gene - - -    + +   UniGene   -
+
- {% for sd in stats_data %} + {% for sd in stats_data %}
- {% endfor %} - {# Not used now - Todo: Delete after we're sure this is right. + {% endfor %} + {# Not used now - Todo: Delete after we're sure this is right.
- {% endfor %} + {% endfor %} - + @@ -1317,15 +1317,15 @@ js_data = {{ js_data | safe }} - --> - + --> + - + - - + + -- cgit v1.2.3