seqmat 1.3.1__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {seqmat-1.3.1/seqmat.egg-info → seqmat-1.4.0}/PKG-INFO +1 -1
  2. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/__init__.py +4 -1
  3. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/gene.py +28 -0
  4. seqmat-1.4.0/seqmat/locator.py +235 -0
  5. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/sqlite_store.py +3 -2
  6. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/utils.py +9 -0
  7. {seqmat-1.3.1 → seqmat-1.4.0/seqmat.egg-info}/PKG-INFO +1 -1
  8. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat.egg-info/SOURCES.txt +2 -0
  9. {seqmat-1.3.1 → seqmat-1.4.0}/setup.py +1 -1
  10. seqmat-1.4.0/tests/test_locator.py +108 -0
  11. {seqmat-1.3.1 → seqmat-1.4.0}/LICENSE +0 -0
  12. {seqmat-1.3.1 → seqmat-1.4.0}/MANIFEST.in +0 -0
  13. {seqmat-1.3.1 → seqmat-1.4.0}/README.md +0 -0
  14. {seqmat-1.3.1 → seqmat-1.4.0}/examples/basic_usage.py +0 -0
  15. {seqmat-1.3.1 → seqmat-1.4.0}/examples/data_inspection.py +0 -0
  16. {seqmat-1.3.1 → seqmat-1.4.0}/requirements.txt +0 -0
  17. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/cli.py +0 -0
  18. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/config.py +0 -0
  19. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/lmdb_store.py +0 -0
  20. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/seqmat.py +0 -0
  21. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat/transcript.py +0 -0
  22. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat.egg-info/dependency_links.txt +0 -0
  23. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat.egg-info/entry_points.txt +0 -0
  24. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat.egg-info/requires.txt +0 -0
  25. {seqmat-1.3.1 → seqmat-1.4.0}/seqmat.egg-info/top_level.txt +0 -0
  26. {seqmat-1.3.1 → seqmat-1.4.0}/setup.cfg +0 -0
  27. {seqmat-1.3.1 → seqmat-1.4.0}/tests/__init__.py +0 -0
  28. {seqmat-1.3.1 → seqmat-1.4.0}/tests/bench_gene_creation.py +0 -0
  29. {seqmat-1.3.1 → seqmat-1.4.0}/tests/test_gene.py +0 -0
  30. {seqmat-1.3.1 → seqmat-1.4.0}/tests/test_seqmat.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 1.3.1
3
+ Version: 1.4.0
4
4
  Summary: Lightning-fast gene manipulation and analysis library.
5
5
  Home-page: https://github.com/nicolasalynn/seqmat
6
6
  Author: Nicolas Lynn Vila
@@ -5,7 +5,7 @@ A comprehensive Python library for genomic sequence analysis with full mutation
5
5
  splicing analysis, and sequence manipulation.
6
6
  """
7
7
 
8
- __version__ = "1.3.1"
8
+ __version__ = "1.4.0"
9
9
  __author__ = "Nicolas Lynn Vila"
10
10
  __email__ = "nicolasalynn@gmail.com"
11
11
 
@@ -14,6 +14,7 @@ from .gene import Gene
14
14
  from .transcript import Transcript
15
15
  from .config import get_default_organism, get_data_dir, get_config_dir, get_config_file, get_data_base
16
16
  from .lmdb_store import build_lmdb
17
+ from .locator import gene_names_at_position, build_location_index
17
18
  from .utils import (
18
19
  setup_genomics_data,
19
20
  set_fasta_path,
@@ -57,4 +58,6 @@ __all__ = [
57
58
  "get_all_genes",
58
59
  "available_genes",
59
60
  "build_lmdb",
61
+ "gene_names_at_position",
62
+ "build_location_index",
60
63
  ]
@@ -6,6 +6,7 @@ from pathlib import Path
6
6
  from .config import get_organism_config, get_default_organism
7
7
  from .utils import unload_pickle
8
8
  from .transcript import Transcript
9
+ from .locator import PosArg, gene_names_at_position
9
10
 
10
11
 
11
12
  class Gene:
@@ -136,6 +137,33 @@ class Gene:
136
137
  organism=organism
137
138
  )
138
139
 
140
+ @classmethod
141
+ def from_position(
142
+ cls,
143
+ chrm: str,
144
+ pos: PosArg,
145
+ organism: Optional[str] = None,
146
+ ) -> List['Gene']:
147
+ """Return all genes overlapping a point or range on a chromosome.
148
+
149
+ Args:
150
+ chrm: Chromosome (e.g. "12", "chr12", "X"). Leading 'chr' is stripped.
151
+ pos: Either an int position or a (start, end) tuple (inclusive).
152
+ organism: Organism build (uses default if None).
153
+
154
+ Returns:
155
+ List of Gene objects, possibly empty. Returned in ascending start order.
156
+ """
157
+ if organism is None:
158
+ organism = get_default_organism()
159
+ names = gene_names_at_position(chrm, pos, organism=organism)
160
+ genes: List['Gene'] = []
161
+ for name in names:
162
+ g = cls.from_file(name, organism=organism)
163
+ if g is not None:
164
+ genes.append(g)
165
+ return genes
166
+
139
167
  def splice_sites(self) -> Tuple[Counter, Counter]:
140
168
  """Return (Counter of acceptors, Counter of donors) across all transcripts."""
141
169
  acceptors: List[Any] = []
@@ -0,0 +1,235 @@
1
+ """Fast (chromosome, position) -> gene lookup.
2
+
3
+ Strategy: build a compact per-chromosome interval index from genes.db, persist it as a
4
+ sidecar ``gene_locations.npz`` next to genes.db, and cache it in memory. Queries are
5
+ O(log n) via ``np.searchsorted`` plus a vectorized end-bound check on the surviving
6
+ candidates — sub-microsecond per lookup for typical chromosomes.
7
+
8
+ The sidecar is built lazily on first query if missing, and is also produced by
9
+ ``retrieve_and_parse_ensembl_annotations`` for fresh builds.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import pickle
14
+ import sqlite3
15
+ import threading
16
+ from pathlib import Path
17
+ from typing import Any, Dict, List, Optional, Tuple, Union
18
+
19
+ import numpy as np
20
+
21
+ from .config import get_default_organism, get_organism_config
22
+
23
+
24
+ PosArg = Union[int, Tuple[int, int], List[int]]
25
+
26
+
27
+ _INDEX_CACHE: Dict[str, "_LocationIndex"] = {}
28
+ _BUILD_LOCK = threading.Lock()
29
+
30
+
31
+ def _normalize_chrm(chrm: str) -> str:
32
+ """Strip a leading 'chr'/'CHR' and uppercase. genes.db stores chromosomes without 'chr'."""
33
+ c = str(chrm).strip()
34
+ if c[:3].lower() == "chr":
35
+ c = c[3:]
36
+ return c.upper()
37
+
38
+
39
+ def _coerce_pos(pos: PosArg) -> Tuple[int, int]:
40
+ """Return (start, end) inclusive bounds for a point or range query."""
41
+ if isinstance(pos, (tuple, list)):
42
+ if len(pos) != 2:
43
+ raise ValueError(f"Range query must be (start, end); got {pos!r}")
44
+ a, b = int(pos[0]), int(pos[1])
45
+ return (a, b) if a <= b else (b, a)
46
+ p = int(pos)
47
+ return p, p
48
+
49
+
50
+ def _locations_path(organism: str) -> Path:
51
+ """Sidecar path: ``<organism dir>/gene_locations.npz``."""
52
+ config = get_organism_config(organism)
53
+ db_path = Path(config["genes_db"])
54
+ return db_path.parent / "gene_locations.npz"
55
+
56
+
57
+ def _genes_db_path(organism: str) -> Path:
58
+ config = get_organism_config(organism)
59
+ return Path(config["genes_db"])
60
+
61
+
62
+ class _LocationIndex:
63
+ """Per-organism index: chrm -> (starts, ends, names) sorted by start."""
64
+
65
+ __slots__ = ("by_chrm",)
66
+
67
+ def __init__(self, by_chrm: Dict[str, Tuple[np.ndarray, np.ndarray, np.ndarray]]):
68
+ self.by_chrm = by_chrm
69
+
70
+ def query_names(self, chrm: str, pos: PosArg) -> List[str]:
71
+ """Return gene names whose interval overlaps the point or range."""
72
+ key = _normalize_chrm(chrm)
73
+ entry = self.by_chrm.get(key)
74
+ if entry is None:
75
+ return []
76
+ starts, ends, names = entry
77
+ qs, qe = _coerce_pos(pos)
78
+ # Candidates: starts <= qe. searchsorted returns the insertion point on the right
79
+ # so all indices [0, hi) satisfy starts <= qe.
80
+ hi = int(np.searchsorted(starts, qe, side="right"))
81
+ if hi == 0:
82
+ return []
83
+ mask = ends[:hi] >= qs
84
+ if not mask.any():
85
+ return []
86
+ return names[:hi][mask].tolist()
87
+
88
+ def save(self, path: Path) -> None:
89
+ path.parent.mkdir(parents=True, exist_ok=True)
90
+ chroms = sorted(self.by_chrm.keys())
91
+ out: Dict[str, np.ndarray] = {"__chroms__": np.array(chroms, dtype=object)}
92
+ for c in chroms:
93
+ starts, ends, names = self.by_chrm[c]
94
+ out[f"s::{c}"] = starts
95
+ out[f"e::{c}"] = ends
96
+ out[f"n::{c}"] = names
97
+ # allow_pickle is needed because gene-name arrays are object dtype.
98
+ np.savez(str(path), **out)
99
+
100
+ @classmethod
101
+ def load(cls, path: Path) -> "_LocationIndex":
102
+ with np.load(str(path), allow_pickle=True) as z:
103
+ chroms = z["__chroms__"].tolist()
104
+ by_chrm: Dict[str, Tuple[np.ndarray, np.ndarray, np.ndarray]] = {}
105
+ for c in chroms:
106
+ by_chrm[str(c)] = (
107
+ z[f"s::{c}"].astype(np.int64, copy=False),
108
+ z[f"e::{c}"].astype(np.int64, copy=False),
109
+ z[f"n::{c}"],
110
+ )
111
+ return cls(by_chrm)
112
+
113
+ @classmethod
114
+ def build_from_db(cls, db_path: Path) -> "_LocationIndex":
115
+ """Scan genes.db, unpickle each BLOB, extract (chrm, gene_start, gene_end, identifier).
116
+
117
+ Identifier prefers ``gene_name``; falls back to ``gene_id`` when the name is empty
118
+ (common for Ensembl lncRNAs/pseudogenes).
119
+ """
120
+ if not db_path.exists():
121
+ raise FileNotFoundError(f"genes.db not found at {db_path}")
122
+ per_chrm: Dict[str, List[Tuple[int, int, str]]] = {}
123
+ conn = sqlite3.connect(str(db_path))
124
+ try:
125
+ cur = conn.execute("SELECT gene_name, gene_id, data FROM genes")
126
+ for gene_name, gene_id, blob in cur:
127
+ if blob is None:
128
+ continue
129
+ try:
130
+ data = pickle.loads(blob)
131
+ except Exception:
132
+ continue
133
+ chrm = data.get("chrm")
134
+ start = data.get("gene_start")
135
+ end = data.get("gene_end")
136
+ if chrm is None or start is None or end is None:
137
+ continue
138
+ ident = gene_name if (gene_name and str(gene_name).strip()) else gene_id
139
+ if not ident:
140
+ continue
141
+ if start > end:
142
+ start, end = end, start
143
+ key = _normalize_chrm(str(chrm))
144
+ per_chrm.setdefault(key, []).append((int(start), int(end), str(ident)))
145
+ finally:
146
+ conn.close()
147
+
148
+ by_chrm: Dict[str, Tuple[np.ndarray, np.ndarray, np.ndarray]] = {}
149
+ for c, rows in per_chrm.items():
150
+ rows.sort(key=lambda r: r[0])
151
+ starts = np.fromiter((r[0] for r in rows), dtype=np.int64, count=len(rows))
152
+ ends = np.fromiter((r[1] for r in rows), dtype=np.int64, count=len(rows))
153
+ names = np.array([r[2] for r in rows], dtype=object)
154
+ by_chrm[c] = (starts, ends, names)
155
+ return cls(by_chrm)
156
+
157
+
158
+ def _get_index(organism: Optional[str] = None, rebuild: bool = False) -> _LocationIndex:
159
+ """Return the cached index for organism, loading or building as needed."""
160
+ if organism is None:
161
+ organism = get_default_organism()
162
+ if not rebuild and organism in _INDEX_CACHE:
163
+ return _INDEX_CACHE[organism]
164
+
165
+ with _BUILD_LOCK:
166
+ if not rebuild and organism in _INDEX_CACHE:
167
+ return _INDEX_CACHE[organism]
168
+ npz_path = _locations_path(organism)
169
+ if npz_path.exists() and not rebuild:
170
+ index = _LocationIndex.load(npz_path)
171
+ else:
172
+ db_path = _genes_db_path(organism)
173
+ index = _LocationIndex.build_from_db(db_path)
174
+ try:
175
+ index.save(npz_path)
176
+ except OSError:
177
+ # Read-only data dir is fine; we still have it in memory.
178
+ pass
179
+ _INDEX_CACHE[organism] = index
180
+ return index
181
+
182
+
183
+ def build_location_index(organism: Optional[str] = None, force: bool = False) -> Path:
184
+ """Build (or rebuild) the on-disk location index for an organism.
185
+
186
+ Returns the sidecar path. Use ``force=True`` to overwrite an existing index.
187
+ """
188
+ if organism is None:
189
+ organism = get_default_organism()
190
+ npz_path = _locations_path(organism)
191
+ if npz_path.exists() and not force:
192
+ _INDEX_CACHE.pop(organism, None)
193
+ _get_index(organism)
194
+ return npz_path
195
+ _INDEX_CACHE.pop(organism, None)
196
+ _get_index(organism, rebuild=True)
197
+ return npz_path
198
+
199
+
200
+ def gene_names_at_position(
201
+ chrm: str, pos: PosArg, organism: Optional[str] = None
202
+ ) -> List[str]:
203
+ """Fast name-only lookup: gene names overlapping a point or range. No BLOB load."""
204
+ return _get_index(organism).query_names(chrm, pos)
205
+
206
+
207
+ def write_location_index_from_rows(
208
+ organism_dir: Path, rows: List[Tuple[str, int, int, str]]
209
+ ) -> Path:
210
+ """Write a location index directly from rows, without scanning genes.db.
211
+
212
+ Used by the GTF build path so a fresh setup gets the sidecar for free.
213
+
214
+ Each row is ``(chrm, gene_start, gene_end, gene_name)``.
215
+ """
216
+ per_chrm: Dict[str, List[Tuple[int, int, str]]] = {}
217
+ for chrm, start, end, name in rows:
218
+ if chrm is None or start is None or end is None or name is None:
219
+ continue
220
+ if start > end:
221
+ start, end = end, start
222
+ per_chrm.setdefault(_normalize_chrm(str(chrm)), []).append(
223
+ (int(start), int(end), str(name))
224
+ )
225
+ by_chrm: Dict[str, Tuple[np.ndarray, np.ndarray, np.ndarray]] = {}
226
+ for c, rs in per_chrm.items():
227
+ rs.sort(key=lambda r: r[0])
228
+ starts = np.fromiter((r[0] for r in rs), dtype=np.int64, count=len(rs))
229
+ ends = np.fromiter((r[1] for r in rs), dtype=np.int64, count=len(rs))
230
+ names = np.array([r[2] for r in rs], dtype=object)
231
+ by_chrm[c] = (starts, ends, names)
232
+ index = _LocationIndex(by_chrm)
233
+ out = Path(organism_dir) / "gene_locations.npz"
234
+ index.save(out)
235
+ return out
@@ -36,9 +36,10 @@ def load_gene_from_sqlite(gene_name: str, organism: Optional[str] = None) -> Opt
36
36
  import sqlite3
37
37
  conn = sqlite3.connect(db_path)
38
38
  conn.row_factory = sqlite3.Row
39
+ key = gene_name.strip()
39
40
  cursor = conn.execute(
40
- "SELECT data FROM genes WHERE UPPER(gene_name) = UPPER(?) LIMIT 1",
41
- (gene_name.strip(),),
41
+ "SELECT data FROM genes WHERE UPPER(gene_name) = UPPER(?) OR gene_id = ? LIMIT 1",
42
+ (key, key),
42
43
  )
43
44
  row = cursor.fetchone()
44
45
  conn.close()
@@ -473,6 +473,15 @@ def retrieve_and_parse_ensembl_annotations(
473
473
  conn.close()
474
474
  print(f"Wrote {genes_db}")
475
475
 
476
+ # Sidecar position index for chrom/position -> gene lookups.
477
+ try:
478
+ from .locator import _LocationIndex
479
+ idx = _LocationIndex.build_from_db(genes_db)
480
+ idx.save(local_path / 'gene_locations.npz')
481
+ print(f"Wrote {local_path / 'gene_locations.npz'}")
482
+ except Exception as exc:
483
+ print(f"Warning: failed to build gene_locations.npz sidecar: {exc}")
484
+
476
485
  def split_fasta(input_file: Path, output_directory: Path, skip_existing: bool = False) -> None:
477
486
  """Split a FASTA file into individual chromosome files."""
478
487
  print("Splitting FASTA file by chromosome...")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 1.3.1
3
+ Version: 1.4.0
4
4
  Summary: Lightning-fast gene manipulation and analysis library.
5
5
  Home-page: https://github.com/nicolasalynn/seqmat
6
6
  Author: Nicolas Lynn Vila
@@ -10,6 +10,7 @@ seqmat/cli.py
10
10
  seqmat/config.py
11
11
  seqmat/gene.py
12
12
  seqmat/lmdb_store.py
13
+ seqmat/locator.py
13
14
  seqmat/seqmat.py
14
15
  seqmat/sqlite_store.py
15
16
  seqmat/transcript.py
@@ -23,4 +24,5 @@ seqmat.egg-info/top_level.txt
23
24
  tests/__init__.py
24
25
  tests/bench_gene_creation.py
25
26
  tests/test_gene.py
27
+ tests/test_locator.py
26
28
  tests/test_seqmat.py
@@ -8,7 +8,7 @@ long_description = (this_directory / "README.md").read_text()
8
8
 
9
9
  setup(
10
10
  name="seqmat",
11
- version="1.3.1",
11
+ version="1.4.0",
12
12
  author="Nicolas Lynn Vila",
13
13
  author_email="nicolasalynn@gmail.com",
14
14
  description="Lightning-fast gene manipulation and analysis library.",
@@ -0,0 +1,108 @@
1
+ """Tests for the (chromosome, position) -> gene lookup."""
2
+ import pickle
3
+ import sqlite3
4
+ from unittest.mock import patch
5
+
6
+ import numpy as np
7
+ import pytest
8
+
9
+ from seqmat.locator import (
10
+ _LocationIndex,
11
+ _coerce_pos,
12
+ _normalize_chrm,
13
+ gene_names_at_position,
14
+ )
15
+
16
+
17
+ def _make_gene_blob(name: str, gene_id: str, chrm: str, start: int, end: int) -> bytes:
18
+ return pickle.dumps({
19
+ "gene_name": name,
20
+ "gene_id": gene_id,
21
+ "chrm": chrm,
22
+ "gene_start": start,
23
+ "gene_end": end,
24
+ "rev": False,
25
+ "transcripts": {},
26
+ })
27
+
28
+
29
+ @pytest.fixture
30
+ def fake_db(tmp_path):
31
+ """A small genes.db with a handful of overlapping and adjacent genes."""
32
+ db_path = tmp_path / "genes.db"
33
+ conn = sqlite3.connect(str(db_path))
34
+ conn.execute("CREATE TABLE genes (gene_name TEXT, gene_id TEXT, biotype TEXT, data BLOB)")
35
+ rows = [
36
+ ("KRAS", "ENSG_KRAS", "protein_coding", _make_gene_blob("KRAS", "ENSG_KRAS", "12", 100, 200)),
37
+ ("LRMP", "ENSG_LRMP", "protein_coding", _make_gene_blob("LRMP", "ENSG_LRMP", "12", 150, 175)),
38
+ ("FOO", "ENSG_FOO", "protein_coding", _make_gene_blob("FOO", "ENSG_FOO", "12", 300, 400)),
39
+ ("TP53", "ENSG_TP53", "protein_coding", _make_gene_blob("TP53", "ENSG_TP53", "17", 500, 600)),
40
+ # Unnamed gene: gene_name is empty, only gene_id available (Ensembl pseudogenes etc.)
41
+ ("", "ENSG_X", "lncRNA", _make_gene_blob("", "ENSG_X", "X", 1000, 2000)),
42
+ ]
43
+ conn.executemany(
44
+ "INSERT INTO genes (gene_name, gene_id, biotype, data) VALUES (?, ?, ?, ?)",
45
+ rows,
46
+ )
47
+ conn.commit()
48
+ conn.close()
49
+ return db_path
50
+
51
+
52
+ def test_normalize_chrm():
53
+ assert _normalize_chrm("chr12") == "12"
54
+ assert _normalize_chrm("Chr12") == "12"
55
+ assert _normalize_chrm("CHRX") == "X"
56
+ assert _normalize_chrm("12") == "12"
57
+ assert _normalize_chrm(" chr1 ") == "1"
58
+
59
+
60
+ def test_coerce_pos():
61
+ assert _coerce_pos(100) == (100, 100)
62
+ assert _coerce_pos((100, 200)) == (100, 200)
63
+ assert _coerce_pos([200, 100]) == (100, 200) # reversed range
64
+ with pytest.raises(ValueError):
65
+ _coerce_pos((1, 2, 3))
66
+
67
+
68
+ def test_build_and_query(fake_db):
69
+ idx = _LocationIndex.build_from_db(fake_db)
70
+ # Point inside KRAS only
71
+ assert idx.query_names("12", 110) == ["KRAS"]
72
+ # Point inside both KRAS and LRMP (LRMP is nested inside KRAS in this fixture)
73
+ assert sorted(idx.query_names("12", 160)) == ["KRAS", "LRMP"]
74
+ # Point outside any gene
75
+ assert idx.query_names("12", 250) == []
76
+ # Range overlapping KRAS+LRMP and FOO
77
+ names = idx.query_names("12", (180, 350))
78
+ assert "KRAS" in names and "FOO" in names
79
+ # Chrom normalization
80
+ assert idx.query_names("chr12", 110) == ["KRAS"]
81
+ # Unknown chrom -> empty
82
+ assert idx.query_names("99", 100) == []
83
+ # Empty gene_name falls back to gene_id
84
+ assert idx.query_names("X", 1500) == ["ENSG_X"]
85
+
86
+
87
+ def test_save_and_load_roundtrip(fake_db, tmp_path):
88
+ idx = _LocationIndex.build_from_db(fake_db)
89
+ out = tmp_path / "gene_locations.npz"
90
+ idx.save(out)
91
+ assert out.exists()
92
+ loaded = _LocationIndex.load(out)
93
+ assert loaded.query_names("12", 110) == ["KRAS"]
94
+ assert sorted(loaded.query_names("12", 160)) == ["KRAS", "LRMP"]
95
+
96
+
97
+ def test_gene_names_at_position_via_organism(fake_db, tmp_path):
98
+ """End-to-end through the module-level helper, using a mocked organism config."""
99
+ # Clear cache so a fresh build runs for this organism key
100
+ from seqmat import locator
101
+ locator._INDEX_CACHE.pop("hg38_test", None)
102
+ with patch("seqmat.locator.get_organism_config") as cfg, \
103
+ patch("seqmat.locator.get_default_organism", return_value="hg38_test"):
104
+ cfg.return_value = {"genes_db": fake_db}
105
+ names = gene_names_at_position("12", 110)
106
+ assert names == ["KRAS"]
107
+ names = gene_names_at_position("chr12", (150, 350))
108
+ assert "KRAS" in names and "FOO" in names
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes