From 97a4c1951cf92a9b1f4151953439a6dc3119da5f Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 2 Jun 2015 22:04:48 +0000 Subject: Wildcards can now be appended to mRNA assay searches, but isn't working correctly yet with phenotypes --- wqflask/wqflask/do_search.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index f6f39ab0..529befb4 100755 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -3,6 +3,8 @@ from __future__ import print_function, division +import string + from flask import Flask, g from MySQLdb import escape_string as escape @@ -40,6 +42,13 @@ class DoSearch(object): results = g.db.execute(query, no_parameters=True).fetchall() return results + def handle_wildcard(self, str): + keyword = str.strip() + keyword.replace("*",".*") + keyword.replace("?",".") + + return keyword + #def escape(self, stringy): # """Shorter name than self.db_conn.escape_string""" # return escape(str(stringy)) @@ -237,7 +246,7 @@ class PhenotypeSearch(DoSearch): #Todo: Zach will figure out exactly what both these lines mean #and comment here if "'" not in self.search_term[0]: - search_term = "[[:<:]]" + self.search_term[0] + "[[:>:]]" + search_term = "[[:<:]]" + self.handle_wildcard(self.search_term[0]) + "[[:>:]]" # This adds a clause to the query that matches the search term # against each field in the search_fields tuple -- cgit v1.2.3