aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/webqtlFormData.py72
-rw-r--r--wqflask/wqflask/correlation/CorrelationPage.py18
-rw-r--r--wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee28
-rw-r--r--wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js11
-rw-r--r--wqflask/wqflask/templates/trait_data_and_analysis.html12
-rw-r--r--wqflask/wqflask/views.py6
6 files changed, 77 insertions, 70 deletions
diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py
index 177c72a2..9f58d437 100755
--- a/wqflask/base/webqtlFormData.py
+++ b/wqflask/base/webqtlFormData.py
@@ -63,7 +63,7 @@ class webqtlFormData:
for item in start_vars:
self.__dict__[item] = start_vars[item]
- #print(" Now self.dict is:", pf(self.__dict__))
+ print(" Now self.dict is:", pf(self.__dict__))
#Todo: This can't be good below...rework
try:
@@ -216,6 +216,13 @@ class webqtlFormData:
#### Todo: Rewrite below when we get to someone submitting their own trait #####
+ def to_float(item):
+ try:
+ return float(item)
+ except ValueError:
+ return None
+
+ print("bottle strainlist is:", strainlist)
if traitfiledata:
tt = traitfiledata.split()
values = map(webqtlUtil.StringAsFloat, tt)
@@ -223,12 +230,17 @@ class webqtlFormData:
tt = traitpastedata.split()
values = map(webqtlUtil.StringAsFloat, tt)
else:
- values = map(self.FormDataAsFloat, strainlist)
+ print("mapping formdataasfloat")
+ #values = map(self.FormDataAsFloat, strainlist)
+ values = [to_float(getattr(self, key)) for key in strainlist]
+ print("rocket values is:", values)
+
if len(values) < len(strainlist):
values += [None] * (len(strainlist) - len(values))
elif len(values) > len(strainlist):
values = values[:len(strainlist)]
+ print("now values is:", values)
if variancefiledata:
@@ -257,40 +269,48 @@ class webqtlFormData:
self.allTraitData = {}
for i, _strain in enumerate(strainlist):
if values[i] != None:
- self.allTraitData[_strain] = webqtlCaseData(values[i], variances[i], nstrains[i])
+ self.allTraitData[_strain] = webqtlCaseData(
+ _strain, values[i], variances[i], nstrains[i])
+ print("allTraitData is:", pf(self.allTraitData))
- def informativeStrains(self, strainlst=[], incVars = 0):
- '''if readData was called, use this to output the informative strains
- (strain with values)'''
- if not strainlst:
- strainlst = self.strainlist
+ def informativeStrains(self, strainlist=None, include_variances = None):
+ '''if readData was called, use this to output informative strains (strain with values)'''
+
+ if not strainlist:
+ strainlist = self.strainlist
+
strains = []
- vals = []
- vars = []
- for _strain in strainlst:
- if self.allTraitData.has_key(_strain):
- _val, _var = self.allTraitData[_strain].val, self.allTraitData[_strain].var
+ values = []
+ variances = []
+
+ #print("self.allTraitData is:", pf(self.allTraitData))
+
+ for strain in strainlist:
+ if strain in self.allTraitData:
+ _val, _var = self.allTraitData[strain].value, self.allTraitData[strain].variance
if _val != None:
- if incVars:
+ if include_variances:
if _var != None:
- strains.append(_strain)
- vals.append(_val)
- vars.append(_var)
+ strains.append(strain)
+ values.append(_val)
+ variances.append(_var)
else:
- strains.append(_strain)
- vals.append(_val)
- vars.append(None)
- return strains, vals, vars, len(strains)
+ strains.append(strain)
+ values.append(_val)
+ variances.append(None)
+
+ return strains, values, variances, len(strains)
- def FormDataAsFloat(self, key):
- try:
- return float(self.formdata.getfirst(key))
- except:
- return None
+ #def FormDataAsFloat(self, key):
+ #
+ # #try:
+ # # return float(self.key)
+ # #except:
+ # # return None
def FormVarianceAsFloat(self, key):
diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py
index 62e4c4ab..0af5297a 100644
--- a/wqflask/wqflask/correlation/CorrelationPage.py
+++ b/wqflask/wqflask/correlation/CorrelationPage.py
@@ -157,7 +157,7 @@ def get_correlation_method_key(form_data):
#XZ, 09/28/2008: if user select "4", then display 1, 3 and 4.
#XZ, 09/28/2008: if user select "5", then display 2, 3 and 5.
- method = form_data.formdata.getvalue("method")
+ method = form_data.method
if method not in ["1", "2", "3" ,"4", "5"]:
return "1"
@@ -166,7 +166,7 @@ def get_correlation_method_key(form_data):
def get_custom_trait(form_data, cursor):
"""Pulls the custom trait, if it exists, out of the form data"""
- trait_name = form_data.formdata.getvalue('fullname')
+ trait_name = form_data.fullname
if trait_name:
trait = webqtlTrait(fullname=trait_name, cursor=cursor)
@@ -178,7 +178,7 @@ def get_custom_trait(form_data, cursor):
#XZ, 09/18/2008: get the information such as value, variance of the input strain names from the form.
def get_sample_data(fd):
- print("fd is:", pf(fd.__dict__))
+ #print("fd is:", pf(fd.__dict__))
if fd.allstrainlist:
mdpchoice = fd.MDPChoice
#XZ, in HTML source code, it is "BXD Only", "BXH Only", and so on
@@ -277,10 +277,10 @@ class CorrelationPage(templatePage):
return templatePage.error(heading = heading, detail = [message], error=error)
def __init__(self, fd):
- print("in CorrelationPage __init__ fd is:", pf(fd.__dict__))
+ #print("in CorrelationPage __init__ fd is:", pf(fd.__dict__))
# Call the superclass constructor
templatePage.__init__(self, fd)
- print("in CorrelationPage __init__ now fd is:", pf(fd.__dict__))
+ #print("in CorrelationPage __init__ now fd is:", pf(fd.__dict__))
# Connect to the database
if not self.openMysql():
return
@@ -290,6 +290,7 @@ class CorrelationPage(templatePage):
fd.readGenotype()
sample_list = get_sample_data(fd)
+ print("sample_list is", pf(sample_list))
# Whether the user chose BXD Only, Non-BXD Only, or All Strains
# (replace BXD with whatever the group/inbredset name is)
@@ -321,17 +322,18 @@ class CorrelationPage(templatePage):
#XZ, 09/18/2008: filter out the strains that have no value.
self.sample_names, vals, vars, N = fd.informativeStrains(sample_list)
- #CF - If less than a minimum number of strains/cases in common, don't calculate anything
+ print("samplenames is:", pf(self.sample_names))
+ #CF - If less than a minimum number of strains/cases in common, don't calculate anything
if len(self.sample_names) < self.corrMinInformative:
detail = ['Fewer than %d strain data were entered for %s data set. No calculation of correlation has been attempted.' % (self.corrMinInformative, fd.RISet)]
self.error(heading=None, detail=detail)
- self.method = get_correlation_method_key(fd)
+ self.method = fd.method
correlation_method = self.CORRELATION_METHODS[self.method]
rankOrder = self.RANK_ORDERS[self.method]
- # CF - Number of results returned
+ # CF - Number of results returned
self.returnNumber = int(fd.criteria)
self.record_count = 0
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 7bfa6d01..5c153ccb 100644
--- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee
+++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee
@@ -166,20 +166,20 @@ $ ->
$('select[name=corr_method]').change(on_corr_method_change)
- on_corr_submit = ->
- console.log("in beginning of on_corr_submit")
- values = $('#trait_data_form').serialize()
- console.log("in on_corr_submit, values are:", values)
-
- params = $.param(values)
- window.location.href = "/corr_compute?" + params
-
- #$.ajax "/corr_compute",
- # type: 'GET'
- # dataType: 'html'
- # data: values
-
- $('#corr_compute').click(on_corr_submit)
+ #on_corr_submit = ->
+ # console.log("in beginning of on_corr_submit")
+ # values = $('#trait_data_form').serialize()
+ # console.log("in on_corr_submit, values are:", values)
+ #
+ # params = $.param(values)
+ # window.location.href = "/corr_compute?" + params
+ #
+ # #$.ajax "/corr_compute",
+ # # type: 'GET'
+ # # dataType: 'html'
+ # # data: values
+ #
+ #$('#corr_compute').click(on_corr_submit)
###
End Calculate Correlations Code
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 e1f870d9..55acbada 100644
--- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js
+++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js
@@ -10,7 +10,7 @@
};
$(function() {
- var edit_data_change, hide_tabs, make_table, on_corr_method_change, on_corr_submit, process_id, show_hide_outliers, stats_mdp_change, update_stat_values;
+ var edit_data_change, hide_tabs, make_table, on_corr_method_change, process_id, show_hide_outliers, stats_mdp_change, update_stat_values;
hide_tabs = function(start) {
var x, _i, _results;
_results = [];
@@ -199,15 +199,6 @@
return $('#' + corr_method + "_r_desc").show().effect("highlight");
};
$('select[name=corr_method]').change(on_corr_method_change);
- on_corr_submit = function() {
- var params, values;
- console.log("in beginning of on_corr_submit");
- values = $('#trait_data_form').serialize();
- console.log("in on_corr_submit, values are:", values);
- params = $.param(values);
- return window.location.href = "/corr_compute?" + params;
- };
- $('#corr_compute').click(on_corr_submit);
/*
End Calculate Correlations Code
*/
diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html
index a5d0e05c..c25db7c4 100644
--- a/wqflask/wqflask/templates/trait_data_and_analysis.html
+++ b/wqflask/wqflask/templates/trait_data_and_analysis.html
@@ -8,7 +8,7 @@
<table width="100%" cellspacing="0" cellpadding="5">
<tr>
<td valign="top" width="100%" bgcolor="#FAFAFA">
- <form method="post" action="/webqtl/main.py" name="dataInput" id="trait_data_form">
+ <form method="post" action="/corr_compute" name="dataInput" id="trait_data_form">
{# <input type="hidden" name="isSE" value="yes">
<input type="hidden" name="permCheck">
<input type="hidden" name="otherStrainVals" value="_">
@@ -683,13 +683,7 @@
<p class="sectionheader" id="title3" style="border-radius: 5px;">&nbsp;&nbsp;Calculate Correlations</p>
- <p id="sectionbody3"></p><script language="Javascript" type="text/javascript">
-<!--
-
- $(function() { $("#corr_tabs").tabs(); });
-
- //-->
- </script>
+ <p id="sectionbody3"></p>
<table class="target4" cellpadding="0" cellspacing="0" width="100%">
<tr>
@@ -771,7 +765,7 @@
"sample_method" value="spearman"><br>
<br>
- <input type="button" name="corr_compute" id="corr_compute" class="button" value="Compute"><br><br>
+ <input type="submit" name="corr_compute" id="corr_compute" class="button" value="Compute"><br><br>
<span id="sample_r_desc" class="correlation_desc fs12">
The <a href="/correlationAnnotation.html#sample_r" target="_blank">Sample Correlation</a>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 114ec458..677c7f43 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -75,10 +75,10 @@ def showDatabaseBXD():
print("showDatabaseBXD template_vars:", pf(template_vars.__dict__))
return render_template("trait_data_and_analysis.html", **template_vars.__dict__)
-@app.route("/corr_compute")
+@app.route("/corr_compute", methods=('POST',))
def corr_compute():
- print("In corr_compute")
- fd = webqtlFormData.webqtlFormData(request.args)
+ #print("In corr_compute, request.args is:", pf(request.form))
+ fd = webqtlFormData.webqtlFormData(request.form)
print("Have fd")
template_vars = CorrelationPage.CorrelationPage(fd)
print("Made it to rendering")