diff options
author | zsloan | 2022-04-21 20:28:07 +0000 |
---|---|---|
committer | zsloan | 2022-04-21 20:28:07 +0000 |
commit | d0efb29688cee6e8dd6086844a7f0b5992228cd7 (patch) | |
tree | 6e662ac70b29a59b873e6464d1e2bbcf3b075bf9 /wqflask | |
parent | 36ce17239c002749e59b65d13402bd31375dfaf1 (diff) | |
download | genenetwork2-d0efb29688cee6e8dd6086844a7f0b5992228cd7.tar.gz |
Change searches to interpret any string starting with c/C as chromosome
Previously search terms with chromosome as a parameter would only search
for Chr or chr specifically; this changes them to detect any string
starting with a C/c (so it would detect, for example, 'ch4' as
chromosome 4)
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/do_search.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index fa18c10b..b0756361 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -540,8 +540,10 @@ class LrsSearch(DoSearch): 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] - if "chr" in self.search_term[2].lower(): - chr_num = self.search_term[2].lower().replace("chr", "") + chr_str = re.match("(^c|^C)[a-z]*", 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: @@ -632,8 +634,9 @@ class CisTransLrsSearch(DoSearch): lrs_min, lrs_max, self.mb_buffer = [ float(value) for value in self.search_term[:3]] chromosome = self.search_term[3] - if "Chr" in chromosome or "chr" in chromosome: - chromosome = int(chromosome[3:]) + chr_str = re.match("(^c|^C)[a-z]*", chromosome) + if chr_str: + chromosome = int(chromosome.replace(chr_str.group(0), '')) else: SomeError @@ -863,10 +866,9 @@ class PositionSearch(DoSearch): try: self.chr = int(self.chr) except: - if 'chr' in self.chr: - self.chr = self.chr.replace('chr', '') - else: - self.chr = self.chr.replace('CHR', '') + chr_str = re.match("(^c|^C)[a-z]*", self.chr) + if chr_str: + self.chr = self.chr.replace(chr_str.group(0), '') def run(self): |