aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2019-08-15 17:29:01 -0500
committerzsloan2019-08-15 17:29:01 -0500
commit9d4717384aaa1adf0ce4b717dd5be806a1ba1a5d (patch)
tree33e9ffa267435c4b7b986c84a93596a5bca77fa8
parent12b7eebfc1190616d1bb378eb425faeda2951412 (diff)
downloadgenenetwork2-9d4717384aaa1adf0ce4b717dd5be806a1ba1a5d.tar.gz
LOD searches should now also work
-rw-r--r--wqflask/wqflask/do_search.py31
-rw-r--r--wqflask/wqflask/search_results.py1
2 files changed, 25 insertions, 7 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index c4c303fe..2eac4bb3 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -22,12 +22,13 @@ class DoSearch(object):
# Used to translate search phrases into classes
search_types = dict()
- def __init__(self, search_term, search_operator=None, dataset=None):
+ def __init__(self, search_term, search_operator=None, dataset=None, search_type=None):
self.search_term = search_term
# Make sure search_operator is something we expect
assert search_operator in (None, "=", "<", ">", "<=", ">="), "Bad search operator"
self.search_operator = search_operator
self.dataset = dataset
+ self.search_type = search_type
if self.dataset:
logger.debug("self.dataset is boo: ", type(self.dataset), pf(self.dataset))
@@ -444,7 +445,8 @@ class LrsSearch(DoSearch):
"""
- DoSearch.search_types['LRS'] = 'LrsSearch'
+ for search_key in ('LRS', 'LOD'):
+ DoSearch.search_types[search_key] = "LrsSearch"
def get_from_clause(self):
#If the user typed, for example "Chr4", the "Chr" substring needs to be removed so that all search elements can be converted to floats
@@ -465,6 +467,9 @@ class LrsSearch(DoSearch):
if self.search_operator == "=":
assert isinstance(self.search_term, (list, tuple))
lrs_min, lrs_max = self.search_term[:2]
+ if self.search_type == "LOD":
+ lrs_min = lrs_min*4.61
+ lrs_max = lrs_max*4.61
where_clause = """ %sXRef.LRS > %s and
%sXRef.LRS < %s """ % self.mescape(self.dataset.type,
@@ -489,6 +494,10 @@ class LrsSearch(DoSearch):
else:
# Deal with >, <, >=, and <=
logger.debug("self.search_term is:", self.search_term)
+ lrs_val = self.search_term[0]
+ if self.search_type == "LOD":
+ lrs_val = lrs_val*4.61
+
where_clause = """ %sXRef.LRS %s %s """ % self.mescape(self.dataset.type,
self.search_operator,
self.search_term[0])
@@ -505,9 +514,11 @@ class LrsSearch(DoSearch):
return self.execute(self.query)
+
class MrnaLrsSearch(LrsSearch, MrnaAssaySearch):
- DoSearch.search_types['ProbeSet_LRS'] = 'MrnaLrsSearch'
+ for search_key in ('LRS', 'LOD'):
+ DoSearch.search_types['ProbeSet_' + search_key] = "MrnaLrsSearch"
def run(self):
@@ -520,7 +531,8 @@ class MrnaLrsSearch(LrsSearch, MrnaAssaySearch):
class PhenotypeLrsSearch(LrsSearch, PhenotypeSearch):
- DoSearch.search_types['Publish_LRS'] = 'PhenotypeLrsSearch'
+ for search_key in ('LRS', 'LOD'):
+ DoSearch.search_types['Publish_' + search_key] = "PhenotypeLrsSearch"
def run(self):
@@ -532,7 +544,6 @@ class PhenotypeLrsSearch(LrsSearch, PhenotypeSearch):
return self.execute(self.query)
-
class CisTransLrsSearch(DoSearch):
def get_from_clause(self):
@@ -557,6 +568,10 @@ class CisTransLrsSearch(DoSearch):
else:
SomeError
+ if self.search_type == "CISLOD" or self.search_type == "TRANSLOD":
+ lrs_min = lrs_min * 4.61
+ lrs_max = lrs_max * 4.61
+
sub_clause = """ %sXRef.LRS > %s and
%sXRef.LRS < %s and """ % (
escape(self.dataset.type),
@@ -619,7 +634,8 @@ class CisLrsSearch(CisTransLrsSearch, MrnaAssaySearch):
"""
- DoSearch.search_types['ProbeSet_CISLRS'] = 'CisLrsSearch'
+ for search_key in ('LRS', 'LOD'):
+ DoSearch.search_types['ProbeSet_CIS'+search_key] = "CisLrsSearch"
def get_where_clause(self):
return CisTransLrsSearch.get_where_clause(self, "cis")
@@ -648,7 +664,8 @@ class TransLrsSearch(CisTransLrsSearch, MrnaAssaySearch):
"""
- DoSearch.search_types['ProbeSet_TRANSLRS'] = 'TransLrsSearch'
+ for search_key in ('LRS', 'LOD'):
+ DoSearch.search_types['ProbeSet_TRANS'+search_key] = "TransLrsSearch"
def get_where_clause(self):
return CisTransLrsSearch.get_where_clause(self, "trans")
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index e74fef80..be06b390 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -228,6 +228,7 @@ views.py).
the_search = search_class(search_term,
search_operator,
self.dataset,
+ search_type['key']
)
return the_search
else: