Skip to content

Commit 4302def

Browse files
committed
Fix #5896 - managed variants start to end interval search
1 parent 9d75872 commit 4302def

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
2020
- Tests for cli command to update VCF files not running (#5888)
2121
- Gene in panels search results broken layout - overflow when a panel has many panel versions containing the gene (#5899)
2222
- ACMG evaluation PDF export, both style and colors (#5879)
23+
- Start to end interval search for managed variants (#5917)
2324

2425
## [4.106]
2526
### Added

scout/adapter/mongo/managed_variant.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,22 @@ def add_options(self, query, query_options):
183183
"$options": "i",
184184
}
185185

186+
start = max(int(query_options.get("position", 1)), 1)
187+
end = max(int(query_options.get("end", 1)), 1)
188+
186189
if "position" in query_options:
187-
position = max(int(query_options["position"]), 1)
188-
query["end"] = {"$gte": position}
190+
query["position"] = {"$gte": start}
191+
if "end" in query_options:
192+
query["position"]["$lte"] = end
189193

190194
if "end" in query_options:
191-
end = max(int(query_options["end"]), 1)
192-
query["position"] = {"$lte": end}
195+
query.setdefault("$or", []).extend(
196+
[
197+
{"end": {"$gte": start, "$lte": end}},
198+
{"end": {"$exists": False}},
199+
{"end": {"$in": [None, ""]}},
200+
]
201+
)
193202

194203
if "sub_category" in query_options:
195204
query["sub_category"] = {"$in": query_options["sub_category"]}

tests/adapter/mongo/test_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_genotype_query_other(adapter, case_obj):
173173

174174

175175
def test_gene_symbol_gene_panel_query(adapter, case_obj):
176-
"""Test variants query using a gene panel cointaining a certain gene and a hgnc symbol of another gene"""
176+
"""Test variants query using a gene panel containing a certain gene and a hgnc symbol of another gene"""
177177

178178
# GIVEN a database containing a minimal gene panel
179179
test_gene = "POT1"
@@ -199,7 +199,7 @@ def test_gene_symbol_gene_panel_query(adapter, case_obj):
199199
query = {"hgnc_symbols": ["ATM"], "gene_panels": ["POT panel"]}
200200
mongo_query = adapter.build_query(case_obj["_id"], query=query)
201201

202-
# THEN the query should countain both genes in the hgnc_symbols list
202+
# THEN the query should contain both genes in the hgnc_symbols list
203203
mongo_query_gene_list = mongo_query["hgnc_ids"]["$in"]
204204
for gene in [test_gene_hgnc_id, other_gene_hgnc_id]:
205205
assert gene in mongo_query_gene_list

0 commit comments

Comments
 (0)