about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xwqflask/base/trait.py61
1 files changed, 37 insertions, 24 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 38b3a625..801d32c2 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -268,7 +268,7 @@ class GeneralTrait(object):
                             PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND
                             PublishFreeze.Id = %s
                     """ % (self.name, self.dataset.id)
-            traitInfo = g.db.execute(query).fetchone()
+            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
         #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms.
         elif self.dataset.type == 'ProbeSet':
@@ -285,8 +285,8 @@ class GeneralTrait(object):
                     """ % (escape(display_fields_string),
                            escape(self.dataset.name),
                            escape(self.name))
-            traitInfo = g.db.execute(query).fetchone()
-            #print("traitInfo is: ", pf(traitInfo))
+            trait_info = g.db.execute(query).fetchone()
+            #print("trait_info is: ", pf(trait_info))
         #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name
         # to avoid the problem of same marker name from different species.
         elif self.dataset.type == 'Geno':
@@ -303,23 +303,24 @@ class GeneralTrait(object):
                     """ % (escape(display_fields_string),
                            escape(self.dataset.name),
                            escape(self.name))
-            traitInfo = g.db.execute(query).fetchone()
-            #print("traitInfo is: ", pf(traitInfo))
+            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)
-            traitInfo = g.db.execute(query).fetchone()
+            trait_info = g.db.execute(query).fetchone()
 
 
         #self.cursor.execute(query)
-        #traitInfo = self.cursor.fetchone()
-        if traitInfo:
+        #trait_info = self.cursor.fetchone()
+        if trait_info:
             self.haveinfo = True
 
             #XZ: assign SQL query result to trait attributes.
             for i, field in enumerate(self.dataset.display_fields):
-                setattr(self, field, str(traitInfo[i]))
+                print("  mike: {} -> {} - {}".format(field, type(trait_info[i]), trait_info[i]))
+                setattr(self, field, trait_info[i])
 
             if self.dataset.type == 'Publish':
                 self.confidential = 0
@@ -327,6 +328,10 @@ class GeneralTrait(object):
                     self.confidential = 1
 
             self.homologeneid = None
+            
+            print("self.geneid is:", self.geneid)
+            print("  type:", type(self.geneid))
+            print("self.dataset.group.name is:", self.dataset.group.name)
             if self.dataset.type == 'ProbeSet' and self.dataset.group and self.geneid:
                 #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number.
                 #XZ: So I have to test if geneid is number before execute the query.
@@ -338,6 +343,8 @@ class GeneralTrait(object):
                 #    geneidIsNumber = False
 
                 #if geneidIsNumber:
+
+
                 query = """
                         SELECT
                                 HomologeneId
@@ -349,6 +356,7 @@ class GeneralTrait(object):
                                 InbredSet.SpeciesId = Species.Id AND
                                 Species.TaxonomyId = Homologene.TaxonomyId
                         """ % (escape(str(self.geneid)), escape(self.dataset.group.name))
+                print("-> query is:", query)
                 result = g.db.execute(query).fetchone()
                 #else:
                 #    result = None
@@ -358,33 +366,38 @@ class GeneralTrait(object):
 
             if get_qtl_info:
                 if self.dataset.type == 'ProbeSet' and not self.cellid:
-                    traitQTL = g.db.execute("""
+                    query = """
                             SELECT
                                     ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean
                             FROM
                                     ProbeSetXRef, ProbeSet
                             WHERE
                                     ProbeSetXRef.ProbeSetId = ProbeSet.Id AND
-                                    ProbeSet.Name = "%s" AND
-                                    ProbeSetXRef.ProbeSetFreezeId =%s
-                            """, (self.name, self.dataset.id)).fetchone()
+                                    ProbeSet.Name = "{}" AND
+                                    ProbeSetXRef.ProbeSetFreezeId ={}
+                            """.format(self.name, self.dataset.id)
+                    trait_qtl = g.db.execute(query).fetchone()
                     #self.cursor.execute(query)
-                    #traitQTL = self.cursor.fetchone()
-                    if traitQTL:
-                        self.locus, self.lrs, self.pvalue, self.mean = traitQTL
+                    #trait_qtl = self.cursor.fetchone()
+                    if trait_qtl:
+                        self.locus, self.lrs, self.pvalue, self.mean = trait_qtl
                         if self.locus:
-                            result = g.db.execute("""
+                            query = """
                                 select Geno.Chr, Geno.Mb from Geno, Species
-                                where Species.Name = '%s' and
-                                Geno.Name = '%s' and
+                                where Species.Name = '{}' and
+                                Geno.Name = '{}' and
                                 Geno.SpeciesId = Species.Id
-                                """, (species, self.locus)).fetchone()
+                                """.format(self.dataset.group.species, self.locus)
+                            print("query is:", query)
+                            result = g.db.execute(query).fetchone()
                             self.locus_chr = result[0]
                             self.locus_mb = result[1]
                     else:
                         self.locus = self.locus_chr = self.locus_mb = self.lrs = self.pvalue = self.mean = ""
+                
+                
                 if self.dataset.type == 'Publish':
-                    traitQTL = g.db.execute("""
+                    trait_qtl = g.db.execute("""
                             SELECT
                                     PublishXRef.Locus, PublishXRef.LRS
                             FROM
@@ -395,9 +408,9 @@ class GeneralTrait(object):
                                     PublishFreeze.Id =%s
                             """, (self.name, self.dataset.id)).fetchone()
                     #self.cursor.execute(query)
-                    #traitQTL = self.cursor.fetchone()
-                    if traitQTL:
-                        self.locus, self.lrs = traitQTL
+                    #trait_qtl = self.cursor.fetchone()
+                    if trait_qtl:
+                        self.locus, self.lrs = trait_qtl
                     else:
                         self.locus = self.lrs = ""
         else: