diff options
author | zsloan | 2023-07-31 17:41:43 +0000 |
---|---|---|
committer | zsloan | 2023-07-31 17:43:18 +0000 |
commit | 9f62caa68b541d683b2a744af19c0ad4c6d0d206 (patch) | |
tree | b72924d70d45d782bf1523e109e5b0a3073bef33 | |
parent | da5ff246e984ba622600ae7ba5369a49c6957429 (diff) | |
download | genenetwork2-9f62caa68b541d683b2a744af19c0ad4c6d0d206.tar.gz |
Fix searches so they work with chromosomes X/Y and both including and not including 'chr'
As far as I can tell, the regex from before wasn't necessary; it seems like a simple matter of extracting the 'chr' substring from the chromosome search term
-rw-r--r-- | wqflask/wqflask/do_search.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 9bc92247..0ce3bf62 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -522,13 +522,12 @@ class LrsSearch(DoSearch): max(lrs_min, lrs_max)) if len(self.search_term) > 2: - # If the user typed, for example "Chr4", the "Chr" substring needs to be removed so that all search elements can be converted to floats - chr_num = self.search_term[2] - chr_str = re.match("(^c|^C)[a-z]*", chr_num) + try: + chr_num = int(float(self.search_term[2])) + except: + chr_num = self.search_term[2].lower().replace('chr', '') + self.search_term[2] = chr_num - if chr_str: - chr_num = self.search_term[2].replace(chr_str.group(0), "") - self.search_term[2] = chr_num where_clause += """ and Geno.Chr = '%s' """ % (chr_num) if len(self.search_term) == 5: mb_low, mb_high = self.search_term[3:] @@ -843,11 +842,9 @@ class PositionSearch(DoSearch): def get_chr(self): try: - self.chr = int(self.chr) + self.chr = int(float(self.chr)) except: - chr_str = re.match("(^c|^C)[a-z]*", self.chr) - if chr_str: - self.chr = self.chr.replace(chr_str.group(0), '') + self.chr = self.chr.lower().replace('chr', '') def run(self): |