diff options
author | Zachary Sloan | 2012-11-30 14:04:59 -0600 |
---|---|---|
committer | Zachary Sloan | 2012-11-30 14:04:59 -0600 |
commit | 7929d5d5aace20b50a9c5b428eea784d8eac0b77 (patch) | |
tree | 490cc498d2876de01e395103f859e1aaf3957f56 | |
parent | 94300b4488aa334ced34981981ad5d0ecdec01d6 (diff) | |
download | genenetwork2-7929d5d5aace20b50a9c5b428eea784d8eac0b77.tar.gz |
Got searches working for RANGE and MEAN commands
Created a file where renamed variables will be listed for future reference
-rw-r--r-- | misc/new_variable_names.txt | 5 | ||||
-rw-r--r-- | wqflask/wqflask/do_search.py | 59 |
2 files changed, 61 insertions, 3 deletions
diff --git a/misc/new_variable_names.txt b/misc/new_variable_names.txt new file mode 100644 index 00000000..2b10c07e --- /dev/null +++ b/misc/new_variable_names.txt @@ -0,0 +1,5 @@ +RISet/riset -> group +webqtlDataset.py -> data_set.py +webqtlDataset (class object) -> DataSet +database/db -> dataset/data_set +DataEditingPage -> show_trait.py/show_trait.html diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 92a754e3..11411b26 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -414,8 +414,7 @@ class CisLrsSearch(CisTransLrsSearch): def run(self): return self.real_run("<") - - + class TransLrsSearch(CisTransLrsSearch): """Searches for genes on a particular chromosome with a cis-eQTL within the given LRS values @@ -443,9 +442,63 @@ class MeanSearch(ProbeSetSearch): DoSearch.search_types['MEAN'] = "MeanSearch" def run(self): + + self.search_term = [float(value) for value in self.search_term] - return None + 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]) + + print("where_clause is:", pf(self.where_clause)) + + self.query = self.compile_final_query(where_clause = self.where_clause) + + return self.execute(self.query) + +class RangeSearch(ProbeSetSearch): + """Searches for genes with a range of expression varying between two values""" + + DoSearch.search_types['RANGE'] = "RangeSearch" + + 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.range_min, self.range_max = self.search_term[:2] + self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) + FROM ProbeSetData + WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s AND + (SELECT Pow(2, max(value) -min(value)) + FROM ProbeSetData + WHERE ProbeSetData.Id = ProbeSetXRef.dataId) < %s + """ % self.mescape(min(self.range_min, self.range_max), + max(self.range_min, self.range_max)) + else: + # Deal with >, <, >=, and <= + self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) + FROM ProbeSetData + WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s + """ % (self.escape(self.search_term[0])) + + print("where_clause is:", pf(self.where_clause)) + + self.query = self.compile_final_query(where_clause = self.where_clause) + + return self.execute(self.query) + if __name__ == "__main__": ### Usually this will be used as a library, but call it from the command line for testing |