about summary refs log tree commit diff
path: root/gn3/api
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/search.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/gn3/api/search.py b/gn3/api/search.py
index 7f7a4ff..2038a14 100644
--- a/gn3/api/search.py
+++ b/gn3/api/search.py
@@ -164,12 +164,18 @@ def parse_location_field(species_query: xapian.Query,
     """
     def split_query(query: str) -> ChromosomalInterval:
         """Split query into chromosome and location tuple."""
-        chromosome, location = query.lower().split(":")
+        chromosome, location_str = query.lower().split(":")
         if not chromosome.startswith("chr"):
             raise ValueError
-        return ChromosomalInterval(chromosome.removeprefix("chr"),
-                                   *[location.map(apply_si_suffix)
-                                     for location in parse_range(location)])
+        location: tuple[Maybe[int], Maybe[int]]
+        if ".." in location_str:
+            location = tuple(limit.map(apply_si_suffix) for limit in parse_range(location_str))
+        # If point location, assume +/- 50 kbases on either side.
+        else:
+            width = 50*10**3
+            point = apply_si_suffix(location_str)
+            location = Just(point - width), Just(point + width)
+        return ChromosomalInterval(chromosome.removeprefix("chr"), *location)
 
     def make_query(interval: ChromosomalInterval) -> xapian.Query:
         # TODO: Convert the xapian index to use bases instead of megabases.