gseek
English | 简体中文
gseek is a zero-runtime-dependency Python library that puts a stable,
reproducible interface around DNA alignment and distance tools. It normalizes
requests and results for BLAST+, minimap2, MUMmer4, KMA, BWA, mash, sourmash,
and skani, with content-addressed indexes and replayable run manifests.
It is the shared alignment layer for gside, gapit, and gmlst. Adapters only plan commands and normalize output; biological interpretation stays in the consumer.
consumer (gside / gapit / gmlst)
│
▼
gseek.api: align / distance / backends
│
▼
runner: probe → index → plan → execute → parse → manifest
│
▼
adapters: blast · minimap2 · mummer · kma · bwa · mash · sourmash · skani
Why gseek
Bioinformatics tools solve similar problems with incompatible conventions:
| Concern | Typical consumer code | gseek |
|---|---|---|
| BLAST columns | different outfmt per project |
one AlignmentRecord |
| Coordinates | 1-based inclusive or 0-based half-open | 0-based half-open + strand |
| Identity / coverage | tool-specific formulas | normalized values + source |
| Index reuse | mtime / file existence | content-addressed keys + locks |
| Reproducibility | partial version logging | gseek.run/1 manifest + replay |
The library does not decide whether a hit is "good"; it preserves the evidence and lets the consumer apply thresholds and business rules.
Status
0.10.0; Python >=3.12; runtime dependencies: none.
| Backend | Input | Operations | Index |
|---|---|---|---|
blast |
FASTA (DNA/protein tasks) | alignment | target |
minimap2 |
FASTA / FASTQ / paired | alignment | target |
kma |
FASTA / FASTQ / paired | alignment | target |
mummer |
FASTA | alignment (MUMmer 4) | none |
bwa |
FASTA / FASTQ / paired | alignment | target |
mash |
FASTA / FASTQ | distance / screen | sketch |
sourmash |
FASTA / FASTQ | distance / search / gather | sketch |
skani |
FASTA | ANI distance | sketch |
External tools are installed separately (conda, Bioconda, pixi, or system
packages); gseek discovers them at runtime and reports actionable errors when
one is missing or too old.
Installation
pip install gseek==0.10.0
From source:
pip install -e ".[dev]"
pixi install
External tools:
pixi add blast minimap2 mummer4 kma bwa mash sourmash skani
# or
conda install -c bioconda blast minimap2 mummer4 kma bwa mash sourmash skani
The package itself has no third-party runtime dependencies.
Python quickstart
from pathlib import Path
import gseek
result = gseek.align(
backend="minimap2",
query=Path("sample.fna"),
target=[Path("scheme/alleles.fna")],
preset="asm5",
threads=8,
index="auto",
manifest=Path("runs/sample.manifest.json"),
)
print(result.stats.record_count)
for hit in result.records:
print(hit.query_id, hit.target_id, hit.identity, hit.target_coverage)
best = result.best_per_query_target()
Inspect capabilities and tools:
gseek.backends()
gseek.get_backend("blast").probe()
gseek.align(...)
gseek.distance(...)
gseek.replay(Path("run.manifest.json"), check=True)
gseek.verify(Path("run.manifest.json"))
Distance and ANI
result = gseek.distance(
backend="mash",
query=Path("assembly.fna"),
reference=Path("refs.msh"),
external_reference=True,
params={"max_distance": 1.0},
manifest=Path("runs/mash.manifest.json"),
)
distance supports mash, sourmash, and skani. external_reference=True means
the reference is already a sketch/database rather than FASTA to be indexed.
Result model
gseek.align() returns an AlignmentResult containing normalized
AlignmentRecords, the index/tool references used, and optional manifest data.
Key provenance fields:
query_id,target_idquery_start/query_end,target_start/target_end(0-based half-open)strandidentity,aligned_length,matches,gap_count,gap_openingstarget_coverage,query_coverageevalue,bit_score,mapq,depthtagsfor tool-specific values (NM,cs, …)
AlignmentResult also provides explicit views such as
best_per_query_target(), summarize_by_target(), and
iter_records(). Views never discard the original records.
gseek.distance() returns a DistanceResult; distance records keep the query,
reference, distance, and p-value/ANI fields appropriate to the backend.
CLI
The CLI is a thin wrapper over the public API: argv parsing, JSON output, and exit-code mapping. It never executes a shell string.
gseek doctor
gseek backends --json
gseek align \
--backend minimap2 \
--query sample.fna \
--target scheme/alleles.fna \
--preset asm5 \
--threads 8 \
--manifest runs/sample.manifest.json \
-o runs/sample.json
gseek verify runs/sample.manifest.json
gseek replay runs/sample.manifest.json --check --json
Results go to stdout (or -o), errors to stderr as gseek.error/1 JSON by
default. Use --error-format text for humans. Exit codes:
| Code | Meaning |
|---|---|
0 |
success |
2 |
usage/configuration error |
3 |
missing or unsupported tool |
4 |
execution/index/manifest error |
5 |
input/parse error |
6 |
replay hash mismatch |
Reproducibility
- Indexes are content-addressed: adapter version, semantic parameters, target content hash, and tool version all participate in the key.
gseek.run/1manifests record inputs, tool versions, planned commands, and a canonical recipe/result hash.gseek verifychecks recorded files and hashes.gseek replayre-plans from the manifest and can compare the newresult_hash; it does not re-execute arbitrary argv stored in JSON.
Consumer compatibility
gseek.compat centralizes the legacy | gseek | shadow switch used by
consumers:
from gseek.compat import Engine
switch = Engine.from_env("GSIDE_ENGINE")
result = switch.run(legacy_call, gseek_call, compare=compare)
legacy(default): only the consumer's existing implementation.gseek: only the gseek path; failures propagate.shadow: run both, compare/log, and return the legacy result.
The consumer keeps its own business rules and legacy code; gseek.compat
only owns mode parsing, shadow execution, and fallback.
Documentation
- Documentation site
- Documentation index
- Tutorial
- Quickstart
- CLI reference
- Error model
- API reference
- 中文 README
- 中文文档
Development documents:
- Development plan
- Adapter matrix
- Compatibility and migration
- Testing and contribution rules
- Changelog
Development
The project enforces test-first development.
pixi install
pixi run test # unit and contract tests
pixi run test-cov # coverage gate
pixi run lint # ruff check + format --check
pixi run typecheck # pyright
pixi run check # lint + typecheck + test
Integration tests need the external tools and are skipped when a binary is absent. The test suite currently passes 350 tests (36 skipped integration cases without optional tools) and covers adapter planning/parsing, execution, indexing, manifests, replay, and consumer parity.
Design principles
- Adapters are pure planners/parsers; only
execution.pystarts processes. - No information loss: merging is an explicit view.
- Coordinates are 0-based half-open; strand is a separate field.
- Identity/coverage carry their source and formula.
- Indexes are content-addressed; no mtime decisions.
- Deterministic defaults: stable ordering, absolute paths,
LC_ALL=C, no shell. - Zero runtime dependencies; typed errors with stable codes.
- Docs and schemas are contracts and evolve with the code.
License
MIT. See LICENSE.
Metadata
Release files for gseek 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gseek-0.10.0.tar.gz | 222.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gseek-0.10.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 328.1 kB
Release files / gseek-0.10.0.tar.gz
| Download URL | gseek-0.10.0.tar.gz |
|---|---|
| Size | 222.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
493c963a7517c38941efb24d1daf2b1c897d0639d5e07b061291a7524fb9d93d
|
|
BLAKE2b-256 checksum How to use checksums |
05261d6846ee9588563ea37b25fc8e5699bfa00d4a711ea127fbbebf1b592d6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logRelease files / gseek-0.10.0-py3-none-any.whl
| Download URL | gseek-0.10.0-py3-none-any.whl |
|---|---|
| Size | 105.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43de6da346073fb6366ee577a4554c775b51098370b5aa36f469c89cb99f6a05
|
|
BLAKE2b-256 checksum How to use checksums |
15a6622c5bdb049fafcda85b3638b7564a4d2135f0a23961e88bce7c20e7e46f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logSecurity for gseek 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for gseek-0.10.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.