aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorZachary Sloan2012-08-28 16:05:09 -0500
committerZachary Sloan2012-08-28 16:05:09 -0500
commit4cc46d84810ca9492e9a38e1a1f88ab36d214791 (patch)
tree3b67781f4fc241ca9e95bee0d0f2170463edf4a9 /wqflask/base
parent31aa6fb32e4ae4af18e177a3777a19bbde3e063d (diff)
downloadgenenetwork2-4cc46d84810ca9492e9a38e1a1f88ab36d214791.tar.gz
Various changes related to the webqtlCaseData object and the way values/variances/num_cases are called in DataEditingPage.py
Diffstat (limited to 'wqflask/base')
-rwxr-xr-xwqflask/base/webqtlCaseData.py69
-rwxr-xr-xwqflask/base/webqtlTrait.py52
2 files changed, 78 insertions, 43 deletions
diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py
index f68354be..7805df06 100755
--- a/wqflask/base/webqtlCaseData.py
+++ b/wqflask/base/webqtlCaseData.py
@@ -24,28 +24,59 @@
#
# Last updated by GeneNetwork Core Team 2010/10/20
-class webqtlCaseData:
- """
- one case data in one trait
- """
+print("Mr. Mojo Risin 2")
- val = None #Trait Value
- var = None #Trait Variance
- N = None #Number of individuals
+class webqtlCaseData(object):
+ """one case data in one trait
+
+ """
- def __init__(self, val=val, var=var, N=N):
- self.val = val
- self.var = var
- self.N = N
+ def __init__(self, name, value=None, variance=None, num_cases=None):
+ self.name = name
+ self.value = value # Trait Value
+ self.variance = variance # Trait Variance
+ self.num_cases = num_cases # Number of individuals/cases
+ self.this_id = None # Set a sane default (can't be just "id" cause that's a reserved word)
- def __str__(self):
+ def __repr__(self):
str = ""
- if self.val != None:
- str += "value=%2.3f" % self.val
- if self.var != None:
- str += " variance=%2.3f" % self.var
- if self.N != None:
- str += " ndata=%d" % self.N
+ if self.value != None:
+ str += "value=%2.3f" % self.value
+ if self.variance != None:
+ str += " variance=%2.3f" % self.variance
+ if self.num_cases != None:
+ str += " ndata=%d" % self.num_cases
return str
+
+ @property
+ def display_value(self):
+ if self.value:
+ return "%2.3f" % self.value
+ else:
+ return "x"
+
+ @property
+ def display_variance(self):
+ if self.variance:
+ return "%2.3f" % self.variance
+ else:
+ return "x"
+
+
+ #try:
+ # traitVar = thisvar
+ # dispVar = "%2.3f" % thisvar
+ #except:
+ # traitVar = ''
+ # dispVar = 'x'
+
+ #try:
+ # traitVal = thisval
+ # dispVal = "%2.3f" % thisval
+ #except:
+ # traitVal = ''
+ # dispVal = 'x'
+
- __repr__ = __str__
+ #def this_val_full(self):
+ # strain_name = \ No newline at end of file
diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py
index 23b98238..337493ef 100755
--- a/wqflask/base/webqtlTrait.py
+++ b/wqflask/base/webqtlTrait.py
@@ -225,7 +225,10 @@ class webqtlTrait:
- def retrieveData(self, strainlist=[]):
+ def retrieveData(self, strainlist=None):
+
+ if strainlist == None:
+ strainlist = []
assert self.db and self.cursor
if self.db.type == 'Temp':
@@ -328,32 +331,33 @@ class webqtlTrait:
self.cursor.execute(query)
results = self.cursor.fetchall()
self.data.clear()
+
if results:
self.mysqlid = results[0][-1]
- if strainlist:
- for item in results:
- if item[0] in strainlist:
- val = item[1]
- if val != None:
- var = item[2]
- ndata = None
- if self.db.type in ('Publish', 'Temp'):
- ndata = item[3]
- self.data[item[0]] = webqtlCaseData(val, var, ndata)
+ #if strainlist:
+ for item in results:
+ #name, value, variance, num_cases = item
+ if not strainlist or (strainlist and name in strainlist):
+ #if value != None:
+ # num_cases = None
+ # if self.db.type in ('Publish', 'Temp'):
+ # ndata = item[3]
+ name = item[0]
+ self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases)
#end for
- else:
- for item in results:
- val = item[1]
- if val != None:
- var = item[2]
- ndata = None
- if self.db.type in ('Publish', 'Temp'):
- ndata = item[3]
- self.data[item[0]] = webqtlCaseData(val, var, ndata)
- #end for
- #end if
- else:
- pass
+ # else:
+ # for item in results:
+ # val = item[1]
+ # if val != None:
+ # var = item[2]
+ # ndata = None
+ # if self.db.type in ('Publish', 'Temp'):
+ # ndata = item[3]
+ # self.data[item[0]] = webqtlCaseData(val, var, ndata)
+ # #end for
+ # #end if
+ #else:
+ # pass
def keys(self):
return self.__dict__.keys()