gseek engine migration
gside routes its marker BLAST/FASTQ screening, mash distance, sourmash
gather, and panel/skani lookup through
gseek. gseek is a runtime dependency
and the default engine; legacy and shadow remain selectable for debugging.
Switch
GSIDE_ENGINE=gseek # default: route all migrated paths through gseek
GSIDE_ENGINE=legacy # debug: existing subprocess backends
GSIDE_ENGINE=shadow # debug: run both, log differences, return legacy
GSIDE_ENGINE is read per call, so a process can be tested with either mode
without restarting. Invalid values fail before any tool runs. The selector,
shadow comparison, and fallback are provided by gseek.compat.Engine; legacy
mode still avoids importing gseek entirely.
Legacy and shadow are debug modes
The gseek path is the production default. The dual-path design is retained on purpose:
legacyruns the original subprocess implementation for debugging and side-by-side comparisons;- every migrated path keeps its legacy implementation and remains usable;
shadowruns both implementations, logs coarse differences, and returns the legacy result;- legacy is the reference for parity tests;
- modes without a gseek adapter (
gtdbtk) do not use the switch.
gseek is installed with the package; for local development:
pixi install -e dev
# or: pip install -e ".[dev]"
# or, without installing a release:
PYTHONPATH=../gseek/src pixi run -e dev pytest tests/integration/test_gseek_parity.py -q
The mash/sourmash paths require gseek 0.10.0 (
external_reference). The runtime dependency floor is 0.10.4 (index-cache security hardening), published on PyPI:pip install gseek==0.10.4. Development/test environments install it through the package dependencies (or the pixi environment); the sibling checkout remains useful for working on gseek itself.
Migrated paths
| Path | Legacy | gseek |
|---|---|---|
| Marker BLAST | BlastBackend + markers_blastdb |
gseek.align(backend="blast", target=markers.fasta) |
| FASTQ marker screening | minimap2 PAF + local aggregation | gseek.align(backend="minimap2", ...) + same aggregation |
| mash_refseq (assembly/reads) | MashBackend against mash.msh |
gseek.distance(backend="mash", external_reference=True) |
| sourmash gather | sketch/gather CSV parsing | gseek.distance(backend="sourmash", external_reference=True), one run per query file |
| panel (skani) | SkaniBackend + panel.sketch DB |
gseek.distance(backend="skani", external_reference=True) against the pre-built DB directory |
The gseek path deliberately preserves gside semantics:
- coverage is still
aligned_length / length(not gseek span coverage); - screening identity is still
nmatch / alen, viarecord.matches; - BLAST uses
task="megablast",word_size=11, and dust on to match the historicalblastndefaults; - tool discovery uses the same
GSIDE_PIXI_BIN/pixi/PATH order.
Not routed through gseek
All gseek-backed gside modes are migrated (marker, mash, sourmash, panel).
Modes without a gseek adapter (gtdbtk) remain on their
existing implementations.
Verification
tests/unit/test_gseek_bridge_units.py: record mapping, aggregation, mode dispatch, and fake-gseek parameter wiring.tests/integration/test_gseek_parity.py: real marker DB/genome comparison against the legacy path, plus FASTQ screening parity. Skipped when gseek is not importable.
The same gates apply on main (ruff, pyright, pytest tests/unit --cov ...,
plus integration). The parity test is collected by the default test suite;
cases that need external binaries skip when those binaries are absent.
Local verification (2026-10-24)
gside scan -m marker -f json was run against the tracked N16961 genome and a
synthetic FASTQ generated from the inva marker:
| Input | legacy | gseek | shadow |
|---|---|---|---|
GCF_000006745.1 assembly |
Vibrio_cholerae / high / ompw 94.767 / 100.1 |
identical | identical |
21 reads covering inva |
Salmonella_enterica / high / inva 100.0 / 98.3 |
identical | identical |
K12 assembly, -m mash_refseq |
Escherichia_coli / high / identity 1.0 |
identical | identical |
shadow produced no difference warnings. Unit suite: 748 passed; integration: 28 passed, 1 skipped
(with gseek installed; 6 are parity, 22 without gseek); coverage 96.88%.
Real-data spot check (~/temps/test, 2026-10-24)
Inputs: one RefSeq genome from each of Acinetobacter baumannii,
Campylobacter coli, Escherichia coli, Salmonella enterica, and
Shigella flexneri. Each was run with
gside scan <genome> -m marker+mash_refseq -f json under all three engines.
- legacy, gseek, and shadow JSON were byte-identical for all five genomes.
- Example calls remained identical:
A. baumanniimarkerrpob-aba99.068 /oxa5197.39, mash 0.978914;S. flexnerimarkeripah100.0, mash 0.993922. - A 260,000-read (150 bp, ~10x) FASTQ from A. baumannii produced identical
marker (
Acinetobacter_baumannii, high,rpob-aba94.84 /oxa5193.56) and mash (0.9789136, high) results in all three modes. - panel (skani) on A. baumannii and C. coli: legacy/gseek/shadow JSON were byte-identical (A. baumannii 98.06 ANI / 85.79 AF; C. coli 99.72 / 98.09).
- A mini sourmash signature DB built from three RefSeq genomes produced
identical
species,confidence,f_unique_weighted,ani, andgather_partitionfor A. baumannii and S. enterica in all three modes. - Full gside GTDB zip (3.7 GB) on A. baumannii: legacy and gseek JSON are
byte-identical (
species=Acinetobacter_baumannii, high,f_unique_weighted=0.5978601252609603,ani=98.3, same two-member partition). gseek explicitly passesthreshold_bp=50000to match the legacy sourmash CLI default; the initial 50 bp default admitted extra low-weight partitions. - The benchmark's rocksdb directory (
gtdb-k31.rocksdb) is accepted by gseek 0.10.0 as an external reference and hashed as a deterministic tree. legacy, gseek, and shadow all returned the same full partition (Acinetobacter_baumannii, high,0.5978601252609603, ANI 98.3); shadow produced no difference warning.
Full-dataset benchmark (~/temps/test)
The actual dataset has 42 labels and 4,178 genomes (the directory includes
the Shigella genus label). Every genome was run through legacy and gseek for
all four gseek-backed modes, using 8 worker processes:
| Mode | Runs | Exact same | Errors | Legacy median | gseek median | Speed ratio (median) |
|---|---|---|---|---|---|---|
| marker | 4,178 | 4,178 | 0 | 0.4381s | 0.4480s | 0.978x |
| panel | 4,178 | 4,178 | 0 | 0.0660s | 0.0748s | 0.882x |
| mash_refseq | 4,178 | 4,178 | 0 | 0.5183s | 0.7013s | 0.739x |
| sourmash | 4,178 | 4,178 | 0 | 1.6415s | 1.6452s | 0.998x |
Total measured time: legacy 11,309s, gseek 12,183s (gseek ≈ 1.08x slower under the parallel benchmark). The 0.6.0 run reuses ToolResolver probes, caches reference digests per process, skips manifest/result hashing when not needed, and uses mash's direct FASTA query path. The benchmark is wall-clock under 8-way load, not an isolated single-core comparison.
Raw rows and the generated report:
~/temps/test/results/gseek-full-benchmark-v4/.