From 0e17939e123ec80c4da3f665004b08347aa9480b Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 4 Dec 2012 16:19:46 -0600 Subject: Began changing references to cursor/db_conn to use sqlalchemy Wrote function for phenotype author searches --- wqflask/base/data_set.py | 34 ++++++++++++++++++---------------- wqflask/base/webqtlTrait.py | 15 ++++++++------- 2 files changed, 26 insertions(+), 23 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 34e5eaa1..cd9e810e 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -90,9 +90,7 @@ class DataSet(object): def get_group(self): - assert self.cursor - self.cursor.execute(self.query) - self.group, self.group_id = self.cursor.fetchone() + self.group, self.group_id = g.db.execute(self.query).fetchone() if self.group == 'BXD300': self.group = "BXD" #return group @@ -107,7 +105,7 @@ class DataSet(object): """ - query_args = tuple(self.db_conn.escape_string(x) for x in ( + query_args = tuple(escape(x) for x in ( (self.type + "Freeze"), str(webqtlConfig.PUBLICTHRESH), self.name, @@ -115,18 +113,22 @@ class DataSet(object): self.name)) print("query_args are:", query_args) - query = ''' - SELECT - Id, Name, FullName, ShortName - FROM - %s - WHERE - public > %s AND - (Name = "%s" OR FullName = "%s" OR ShortName = "%s") - ''' % (query_args) + print(""" + SELECT Id, Name, FullName, ShortName + FROM %s + WHERE public > %s AND + (Name = '%s' OR FullName = '%s' OR ShortName = '%s') + """ % (query_args)) + + self.id, self.name, self.fullname, self.shortname = g.db.execute(""" + SELECT Id, Name, FullName, ShortName + FROM %s + WHERE public > %s AND + (Name = '%s' OR FullName = '%s' OR ShortName = '%s') + """ % (query_args)).fetchone() - self.cursor.execute(query) - self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() + #self.cursor.execute(query) + #self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() #def genHTML(self, Class='c0dd'): @@ -185,7 +187,7 @@ class PhenotypeDataSet(DataSet): WHERE PublishFreeze.InbredSetId = InbredSet.Id AND PublishFreeze.Name = "%s" - ''' % self.db_conn.escape_string(self.name) + ''' % escape(self.name) def check_confidentiality(self): # (Urgently?) Need to write this diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 1dceba08..9763e441 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -30,9 +30,9 @@ class webqtlTrait: 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, {}) + 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("::") @@ -381,7 +381,7 @@ class webqtlTrait: # return self.__dict__.items() def retrieveInfo(self, QTL = None): - assert self.dataset and self.cursor + assert self.dataset if self.dataset.type == 'Publish': #self.dataset.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ @@ -434,10 +434,11 @@ class webqtlTrait: Geno.Name = '%s' """ % (display_fields_string, self.dataset.name, self.name) 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("""SELECT %s FROM %s WHERE Name = '%s' + """, (string.join(self.dataset.display_fields,','), + self.dataset.type, self.name)).fetchone() + self.cursor.execute(query) traitInfo = self.cursor.fetchone() if traitInfo: -- cgit v1.2.3