diff options
Diffstat (limited to 'wqflask/wqflask/do_search.py')
-rwxr-xr-x | wqflask/wqflask/do_search.py | 100 |
1 files changed, 36 insertions, 64 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index a3260f34..f966b564 100755 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -442,13 +442,6 @@ class WikiSearch(MrnaAssaySearch): return where_clause def run(self): - #where_clause = """%s.symbol = GeneRIF.symbol - # and GeneRIF.versionId=0 and GeneRIF.display>0 - # and (GeneRIF.comment REGEXP '%s' or GeneRIF.initial = '%s') - # """ % (self.dataset.type, - # "[[:<:]]"+str(self.search_term[0])+"[[:>:]]", - # str(self.search_term[0])) - where_clause = self.get_where_clause() from_clause = ", GeneRIF " @@ -481,7 +474,7 @@ class GoSearch(MrnaAssaySearch): return self.execute(query) #ZS: Not sure what the best way to deal with LRS searches is -class LrsSearch(MrnaAssaySearch): +class LrsSearch(DoSearch): """Searches for genes with a QTL within the given LRS values LRS searches can take 3 different forms: @@ -497,9 +490,11 @@ class LrsSearch(MrnaAssaySearch): def get_from_clause(self): if self.search_operator == "=": - return ", Geno" + from_clause = ", Geno" else: - return "" + from_clause = "" + + return from_clause def get_where_clause(self): self.search_term = [float(value) for value in self.search_term] @@ -537,26 +532,42 @@ class LrsSearch(MrnaAssaySearch): self.search_operator, self.search_term[0]) where_clause = self.sub_clause - - + return where_clause - def get_final_query(self): + + def run(self): + self.from_clause = self.get_from_clause() self.where_clause = self.get_where_clause() + self.query = self.compile_final_query(self.from_clause, self.where_clause) - return self.query + return self.execute(self.query) + +class MrnaLrsSearch(LrsSearch, MrnaAssaySearch): + + DoSearch.search_types['ProbeSet_LRS'] = 'MrnaLrsSearch' def run(self): self.from_clause = self.get_from_clause() self.where_clause = self.get_where_clause() - - self.query = self.compile_final_query(self.from_clause, self.where_clause) + self.query = self.compile_final_query(from_clause = self.from_clause, where_clause = self.where_clause) return self.execute(self.query) +class PhenotypeLrsSearch(LrsSearch, PhenotypeSearch): + + DoSearch.search_types['Publish_LRS'] = 'PhenotypeLrsSearch' + + def run(self): + + self.from_clause = self.get_from_clause() + self.where_clause = self.get_where_clause() + self.query = self.compile_final_query(from_clause = self.from_clause, where_clause = self.where_clause) + + return self.execute(self.query) class CisTransLrsSearch(LrsSearch): @@ -693,24 +704,6 @@ class MeanSearch(MrnaAssaySearch): return self.query def run(self): - - #self.search_term = [float(value) for value in self.search_term] - # - #if self.search_operator == "=": - # assert isinstance(self.search_term, (list, tuple)) - # self.mean_min, self.mean_max = self.search_term[:2] - # - # self.where_clause = """ %sXRef.mean > %s and - # %sXRef.mean < %s """ % self.mescape(self.dataset.type, - # min(self.mean_min, self.mean_max), - # self.dataset.type, - # max(self.mean_min, self.mean_max)) - #else: - # # Deal with >, <, >=, and <= - # self.where_clause = """ %sXRef.mean %s %s """ % self.mescape(self.dataset.type, - # self.search_operator, - # self.search_term[0]) - self.where_clause = self.get_where_clause() print("where_clause is:", pf(self.where_clause)) @@ -747,27 +740,6 @@ class RangeSearch(MrnaAssaySearch): return where_clause def run(self): - - #self.search_term = [float(value) for value in self.search_term] - # - #if self.search_operator == "=": - # assert isinstance(self.search_term, (list, tuple)) - # self.range_min, self.range_max = self.search_term[:2] - # self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) - # FROM ProbeSetData - # WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s AND - # (SELECT Pow(2, max(value) -min(value)) - # FROM ProbeSetData - # WHERE ProbeSetData.Id = ProbeSetXRef.dataId) < %s - # """ % self.mescape(min(self.range_min, self.range_max), - # max(self.range_min, self.range_max)) - #else: - # # Deal with >, <, >=, and <= - # self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) - # FROM ProbeSetData - # WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s - # """ % (escape(self.search_term[0])) - self.where_clause = self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) @@ -781,6 +753,10 @@ class PositionSearch(DoSearch): DoSearch.search_types[search_key] = "PositionSearch" def get_where_clause(self): + self.search_term = [float(value) if is_number(value) else value for value in self.search_term] + self.chr, self.mb_min, self.mb_max = self.search_term[:3] + self.get_chr() + where_clause = """ %s.Chr = %s and %s.Mb > %s and %s.Mb < %s """ % self.mescape(self.dataset.type, @@ -793,12 +769,6 @@ class PositionSearch(DoSearch): return where_clause - def setup(self): - self.search_term = [float(value) if is_number(value) else value for value in self.search_term] - self.chr, self.mb_min, self.mb_max = self.search_term[:3] - self.get_chr() - self.where_clause = self.get_where_clause() - def get_chr(self): try: self.chr = int(self.chr) @@ -807,7 +777,7 @@ class PositionSearch(DoSearch): def run(self): - self.setup() + self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) @@ -820,7 +790,7 @@ class MrnaPositionSearch(PositionSearch, MrnaAssaySearch): def run(self): - self.setup() + self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) @@ -833,7 +803,7 @@ class GenotypePositionSearch(PositionSearch, GenotypeSearch): def run(self): - self.setup() + self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) @@ -841,6 +811,8 @@ class GenotypePositionSearch(PositionSearch, GenotypeSearch): class PvalueSearch(MrnaAssaySearch): """Searches for traits with a permutationed p-value between low and high""" + DoSearch.search_types['ProbeSet_PVALUE'] = "PvalueSearch" + def run(self): self.search_term = [float(value) for value in self.search_term] |