aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/trait.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/base/trait.py')
-rw-r--r--wqflask/base/trait.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 4bce25ac..9566c192 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -9,7 +9,7 @@ from htmlgen import HTMLgen2 as HT
from base import webqtlConfig
from base.webqtlCaseData import webqtlCaseData
from base.data_set import create_dataset
-from dbFunction import webqtlDatabaseFunction
+from db import webqtlDatabaseFunction
from utility import webqtlUtil
from wqflask import app
@@ -20,6 +20,9 @@ from pprint import pformat as pf
from flask import Flask, g, request
+from utility.logger import getLogger
+logger = getLogger(__name__ )
+
def print_mem(stage=""):
mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
print("{}: {}".format(stage, mem/1024))
@@ -253,6 +256,7 @@ class GeneralTrait(object):
PublishFreeze.Id = %s
""" % (self.name, self.dataset.id)
+ logger.sql(query)
trait_info = g.db.execute(query).fetchone()
@@ -272,6 +276,7 @@ class GeneralTrait(object):
""" % (escape(display_fields_string),
escape(self.dataset.name),
escape(str(self.name)))
+ logger.sql(query)
trait_info = g.db.execute(query).fetchone()
#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.
@@ -289,9 +294,11 @@ class GeneralTrait(object):
""" % (escape(display_fields_string),
escape(self.dataset.name),
escape(self.name))
+ logger.sql(query)
trait_info = g.db.execute(query).fetchone()
else: #Temp type
query = """SELECT %s FROM %s WHERE Name = %s"""
+ logger.sql(query)
trait_info = g.db.execute(query,
(string.join(self.dataset.display_fields,','),
self.dataset.type, self.name)).fetchone()
@@ -362,6 +369,7 @@ class GeneralTrait(object):
InbredSet.SpeciesId = Species.Id AND
Species.TaxonomyId = Homologene.TaxonomyId
""" % (escape(str(self.geneid)), escape(self.dataset.group.name))
+ logger.sql(query)
result = g.db.execute(query).fetchone()
#else:
# result = None
@@ -423,6 +431,7 @@ class GeneralTrait(object):
ProbeSet.Name = "{}" AND
ProbeSetXRef.ProbeSetFreezeId ={}
""".format(self.name, self.dataset.id)
+ logger.sql(query)
trait_qtl = g.db.execute(query).fetchone()
if trait_qtl:
self.locus, self.lrs, self.pvalue, self.mean, self.additive= trait_qtl
@@ -433,6 +442,7 @@ class GeneralTrait(object):
Geno.Name = '{}' and
Geno.SpeciesId = Species.Id
""".format(self.dataset.group.species, self.locus)
+ logger.sql(query)
result = g.db.execute(query).fetchone()
if result:
self.locus_chr = result[0]
@@ -446,7 +456,7 @@ class GeneralTrait(object):
if self.dataset.type == 'Publish':
- trait_qtl = g.db.execute("""
+ query = """
SELECT
PublishXRef.Locus, PublishXRef.LRS, PublishXRef.additive
FROM
@@ -455,7 +465,9 @@ class GeneralTrait(object):
PublishXRef.Id = %s AND
PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND
PublishFreeze.Id =%s
- """, (self.name, self.dataset.id)).fetchone()
+ """ % (self.name, self.dataset.id)
+ logger.sql(query)
+ trait_qtl = g.db.execute(query).fetchone()
if trait_qtl:
self.locus, self.lrs, self.additive = trait_qtl
if self.locus:
@@ -465,6 +477,7 @@ class GeneralTrait(object):
Geno.Name = '{}' and
Geno.SpeciesId = Species.Id
""".format(self.dataset.group.species, self.locus)
+ logger.sql(query)
result = g.db.execute(query).fetchone()
if result:
self.locus_chr = result[0]
@@ -651,12 +664,12 @@ class GeneralTrait(object):
"""
if self.cellid:
- self.cursor.execute("""
- select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze
- where
- ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND
- ProbeSetFreeze.Id = %d""" % thisTrait.dataset.id)
- probeDBName = self.cursor.fetchone()[0]
+ query = """ select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze where
+ ProbeFreeze.Id =
+ ProbeSetFreeze.ProbeFreezeId AND
+ ProbeSetFreeze.Id = %d""" % thisTrait.dataset.id
+ logger.sql(query)
+ probeDBName = g.db.execute(query).fetchone()[0]
return dict(name = probeDBName,
url = None)
else:
@@ -724,4 +737,3 @@ def get_sample_data():
# jsonable_sample_data[sample] = trait_ob.data[sample].value
#
#return jsonable_sample_data
-