From 6496f75af521d6801c25de682d2852e14d597fed Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 24 Feb 2022 21:53:56 +0000 Subject: Fix ProbeSet query for aliases ProbeSet queries previously weren't dealing with aliases correctly, because it was doing a MATCH/AGAINST against the ProbeSet.alias field, but that field usually contains a list of gene symbols separated by semi-colons (so it wouldn't detect the alias unless there was only a single alias. To fix this, I added some LIKE conditions, searching for the possible variations. This is a little awkward, because I needed to make sure to avoid a situation where, for example, an alias like 'LPD-1' matches a search for 'PD-1'. I don't think the way it currently works is efficient, but I don't know of any good alternative without changing the way we store aliases in the database. --- wqflask/wqflask/do_search.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 5c182260..f8cc482f 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -137,15 +137,18 @@ class MrnaAssaySearch(DoSearch): search_string = escape(self.search_term[0]) if self.search_term[0] != "*": - match_clause = """((MATCH (ProbeSet.Name, + match_clause = f"""((MATCH (ProbeSet.Name, ProbeSet.description, ProbeSet.symbol, - alias, GenbankId, UniGeneId, Probe_Target_Description) - AGAINST ('%s' IN BOOLEAN MODE))) AND - """ % (search_string) + AGAINST ('{search_string}' IN BOOLEAN MODE)) OR ( + alias LIKE '%%; {search_string};%%' OR + alias LIKE '{search_string};%%' OR + alias LIKE '%%; {search_string}' OR + alias LIKE '{search_string}' + )) AND """ else: match_clause = "" -- cgit v1.2.3