From 18cb113450b8ef17d1d1ca81062e05ce27657c00 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 12 Aug 2022 14:18:22 +0000 Subject: Change homology logic to include lines that start/end outside of the given mb range This is to avoid a situation where a user zooms in and a bar should encompass the whole area but isn't displayed (because its start/end don't both fall within the given Mb range) This commit also renames mm10/hg38 to ref/query to be more generic --- wqflask/wqflask/interval_analyst/GeneUtil.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/wqflask/wqflask/interval_analyst/GeneUtil.py b/wqflask/wqflask/interval_analyst/GeneUtil.py index 5b28f458..a3fe1269 100644 --- a/wqflask/wqflask/interval_analyst/GeneUtil.py +++ b/wqflask/wqflask/interval_analyst/GeneUtil.py @@ -9,16 +9,21 @@ def load_homology(chr_name, start_mb, end_mb, source_file): for line in h_file: line_items = line.split() this_dict = { - "mm10_chr": line_items[2][3:], - "mm10_start": float(line_items[5])/1000000, - "mm10_end": float(line_items[6])/1000000, - "hg38_chr": line_items[7][3:], - "hg38_strand": line_items[9], - "hg38_start": float(line_items[10])/1000000, - "hg38_end": float(line_items[11])/1000000 + "ref_chr": line_items[2][3:], + "ref_strand": line_items[4], + "ref_start": float(line_items[5])/1000000, + "ref_end": float(line_items[6])/1000000, + "query_chr": line_items[7][3:], + "query_strand": line_items[9], + "query_start": float(line_items[10])/1000000, + "query_end": float(line_items[11])/1000000 } - if str(this_dict["mm10_chr"]) == str(chr_name) and this_dict["mm10_start"]>= start_mb and this_dict["mm10_end"] <= end_mb: + if str(this_dict["ref_chr"]) == str(chr_name) and + ((this_dict["ref_start"]>= start_mb and this_dict["ref_end"] <= end_mb) or + (this_dict["ref_start"] < start_mb and this_dict["ref_end"] <= end_mb) or + (this_dict["ref_start"] >= start_mb and this_dict["ref_end"] > end_mb) or + (this_dict["ref_start"] < start_mb and this_dict["ref_end"] > end_mb)): homology_list.append(this_dict) return homology_list -- cgit v1.2.3