aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2015-06-02 16:12:18 +0000
committerzsloan2015-06-02 16:12:18 +0000
commite0b9c2039a1d8dc804c5a3b537021b24cf371b44 (patch)
tree6b4e3e08624ec856cd2f7ef9671af8e0f52e27b9
parentce2e6b5084542e18ad7abfdbf5fdcd71006cf30b (diff)
downloadgenenetwork2-e0b9c2039a1d8dc804c5a3b537021b24cf371b44.tar.gz
Wildcard search should now work for Genotype searches
-rwxr-xr-xwqflask/wqflask/do_search.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index 4cd87270..f6f39ab0 100755
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -391,25 +391,32 @@ class GenotypeSearch(DoSearch):
self.search_term = "[[:<:]]" + self.search_term[0] + "[[:>:]]"
for field in self.search_fields:
- fields_clause.append('''%s REGEXP "%s"''' % ("%s.%s" % self.mescape(self.dataset.type,
+ where_clause.append('''%s REGEXP "%s"''' % ("%s.%s" % self.mescape(self.dataset.type,
field),
self.search_term))
- print("hello ;where_clause is:", pf(fields_clause))
- fields_clause = "(%s) " % ' OR '.join(fields_clause)
+ print("hello ;where_clause is:", pf(where_clause))
+ where_clause = "(%s) " % ' OR '.join(where_clause)
- return fields_clause
+ return where_clause
def compile_final_query(self, from_clause = '', where_clause = ''):
"""Generates the final query string"""
from_clause = self.normalize_spaces(from_clause)
- query = (self.base_query +
- """WHERE %s
- and Geno.Id = GenoXRef.GenoId
- and GenoXRef.GenoFreezeId = GenoFreeze.Id
- and GenoFreeze.Id = %s"""% (where_clause,
- escape(str(self.dataset.id))))
+
+ if self.search_term[0] == "*":
+ query = (self.base_query +
+ """WHERE Geno.Id = GenoXRef.GenoId
+ and GenoXRef.GenoFreezeId = GenoFreeze.Id
+ and GenoFreeze.Id = %s"""% (escape(str(self.dataset.id))))
+ else:
+ query = (self.base_query +
+ """WHERE %s
+ and Geno.Id = GenoXRef.GenoId
+ and GenoXRef.GenoFreezeId = GenoFreeze.Id
+ and GenoFreeze.Id = %s"""% (where_clause,
+ escape(str(self.dataset.id))))
print("query is:", pf(query))
@@ -420,7 +427,10 @@ class GenotypeSearch(DoSearch):
#Todo: Zach will figure out exactly what both these lines mean
#and comment here
- self.query = self.compile_final_query(where_clause = self.get_where_clause())
+ if self.search_term[0] == "*":
+ self.query = self.compile_final_query()
+ else:
+ self.query = self.compile_final_query(where_clause = self.get_where_clause())
return self.execute(self.query)