Skip to main content

gapit

Mass screening of contigs and reads for known genes — AMR, virulence, serotype, plasmid replicons, species targets, or any custom database. An agent-first Python reimplementation of abricate: byte-compatible TSV plus first-class JSON and Markdown.

Why gapit

  • Frozen abricate-compatible baseline. Contig screening keeps the same BLAST pipeline, hit rules, and abricate-format TSV as a frozen baseline surface for existing pipelines. From v0.5.0 gapit pursues its own contract; abricate parity is no longer a release gate — the parity harness (pixi run -e parity parity) remains a regression reference for that frozen surface.
  • Machine-readable by design. Versioned output schemas (gapit.report/1, gapit.reads/1, gapit.summary/1), self-describing via gapit schema, typed JSON error envelopes on stderr, documented exit codes. An agent can discover the whole contract without reading docs.
  • Reads, not just contigs. gapit screen --r1/--r2 screens FASTQ through minimap2, and --r1 accepts assembly FASTA directly (content-detected, map-ont forced) for a fast presence survey. abricate cannot screen raw reads.

Install

From PyPI (external BLAST+ and minimap2 binaries required on PATH — see docs/installation.md):

pip install gapit

Or from a git clone with pixi, which manages the environment including the external binaries:

git clone https://github.com/indexofire/gapit.git
cd gapit
pixi install
pixi run gapit --version

The package supports Python 3.11+; the dev environment pins 3.14.

Quick start

# Screen contigs (abricate-compatible TSV on stdout; --db is required)
gapit screen contigs.fa --db ncbi

# Agent- and human-readable outputs
gapit screen contigs.fa --db ncbi --format json
gapit screen contigs.fa --db ncbi --format md

# Two-stage designation: screen writes the gene table, typing designates from it
# (typed gene databases — the bundled ecoli_dec carries the dual-scheme DEC panel)
gapit screen isolates.fa --db ecoli_dec --output dec.tsv
gapit typing dec.tsv

# Screen FASTQ reads; --read-type picks the minimap2 preset
gapit screen --r1 sample_R1.fastq.gz --r2 sample_R2.fastq.gz --read-type sr --db card
gapit screen --r1 ont_reads.fastq.gz --db ncbi --read-type map-ont --format json

# Summarize report tables into a gene presence/absence matrix
gapit summary *.tsv

# Databases: six ship in-wheel and work instantly; the rest download from upstream on fetch
gapit db fetch all         # default set (card, vfdb)
gapit db fetch ncbi
gapit db list
gapit db outdated                # flag databases older than the staleness threshold
gapit db search "tet(M)"         # look up genes across every installed database
gapit db build mydb my_genes.fa --tsv my_meta.tsv   # custom db from any FASTA

# Introspection
gapit schema report     # JSON Schema of gapit.report/1

Contig screening follows abricate defaults (--minid 80, --mincov 80). Reads-mode presence defaults to 90% alignment breadth (--min-breadth 90).

Databases

A database is a directory under the datadir, resolved from $GAPIT_DATADIR, then ~/.local/share/gapit/db (override per call with --datadir). Twenty-two databases are built into the catalog — twelve gene providers, seven kaptive cluster providers, and three typed bundles (ecoli_dec, lm_doumith, and the cluster-kind vp_ok). Every provider builds on gapit db fetch, which downloads from upstream — and six content-provenance-audited ones also ship inside the package (ecoli_dec and lm_doumith plus the ncbi, resfinder, ecoh snapshots — public domain / Apache-2.0 / BSD-3-Clause / MIT — and the MIT typed-cluster snapshot vp_ok), materialized into the datadir on first use with zero network; the bundled ecoli_dec additionally carries per-gene identity floors (floors.json, pic at 90%) that reads mode applies before presence calls. Several upstream licenses (CARD's McMaster terms, VFDB's CC BY-NC, Kaptive's GPL-3.0) forbid redistribution inside an MIT-licensed distribution, so everything else is fetch-on-demand — and db fetch <name> refreshes the provider-backed bundled names (ecoh, ncbi, resfinder) from the latest upstream.

Name Content dbtype
ncbi NCBI AMRFinderPlus curated AMR nucl
card CARD protein homolog resistance models nucl
resfinder CGE ResFinder acquired resistance genes nucl
argannot ARG-ANNOT acquired resistance genes nucl
plasmidfinder CGE PlasmidFinder replicons nucl
megares MEGARes antimicrobial resistance genes nucl
ecoh E. coli O and H antigens (srst2 EcOH) nucl
ecoli_dec Diarrheagenic E. coli marker panel (GB 4789.6 + risk-monitoring designation) nucl
vfdb VFDB virulence factors (set A, nucleotide) nucl
ecoli_vf E. coli virulence factors nucl
lm_doumith Listeria monocytogenes serogrouping (Doumith 2004) nucl
bacmet2 BacMet2 biocide/resistance genes (protein) prot
victors Victors virulence factors nucl
upec_expec_vf UPEC/ExPEC virulence genes nucl
vp_ok V. parahaemolyticus O and K antigen loci (OAgc/CPSgc, vpasero; cluster, MIT, one-scan O:K serotype) nucl

gapit also reads datadirs built by abricate itself (legacy ~~~ headers). The reverse does not hold: gapit-native databases use the gapit/v1 header format (see SPEC.md §11), which abricate cannot read. Protein databases such as bacmet2 screen through blastx.

Gene cluster databases are a second kind: gapit db build NAME loci.gbk|gff3 builds a kind: cluster db (locus calls via minimap2, optional --typing FILE phenotype scoring), and the seven Kaptive cluster databases (kpsc_k, kpsc_o, kosc_k, kosc_o, ab_k, ab_o, ecoli_kps) fetch the Kaptive antigen-locus references at install time (GPL-3.0 content, so nothing is bundled — cite Kaptive/Wyres et al. 2020 for results). The typed cluster bundle vp_ok merges the vpasero OAgc + CPSgc references (MIT) into one bundled db — a pure built-in in the ecoli_dec/lm_doumith pattern, no db fetch — where a single gapit screen --db vp_ok renders gapit.cluster/2 with o_group, k_group, and the composed serotype O:K call (RIMD 2210633 → O3:K6), working straight after pip install gapit with zero network. gapit db list --json surfaces each provider's content license where one is pinned.

Output contract

  • stdout purity. Data on stdout, diagnostics on stderr, always. --quiet silences stderr only.
  • Deterministic. Stable sort orders, fixed tool parameters, no wall-clock timestamps inside data payloads.
  • Errors print a JSON envelope to stderr and exit nonzero:
{"schema": "gapit.error/1", "code": "...", "message": "...", "context": {...}}
Exit code Meaning
0 success
1 unexpected error
2 usage error
3 missing dependency
4 database error
5 input error

MCP server

gapit ships an MCP (Model Context Protocol) stdio server so agent runtimes can screen assemblies without parsing CLI output: gapit mcp or the gapit-mcp console script speaks newline-delimited JSON-RPC 2.0 on stdin/stdout (no extra dependencies — the protocol is hand-rolled). It exposes nine tools: screen (gapit.report/1 by default; aligner minimap2 for a fast assembly survey), screen_reads (FASTQ via minimap2, gapit.reads/1), summary (gapit.summary/1), schema, db_list, plus the database tools db_fetch, db_build, db_search, and db_outdated so an agent can self-provision and inspect databases mid-session. Tool failures return isError: true with the gapit.error/1 envelope as text. Register it with an MCP client:

{"mcpServers": {"gapit": {"command": "gapit-mcp"}}}

Development

Task Runs
pixi run lint ruff check
pixi run fmt ruff format
pixi run typecheck basedpyright (strict)
pixi run test pytest, 1024 offline tests
pixi run -e parity parity byte-diff screening vs real abricate
pixi run -e parity summary-parity byte-diff summary vs real abricate

User documentation lives in docs/index.md, rendered at https://indexofire.github.io/gapit/.

SPEC.md is the parity contract, PLAN.md the roadmap, AGENTS.md the contributor guide, CHANGELOG.md the change history.

License

gapit is MIT-licensed. It is a behavioral reimplementation of abricate (GPL-2.0) and copies no Perl code; abricate itself remains GPL-2.0. The only database content inside the package is the six audited, permissively licensed bundles under src/gapit/data/dbs/ (public domain / Apache-2.0 / BSD-3-Clause / MIT); every other provider downloads from upstream at fetch time, under its own license (SPEC.md §9).

Metadata

Release files for gapit 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gapit 0.5.6
File Size Uploaded Provenance
gapit-0.5.6.tar.gz 4.9 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gapit 0.5.6
File Interpreter ABI Platform
gapit-0.5.6-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 MB

Release files / gapit-0.5.6.tar.gz

Download URL gapit-0.5.6.tar.gz
Size 4.9 MB
Tags Source
SHA-256 checksum
How to use checksums
d62a5dc19e9efefff7f8973d987113442bd5d23e3d8a25d437a0ea18eb7270dd
BLAKE2b-256 checksum
How to use checksums
6e9a47c0e2a44f32bb3c25013e35b3910629e8f3ef8462fffcb7457a13da5583
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 20, 2026.

Transparency log

Release files / gapit-0.5.6-py3-none-any.whl

Download URL gapit-0.5.6-py3-none-any.whl
Size 3.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0c1e63e0fa61687a86f3bc75901a863407aa2cdf9af08833147557a89a10e412
BLAKE2b-256 checksum
How to use checksums
0ffd9d347832425b09706622d2cf959e58b7878b67aee5cb77c6e8a1507518e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 20, 2026.

Transparency log

Security for gapit 0.5.6

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.

Select from 2 files

Attestation for gapit-0.5.6.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 20, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page