about summary refs log tree commit diff
path: root/wqflask/base/trait.py
diff options
context:
space:
mode:
authorpjotrp2015-11-18 11:19:01 +0100
committerpjotrp2015-11-18 11:19:01 +0100
commitcb0f10fc4850b6b06f2237b532317a5c6668584a (patch)
treed143662ecceac5e05bd06afee4c87b2beb88859b /wqflask/base/trait.py
parent28ec342362ba068b3d0b5b9a302bc279d251f160 (diff)
parent0310301b30c59eca45235cd1bd1ff8e15923950a (diff)
downloadgenenetwork2-cb0f10fc4850b6b06f2237b532317a5c6668584a.tar.gz
Merge branch 'master' of https://github.com/zsloan/genenetwork2 into zsloan
Diffstat (limited to 'wqflask/base/trait.py')
-rwxr-xr-xwqflask/base/trait.py52
1 files changed, 33 insertions, 19 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 58bed865..ff80795c 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -53,7 +53,8 @@ class GeneralTrait(object):
         self.pvalue = None
         self.mean = None
         self.num_overlap = None
-
+        self.strand_probe = None
+        self.symbol = None
 
         if kw.get('fullname'):
             name2 = value.split("::")
@@ -250,14 +251,7 @@ class GeneralTrait(object):
         # Todo: is this necessary? If not remove
         self.data.clear()
 
-        if self.dataset.group.parlist:
-            all_samples_ordered = (self.dataset.group.parlist +
-                                   self.dataset.group.f1list +
-                                   self.dataset.group.samplelist)
-        elif self.dataset.group.f1list:
-            all_samples_ordered = self.dataset.group.f1list + self.dataset.group.samplelist
-        else:
-            all_samples_ordered = self.dataset.group.samplelist
+        all_samples_ordered = self.dataset.group.all_samples_ordered()
 
         if results:
             for item in results:
@@ -297,7 +291,7 @@ class GeneralTrait(object):
                             PublishFreeze.Id = %s
                     """ % (self.name, self.dataset.id)
             
-            print("query is:", query)        
+            print("query is:", query) 
         
             trait_info = g.db.execute(query).fetchone()
         #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name
@@ -336,10 +330,10 @@ class GeneralTrait(object):
             trait_info = g.db.execute(query).fetchone()
             #print("trait_info is: ", pf(trait_info))
         else: #Temp type
-            query = """SELECT %s FROM %s WHERE Name = %s
-                                     """ % (string.join(self.dataset.display_fields,','),
-                                            self.dataset.type, self.name)
-            trait_info = g.db.execute(query).fetchone()
+            query = """SELECT %s FROM %s WHERE Name = %s"""
+            trait_info = g.db.execute(query,
+                                      (string.join(self.dataset.display_fields,','),
+                                                   self.dataset.type, self.name)).fetchone()
         if trait_info:
             self.haveinfo = True
 
@@ -422,6 +416,8 @@ class GeneralTrait(object):
                             if result:
                                 self.locus_chr = result[0]
                                 self.locus_mb = result[1]
+                            else:
+                                self.locus = self.locus_chr = self.locus_mb = ""
                         else:
                             self.locus = self.locus_chr = self.locus_mb = ""
                     else:
@@ -533,12 +529,27 @@ class GeneralTrait(object):
         return setDescription
 
     @property
+    def name_header_fmt(self):
+        '''Return a human-readable name for use in page header'''
+        if self.dataset.type == 'ProbeSet':
+            return self.symbol
+        elif self.dataset.type == 'Geno':
+            return self.name
+        elif self.dataset.type == 'Publish':
+            return self.post_publication_abbreviation
+        else:
+            return "unnamed"
+
+    @property
     def description_fmt(self):
         '''Return a text formated description'''
-        if self.description:
-            formatted = self.description
-            if self.probe_target_description:
-                formatted += "; " + self.probe_target_description
+        if self.dataset.type == 'ProbeSet':
+            if self.description:
+                formatted = self.description
+                if self.probe_target_description:
+                    formatted += "; " + self.probe_target_description
+        elif self.dataset.type == 'Publish':
+            formatted = self.post_publication_description
         else:
             formatted = "Not available"
         return formatted.capitalize()
@@ -549,6 +560,9 @@ class GeneralTrait(object):
         if self.alias:
             alias = string.replace(self.alias, ";", " ")
             alias = string.join(string.split(alias), ", ")
+        else:
+            alias = 'Not available'
+
         return alias
 
 
@@ -649,4 +663,4 @@ def get_sample_data():
     #    jsonable_sample_data[sample] = trait_ob.data[sample].value
     #
     #return jsonable_sample_data
-    
\ No newline at end of file
+