aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/base')
-rwxr-xr-xwqflask/base/data_set.py33
-rwxr-xr-xwqflask/base/webqtlConfigLocal.py4
-rwxr-xr-xwqflask/base/webqtlTrait.py69
3 files changed, 60 insertions, 46 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 633f7545..015b2623 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -22,6 +22,8 @@
from __future__ import print_function, division
+from flask import Flask, g
+
from htmlgen import HTMLgen2 as HT
import webqtlConfig
@@ -31,25 +33,28 @@ from pprint import pformat as pf
# Used by create_database to instantiate objects
DS_NAME_MAP = {}
-def create_dataset(db_conn, dataset_name):
- cursor = db_conn.cursor()
- cursor.execute("""
+def create_dataset(dataset_name):
+ #cursor = db_conn.cursor()
+ print("dataset_name:", dataset_name)
+
+ dataset_type = g.db.execute("""
SELECT DBType.Name
FROM DBList, DBType
WHERE DBList.Name = %s and
DBType.Id = DBList.DBTypeId
- """, (dataset_name))
- print("dataset_name:", dataset_name)
- dataset_type = cursor.fetchone()[0]
- print("dataset_type:", pf(dataset_type))
+ """, (dataset_name)).fetchone().Name
+
+ #dataset_type = cursor.fetchone()[0]
+ print("[blubber] dataset_type:", pf(dataset_type))
dataset_ob = DS_NAME_MAP[dataset_type]
#dataset_class = getattr(data_set, dataset_ob)
-
+ print("dataset_ob:", dataset_ob)
print("DS_NAME_MAP:", pf(DS_NAME_MAP))
dataset_class = globals()[dataset_ob]
- return dataset_class(dataset_name, db_conn)
+ return dataset_class(dataset_name)
+
class DataSet(object):
"""
@@ -58,12 +63,12 @@ class DataSet(object):
"""
- def __init__(self, name, db_conn):
+ def __init__(self, name):
assert name
self.name = name
- self.db_conn = db_conn
- self.cursor = self.db_conn.cursor()
+ #self.db_conn = db_conn
+ #self.cursor = self.db_conn.cursor()
self.id = None
self.type = None
self.group = None
@@ -271,7 +276,7 @@ class GenotypeDataSet(DataSet):
def check_confidentiality(self):
return geno_mrna_confidentiality(self)
- def get_trait_info(self, trait_list):
+ def get_trait_info(self, trait_list, species=None):
for this_trait in trait_list:
if not this_trait.haveinfo:
this_trait.retrieveInfo()
@@ -355,7 +360,7 @@ class MrnaAssayDataSet(DataSet):
ProbeFreeze.InbredSetId = InbredSet.Id AND
ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND
ProbeSetFreeze.Name = "%s"
- ''' % self.db_conn.escape_string(self.name)
+ ''' % g.db.escape_string(self.name)
def check_confidentiality(self):
diff --git a/wqflask/base/webqtlConfigLocal.py b/wqflask/base/webqtlConfigLocal.py
index 5aab48ac..84686234 100755
--- a/wqflask/base/webqtlConfigLocal.py
+++ b/wqflask/base/webqtlConfigLocal.py
@@ -4,12 +4,12 @@
MYSQL_SERVER = 'localhost'
DB_NAME = 'db_webqtl_zas1024'
-DB_USER = 'webqtlupd'
+DB_USER = 'webqtl'
DB_PASSWD = 'webqtl'
MYSQL_UPDSERVER = 'localhost'
DB_UPDNAME = 'db_webqtl_zas1024'
-DB_UPDUSER = 'webqtlupd'
+DB_UPDUSER = 'webqtl'
DB_UPDPASSWD = 'webqtl'
GNROOT = '/home/zas1024/gn/'
diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py
index cc0e2321..1dceba08 100755
--- a/wqflask/base/webqtlTrait.py
+++ b/wqflask/base/webqtlTrait.py
@@ -12,6 +12,7 @@ from utility import webqtlUtil
from pprint import pformat as pf
+from flask import Flask, g
class webqtlTrait:
"""
@@ -20,38 +21,46 @@ class webqtlTrait:
"""
- def __init__(self, db_conn, **kw):
+ def __init__(self, **kw):
print("in webqtlTrait")
- self.db_conn = db_conn
- self.cursor = self.db_conn.cursor()
- self.dataset = None # database object
- self.name = '' # Trait ID, ProbeSet ID, Published ID, etc.
- self.cellid = ''
- self.identification = 'un-named trait'
- self.group = ''
- self.haveinfo = 0
- self.sequence = '' # Blat sequence, available for ProbeSet
- self.data = {}
- print("foo")
- print("kw in webqtlTrait are:", pf(kw))
- print("printed\n\n")
- for name, value in kw.items():
- if self.__dict__.has_key(name):
- setattr(self, name, value)
- elif name == 'fullname':
- name2 = value.split("::")
- if len(name2) == 2:
- self.dataset, self.name = name2
- elif len(name2) == 3:
- self.dataset, self.name, self.cellid = name2
- else:
- raise KeyError, repr(value) + ' parameter format error.'
- else:
- raise KeyError, repr(name) + ' not a valid parameter for this class.'
+ #self.db_conn = db_conn
+ #self.cursor = self.db_conn.cursor()
+ self.dataset = kw.get('dataset', None) # database object
+ self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc.
+ self.cellid = kw.get('cellid', None)
+ self.identification = kw.get('identification', 'un-named trait')
+ self.group = kw.get('group', None)
+ self.haveinfo = kw.get(haveinfo, False)
+ self.sequence = kw.get(sequence, None) # Blat sequence, available for ProbeSet
+ self.data = kw.get(data, {})
+
+ if kw.get('fullname'):
+ name2 = value.split("::")
+ if len(name2) == 2:
+ self.dataset, self.name = name2
+ elif len(name2) == 3:
+ self.dataset, self.name, self.cellid = name2
+
+ #print("foo")
+ #print("kw in webqtlTrait are:", pf(kw))
+ #print("printed\n\n")
+ #for name, value in kw.items():
+ # if self.__dict__.has_key(name):
+ # setattr(self, name, value)
+ # elif name == 'fullname':
+ # name2 = value.split("::")
+ # if len(name2) == 2:
+ # self.dataset, self.name = name2
+ # elif len(name2) == 3:
+ # self.dataset, self.name, self.cellid = name2
+ # else:
+ # raise KeyError, repr(value) + ' parameter format error.'
+ # else:
+ # raise KeyError, repr(name) + ' not a valid parameter for this class.'
if self.dataset and isinstance(self.dataset, basestring):
- assert self.cursor, "Don't have a cursor"
- self.dataset = create_dataset(self.db_conn, self.dataset)
+ #assert self.cursor, "Don't have a cursor"
+ self.dataset = create_dataset(self.dataset)
#if self.dataset == None, not from a database
print("self.dataset is:", self.dataset, type(self.dataset))
@@ -432,7 +441,7 @@ class webqtlTrait:
self.cursor.execute(query)
traitInfo = self.cursor.fetchone()
if traitInfo:
- self.haveinfo = 1
+ self.haveinfo = True
#XZ: assign SQL query result to trait attributes.
for i, field in enumerate(self.dataset.display_fields):