aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorPjotr Prins2016-06-23 12:18:42 +0000
committerPjotr Prins2016-06-23 12:18:42 +0000
commit85644d74643f4fef3641b1ce3c7c437b08b9ee70 (patch)
tree26468cf2b9208633b7cbb97941101b181d3d7b39 /wqflask/base
parentda1db6ae1df0b5c3d539c1d8b2d78d05ebe393e1 (diff)
downloadgenenetwork2-85644d74643f4fef3641b1ce3c7c437b08b9ee70.tar.gz
Logger: SQL
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/mrna_assay_tissue_data.py7
-rw-r--r--wqflask/base/species.py16
-rw-r--r--wqflask/base/trait.py18
3 files changed, 30 insertions, 11 deletions
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py
index 039f5d1f..5511af06 100644
--- a/wqflask/base/mrna_assay_tissue_data.py
+++ b/wqflask/base/mrna_assay_tissue_data.py
@@ -11,6 +11,9 @@ from MySQLdb import escape_string as escape
from pprint import pformat as pf
+from utility.logger import getLogger
+logger = getLogger(__name__ )
+
class MrnaAssayTissueData(object):
def __init__(self, gene_symbols=None):
@@ -54,7 +57,7 @@ class MrnaAssayTissueData(object):
as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol
and t.Mean = x.maxmean;
'''.format(in_clause)
-
+ logger.sql(query)
results = g.db.execute(query).fetchall()
lower_symbols = []
@@ -99,6 +102,7 @@ class MrnaAssayTissueData(object):
TissueProbeSetXRef.DataId = TissueProbeSetData.Id""".format(db_tools.create_in_clause(id_list))
print("TISSUE QUERY:", query)
+ logger.sql(query)
results = g.db.execute(query).fetchall()
for result in results:
@@ -157,4 +161,3 @@ class MrnaAssayTissueData(object):
#
# if len(tissue_data.gene_symbols):
# return get_symbol_values_pairs(tissue_data)
-
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index 79d867c8..ce763fc3 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -10,6 +10,9 @@ from utility import Bunch
from pprint import pformat as pf
+from utility.logger import getLogger
+logger = getLogger(__name__ )
+
class TheSpecies(object):
def __init__(self, dataset):
self.dataset = dataset
@@ -48,16 +51,17 @@ class Chromosomes(object):
self.dataset = dataset
self.chromosomes = collections.OrderedDict()
- results = g.db.execute("""
+
+ query = """
Select
Chr_Length.Name, Chr_Length.OrderId, Length from Chr_Length, InbredSet
where
Chr_Length.SpeciesId = InbredSet.SpeciesId AND
- InbredSet.Name = %s
+ InbredSet.Name = '%s'
Order by OrderId
- """, self.dataset.group.name).fetchall()
- #print("group: ", self.dataset.group.name)
- #print("bike:", results)
+ """ % self.dataset.group.name
+ logger.sql(query)
+ results = g.db.execute(query).fetchall()
for item in results:
self.chromosomes[item.OrderId] = IndChromosome(item.Name, item.Length)
@@ -120,4 +124,4 @@ class Chromosomes(object):
# Testing
#if __name__ == '__main__':
-# foo = dict(bar=dict(length)) \ No newline at end of file
+# foo = dict(bar=dict(length))
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 3dc4ddda..4d4d1a42 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -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))
@@ -259,6 +262,7 @@ class GeneralTrait(object):
PublishFreeze.Id = %s
""" % (self.name, self.dataset.id)
+ logger.sql(query)
trait_info = g.db.execute(query).fetchone()
@@ -278,6 +282,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.
@@ -295,9 +300,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()
@@ -368,6 +375,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
@@ -429,6 +437,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
@@ -439,6 +448,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]
@@ -452,7 +462,7 @@ class GeneralTrait(object):
if self.dataset.type == 'Publish':
- trait_qtl = g.db.execute("""
+ query = """
SELECT
PublishXRef.Locus, PublishXRef.LRS, PublishXRef.additive
FROM
@@ -461,7 +471,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:
@@ -471,6 +483,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]
@@ -730,4 +743,3 @@ def get_sample_data():
# jsonable_sample_data[sample] = trait_ob.data[sample].value
#
#return jsonable_sample_data
-