aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2015-02-19 19:51:37 +0000
committerPjotr Prins2015-03-12 07:42:22 +0300
commitcb97cb560ceaa88ad0a4087a3004d18331e88267 (patch)
tree16f912dde44dec90c69cb2615231c4fc65e0de54 /wqflask
parent3d144d2610acf122dc7b00fbeba15ee4b21348af (diff)
downloadgenenetwork2-cb97cb560ceaa88ad0a4087a3004d18331e88267.tar.gz
Just committing changes to search so I can pull to production branch
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/wqflask/do_search.py98
-rwxr-xr-xwqflask/wqflask/search_results.py28
2 files changed, 110 insertions, 16 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index 29f3de98..f00f0c20 100755
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -139,11 +139,8 @@ class MrnaAssaySearch(DoSearch):
return query
- def run(self):
- """Generates and runs a simple search of an mRNA expression dataset"""
-
- print("Running ProbeSetSearch")
- query = self.base_query + """WHERE (MATCH (ProbeSet.Name,
+ def get_where_clause(self):
+ where_clause = """(MATCH (ProbeSet.Name,
ProbeSet.description,
ProbeSet.symbol,
alias,
@@ -156,6 +153,15 @@ class MrnaAssaySearch(DoSearch):
""" % (escape(self.search_term[0]),
escape(str(self.dataset.id)))
+ return where_clause
+
+ def run(self):
+ """Generates and runs a simple search of an mRNA expression dataset"""
+
+ print("Running ProbeSetSearch")
+ where_clause = self.get_where_clause()
+ query = self.base_query + "WHERE " + where_clause
+
#print("final query is:", pf(query))
return self.execute(query)
@@ -433,12 +439,9 @@ class LrsSearch(MrnaAssaySearch):
DoSearch.search_types['LRS'] = 'LrsSearch'
- def run(self):
-
+ def get_where_clause(self):
self.search_term = [float(value) for value in self.search_term]
- self.from_clause = ", Geno"
-
if self.search_operator == "=":
assert isinstance(self.search_term, (list, tuple))
self.lrs_min, self.lrs_max = self.search_term[:2]
@@ -466,14 +469,56 @@ class LrsSearch(MrnaAssaySearch):
self.search_operator,
self.search_term[0])
- self.where_clause = self.sub_clause + """ %sXRef.Locus = Geno.name and
+ where_clause = self.sub_clause + """ %sXRef.Locus = Geno.name and
Geno.SpeciesId = %s and
%s.Chr = Geno.Chr
""" % self.mescape(self.dataset.type,
self.species_id,
self.dataset.type)
- print("where_clause is:", pf(self.where_clause))
+ return where_clause
+
+ def run(self):
+
+ self.from_clause = ", Geno"
+
+ #self.search_term = [float(value) for value in self.search_term]
+ #
+ #if self.search_operator == "=":
+ # assert isinstance(self.search_term, (list, tuple))
+ # self.lrs_min, self.lrs_max = self.search_term[:2]
+ #
+ # self.sub_clause = """ %sXRef.LRS > %s and
+ # %sXRef.LRS < %s and """ % self.mescape(self.dataset.type,
+ # min(self.lrs_min, self.lrs_max),
+ # self.dataset.type,
+ # max(self.lrs_min, self.lrs_max))
+ #
+ # if len(self.search_term) > 2:
+ # self.chr_num = self.search_term[2]
+ # self.sub_clause += """ Geno.Chr = %s and """ % (escape(self.chr_num))
+ # if len(self.search_term) == 5:
+ # self.mb_low, self.mb_high = self.search_term[3:]
+ # self.sub_clause += """ Geno.Mb > %s and
+ # Geno.Mb < %s and
+ # """ % self.mescape(min(self.mb_low, self.mb_high),
+ # max(self.mb_low, self.mb_high))
+ # print("self.sub_clause is:", pf(self.sub_clause))
+ #else:
+ # # Deal with >, <, >=, and <=
+ # print("self.search_term is:", self.search_term)
+ # self.sub_clause = """ %sXRef.LRS %s %s and """ % self.mescape(self.dataset.type,
+ # self.search_operator,
+ # self.search_term[0])
+ #
+ #self.where_clause = self.sub_clause + """ %sXRef.Locus = Geno.name and
+ # Geno.SpeciesId = %s and
+ # %s.Chr = Geno.Chr
+ # """ % self.mescape(self.dataset.type,
+ # self.species_id,
+ # self.dataset.type)
+
+ self.where_clause = self.get_where_clause()
self.query = self.compile_final_query(self.from_clause, self.where_clause)
@@ -586,25 +631,46 @@ class MeanSearch(MrnaAssaySearch):
DoSearch.search_types['MEAN'] = "MeanSearch"
- def run(self):
-
+ def get_where_clause(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
+ 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,
+ where_clause = """ %sXRef.mean %s %s """ % self.mescape(self.dataset.type,
self.search_operator,
- self.search_term[0])
+ self.search_term[0])
+
+ 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.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))
self.query = self.compile_final_query(where_clause = self.where_clause)
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index c6521106..fdf04d44 100755
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -221,6 +221,34 @@ class SearchResultPage(object):
self.search_terms = parser.parse(self.search_terms)
print("After parsing:", self.search_terms)
+ if len(self.search_terms) > 1:
+ combined_where_clause = ""
+ for i, a_search in enumerate(self.search_terms):
+ print("[kodak] item is:", pf(a_search))
+ search_term = a_search['search_term']
+ search_operator = a_search['separator']
+ if a_search['key']:
+ search_type = a_search['key'].upper()
+ else:
+ # We fall back to the dataset type as the key to get the right object
+ search_type = self.dataset.type
+
+ print("search_type is:", pf(search_type))
+
+ search_ob = do_search.DoSearch.get_search(search_type)
+ search_class = getattr(do_search, search_ob)
+ the_search = search_class(search_term,
+ search_operator,
+ self.dataset,
+ )
+
+ where_clause = the_search.get_where_clause()
+ combined_where_clause += "(" + where_clause + ")"
+ if (i+1) < len(self.search_terms):
+ combined_where_clause += "AND"
+ print("combined_where_clause:", combined_where_clause)
+
+
for a_search in self.search_terms:
print("[kodak] item is:", pf(a_search))
search_term = a_search['search_term']