Skip to content

Databases

A gspec database is a directory of reference genes you screen contigs and reads against. This page covers where databases live, how to get them, what gspec writes on disk, and how to bring your own. For the full datadir layout, sharing, conda/Docker guidance, and the database anatomy, see Data directory. For how screening uses them, see screen.md.

Database naming

New database names describe the organism with a short code followed by a content suffix:

Scope Rule Examples
Species genus initial + first two species letters cje_cps (C. jejuni capsule), eco_vf (E. coli virulence), vch_oagc (V. cholerae O-antigen), vpa_ok (V. parahaemolyticus O:K)
Genus first three genus letters shi_serotype (Shigella), cam_cps (Campylobacter genus-level capsule)

Use lowercase ASCII, underscores, and a content suffix (_cps, _vf, _serogroup, _ok, _dec). The former ecoli_dec bundle is now eco_dec under this convention. Existing published names (cam, ecoh, lmo_sero, vpa_ok, ...) are legacy identifiers: they stay stable for compatibility and are not renamed by this convention.

Where databases live

Every database sits in a datadir, one subdirectory per database. gspec resolves the datadir in this order:

  1. --datadir on the individual call
  2. $GSPEC_DATADIR
  3. $XDG_DATA_HOME/gspec/db (absolute XDG_DATA_HOME only)
  4. ~/.local/share/gspec/db

The location is resolved even before it exists. gspec db list and gspec db setup bootstrap the missing root automatically (so a fresh pip install gspec can be inspected and set up immediately); db fetch/db build create it as part of their write path. Commands that consume installed databases require it — except that screen/typing against a bundled name materialize that bundle and create the root on first use. A missing root on a strict read path is a typed error and exit 4:

$ gspec db outdated --datadir /no/such/dir
{"schema":"gspec.error/1","code":"DATADIR_NOT_FOUND","message":"datadir does not exist: /no/such/dir","context":{"datadir":"/no/such/dir"}}

To keep databases inside an activated conda environment instead of your home directory, opt in explicitly (recommended only when you need env-local data — the home default survives environment rebuilds and is shared by every env):

export GSPEC_DATADIR="${CONDA_PREFIX}/db/gspec"

Listing what's installed

gspec db list shows every known database and whether it is installed:

$ gspec db list
NAME    DESCRIPTION STATUS  DBTYPE  KIND    TYPING  PROVIDER
ab_k    A. baumannii K locus (Kaptive)  available   nucl    cluster -   Kaptive (Kenyon lab)
ab_o    A. baumannii OC locus — official keyword ab_o (Kaptive) available   nucl    cluster -   Kaptive (Kenyon lab)
argannot    ARG-ANNOT acquired resistance genes available   nucl    gene    -   IHU Méditerranée-Infection
bacmet2 BacMet2 experimentally confirmed biocide/resistance genes (protein) available   prot    gene    -   University of Gothenburg
card    CARD protein homolog resistance models  available   nucl    gene    -   McMaster University
cje_cps Campylobacter jejuni Penner capsule (CPS) multiplex PCR panel   bundled nucl    gene    command gspec-curated (Poly 2015; CC0 + NCBI public domain)
cje_cpsv2   C. jejuni Penner typing - 31 full CPS locus categories (CjejuniTyper)   bundled nucl    gene    command CjejuniTyper 2026 (CC BY 4.0)
ecoh    E. coli O and H antigens (srst2 EcOH)   available   nucl    gene    -   Holt lab (srst2)
eco_dec Diarrheagenic E. coli marker panel (GB 4789.6 + risk-monitoring designation)    bundled nucl    gene    command gspec-curated (public-domain sources)
ecoli_kps   E. coli group 2+3 capsular polysaccharide loci (Kaptive)    available   nucl    cluster -   Kaptive (Gladstone lab)
ecoli_vf    E. coli virulence factors (phac-nml)    available   nucl    gene    -   PHAC-NML
kosc_k  K. oxytoca species complex K locus (Kaptive)    available   nucl    cluster -   Kaptive (klebgenomics)
kosc_o  K. oxytoca species complex O locus (Kaptive)    available   nucl    cluster -   Kaptive (klebgenomics)
kpsc_k  K. pneumoniae species complex K locus (Kaptive) available   nucl    cluster -   Kaptive (klebgenomics)
kpsc_o  K. pneumoniae species complex O locus (Kaptive) available   nucl    cluster -   Kaptive (klebgenomics)
lmo_sero    Listeria monocytogenes serogrouping (Doumith 2004)  bundled nucl    gene    command gspec-curated (public-domain INSDC sources)
megares MEGARes antimicrobial resistance genes  available   nucl    gene    -   MEG Lab
ncbi    NCBI AMRFinderPlus (reference finder) curated AMR   available   nucl    gene    -   NCBI
nme_sero    Neisseria meningitidis serogroup + ctrA + sodC control (non-MLST)   available   nucl    gene    command MDU-PHL
plasmidfinder   CGE PlasmidFinder replicons available   nucl    gene    -   DTU CGE
resfinder   CGE ResFinder acquired resistance genes available   nucl    gene    -   DTU CGE
upec_expec_vf   UPEC/ExPEC virulence genes (FordeGenomics)  available   nucl    gene    -   FordeGenomics
vch_oagc    Vibrio cholerae O-antigen gene clusters (OAGC; 190 OL loci) + ompW species control  bundled nucl    cluster integrated  gspec(Hangzhou CDC)
vfdb    VFDB virulence factors (set A, nucleotide)  available   nucl    gene    -   USTC (VFDB)
victors Victors virulence factors   available   nucl    gene    -   University of Chicago
vpa_ok  V. parahaemolyticus O and K antigen loci (OAgc/CPSgc, vpasero)  bundled nucl    cluster integrated  gspec-curated (vpasero)
vpa_vf  V. parahaemolyticus haemolysin panel: tlh species marker + tdh/trh virulence markers    bundled nucl    gene    -   gspec-curated (INSDC)

Rows are sorted globally by NAME, so the TSV and JSON listings can be consumed without a second sort. NAME is the database name you pass to --db; PROVIDER names the upstream maintainer organisation.

For shell loops, gspec db list -n prints one space-separated line of names (no header, no fields):

$ gspec db list -n
ab_k ab_o argannot ... vpa_ok vpa_vf
$ for name in $(gspec db list -n); do gspec db setup -d "$name"; done

The loop is the explicit "acquire and index everything" pattern: a named provider is fetched when missing, a named bundled database is materialized, and installed databases are reindexed. For a repair-only pass that never fetches, use gspec db setup --all. Every row is a screening database (gspec screen); KIND distinguishes gene from cluster databases, and TYPING says how the optional designation works, if the database carries a typing.json:

  • command — a gene database: screen to a table, then run gspec typing RESULT.tsv.
  • integrated — a cluster database: the phenotype is evaluated by gspec screen itself. gspec typing can reformat cluster JSON (cluster/2 or locus_map/1) but does not re-evaluate it; cluster TSV is not re-typable.
  • - — no typing scheme; screen-only.

STATUS reads installed (N) when <datadir>/<name>/gspec-manifest.json exists, with N the record count, otherwise available. The twenty wheel-shipped bundled databases (cam_vf through vpa_vf; gspec db list prints the current set) are gspec-curated, with no provider and no fetch path: they read bundled before materialization and installed (N) after. Every provider, including ecoh, ncbi, and resfinder, is fetch-on-demand and reads available until gspec db fetch -d <name> installs it. Databases installed into the datadir outside the catalog also appear, after the bundled section and sorted by name: db build products (gene and cluster kinds alike) and manifest-less directories (abricate-style or db install bytes) render with PROVIDER local, the record count from the manifest — or counted from the FASTA when no manifest exists — and DBTYPE from the manifest, the BLAST index suffix, or abricate's letter heuristic, in that order. On an interactive terminal the same rows render as a styled rich table; piped or redirected output always stays the plain TSV above. For agents, --json emits a gspec.dblist/1 document (first three entries shown, output trimmed):

$ gspec db list --json
{
  "schema": "gspec.dblist/1",
  "providers": [
    {
      "name": "argannot",
      "vendor": "IHU Méditerranée-Infection",
      "description": "ARG-ANNOT acquired resistance genes",
      "dbtype": "nucl",
      "installed": true,
      "kind": "gene",
      "typing": false,
      "records": 2224
    },
    {
      "name": "bacmet2",
      "vendor": "University of Gothenburg",
      "description": "BacMet2 experimentally confirmed biocide/resistance genes (protein)",
      "dbtype": "prot",
      "installed": true,
      "kind": "gene",
      "typing": false,
      "records": 746
    },
    {
      "name": "card",
      "vendor": "McMaster University",
      "description": "CARD protein homolog resistance models",
      "dbtype": "nucl",
      "installed": true,
      "kind": "gene",
      "typing": false,
      "records": 6059
    }
  ]
}
Field Type Meaning
schema string Always gspec.dblist/1
providers array One entry per known database
providers[].name string Database name, as passed to --db / gspec db fetch
providers[].vendor string Upstream maintainer organisation (NCBI, DTU CGE, Kaptive (klebgenomics), ...)
providers[].description string Short content summary
providers[].dbtype string nucl (screened with blastn) or prot (screened with blastx)
providers[].kind string gene (per-gene BLAST screening) or cluster (minimap2 locus screening, screen.md)
providers[].typing boolean True when the database carries a typing.json; gene databases designate via gspec typing, cluster databases inside gspec screen
providers[].installed boolean True when a manifest and readable sequences exist in the datadir
providers[].indexed boolean True when a BLAST index (.nin or .pin) exists; db setup rebuilds the indices
providers[].records integer Record count, omitted when the database isn't installed
providers[].license string Upstream content license, omitted unless the provider or bundled snapshot pins one (card, vfdb, ecoli_vf, kaptive, bundled content)
providers[].source string local for a datadir-discovered database outside the catalog (db build / db install), bundled for a wheel-shipped database (see below); absent for registry entries

gspec db list is the single listing surface: the database catalog above, with --json returning the gspec.dblist/1 document. (The former standalone listing command and its schema were removed; abricate --list byte-parity is intentionally dropped for this surface.) See outputs.md.

Inspecting one database

gspec db list answers "which databases exist, and are they installed"; gspec db info -d NAME answers "what is this database, where does its content come from, how is it meant to be used, and where does it mislead". It is a pure read over four existing sources — the provider catalog, the wheel's bundled.json, the installed manifest, and an optional info.json sidecar in the database directory — so nothing has to be re-declared.

On a terminal it prints a man-style page (plain text, no colour, wrapped to the terminal width; less can page it):

$ gspec db info -d cje_cps | head -20
CJE_CPS(1)                   gspec database manual                    CJE_CPS(1)

NAME
       cje_cps — Campylobacter jejuni Penner capsule (CPS) multiplex PCR panel

SYNOPSIS
       $ gspec screen -d cje_cps [FILE]... -o RESULT.tsv
       $ gspec typing RESULT.tsv
       $ gspec db info -d cje_cps

DESCRIPTION
       36 CPS amplicon targets + lpxA control; extracted from the GenBank
       accessions listed in Poly et al. 2015, PLoS ONE 10(12):e0144349 (Table
       3). The cje_cps typing asset follows the paper's Table 4 patterns, with
       HS4/HS16/HS64 complex rules and actual amplicon-presence floors; see
       docs/databases.md.

STATUS
       installed · 37 records · gene database · nucl

The sections are NAME, SYNOPSIS, DESCRIPTION, STATUS, PROVENANCE (vendor, licence, snapshot, typing schema, build provenance, source URLs, location), REFERENCES (numbered, with doi:/url: and the reason each source matters), CAVEATS (bulleted interpretation limits), USAGE (the commands that constitute the intended workflow, never wrapped mid-flag), and SEE ALSO. Sections a database has nothing to say in are omitted rather than printed empty, so an uninstalled catalog provider shows no PROVENANCE build rows and no REFERENCES.

Piped output stays machine-readable. When stdout is not a terminal — or when --tsv is passed — the same facts render as a stable two-column FIELD<TAB>VALUE stream: list-valued fields (REFERENCE, CAVEAT, USAGE, SOURCE_URL) repeat their key, and a reference's REFERENCE_DOI/REFERENCE_URL/REFERENCE_NOTE rows follow its own REFERENCE row.

$ gspec db info -d cje_cps --tsv | head -4
NAME    cje_cps
DESCRIPTION Campylobacter jejuni Penner capsule (CPS) multiplex PCR panel
VENDOR  gspec-curated (Poly 2015; CC0 + NCBI public domain)
KIND    gene

--json emits the gspec.dbinfo/1 document (gspec schema dbinfo) for agents:

$ gspec db info -d vpa_ok --json | head -1
{"schema":"gspec.dbinfo/1","name":"vpa_ok","description":"V. parahaemolyticus O and K ...

STATUS mirrors db list — installed, bundled (ships in the wheel, materializes on first use), or available (fetch-time download). An unknown name is exit 4 DATABASE_NOT_FOUND; a broken sidecar is exit 4 DBINFO_MALFORMED.

Every catalog database is documented. The db info page is not limited to the bundled panels: each of the twenty-one providers declares its own literature reference and interpretation caveats in its provider module, and the bundled panels carry theirs in bundled.json, so gspec db info -d card, -d resfinder, -d kpsc_k and friends all answer with a citation and the limits you must respect (CARD model cutoffs vs gspec's 80/80 screen, ResFinder's acquired-gene-only scope, Kaptive's locus-vs-serotype distinction, VFDB's CC BY-NC terms). tests/test_db_info.py enforces the gate: a database added without at least one reference, one caveat, and a usage recipe fails CI.

Bringing your own literature. A db build product can carry its own <datadir>/<NAME>/info.json with optional description/vendor plus the three guidance lists:

{
  "description": "In-house AMR panel",
  "vendor": "gspec(Hangzhou CDC)",
  "references": [{"citation": "Smith 2026, in-house panel (unpublished)"}],
  "caveats": ["unpublished markers: confirm before reporting"],
  "usage": ["gspec screen x.fa --db labgenes"]
}

The optional description and vendor fields feed db list and db info, so a curated local database is not an anonymous local row. The sidecar wins over a bundled panel's declared guidance, so a datadir copy can tighten or replace the wheel's notes without rebuilding anything.

Bundled databases (install-time ready)

Most databases download from upstream at db fetch time because their licenses forbid redistribution (see Providers). A small set of bundled databases ships inside the gspec wheel instead — twenty gspec-curated databases whose content provenance was audited record-by-record (public-domain sources, the MIT vpa_ok panel, the MIT indexofire/enterotoxin conversion behind sau_ent, and the CC BY 4.0 cje_cpsv2 conversion with attribution). The policy is stricter than "the license permits it": third-party provider snapshots (ncbi, card, ecoh, resfinder, ...) never ride the wheel, because their redistribution terms and provenance carry risk that the MIT package should not shoulder. Nothing to download, nothing to accept: a bundled database works out of the box.

Name Content Snapshot Typed
cam_vf C. jejuni virulence panel: T4SS virB4/8/9/10/11, CDT (cdtA/B/C), CiaB, GGT, T6SS Hcp and LOS-modification markers (16 records, INSDC) 2026-11-13 - (screen-only)
cdi_vf C. difficile toxin panel: PaLoc TcdA/TcdB + binary toxin CDT subunits (4 records, INSDC) 2026-11-13 - (screen-only)
cje_cps C. jejuni Penner capsule multiplex PCR panel (37 records: 36 CPS amplicons + lpxA control) 2026-10-27 gspec.typing/2 (scheme penner_cps)
cje_cpsv2 C. jejuni Penner typing, 31 full CPS locus categories (CjejuniTyper conversion, CC BY 4.0; the landed production panel after a 10-database evaluation) 2026-11-14 gspec.typing/2 (scheme penner_cps_v2)
eco_dec Diarrheagenic E. coli marker panel (16 records, GB 4789.6 + risk-monitoring designation) 2026-10-02 gspec.typing/2 (schemes gb4789_6, risk_monitoring)
lmo_sero Listeria monocytogenes serogrouping (5 records, Doumith 2004 markers) 2026-10-03 gspec.typing/2 (scheme doumith_serogroup)
shi_sero Shigella molecular serotype marker panel (95 ShigaTyper public-domain markers, ipaH_c split into two control fragments; first conservative rules) 2026-11-02 gspec.serotype/1 (ShigaTyper marker rules)
vch_vf V. cholerae CTX core/RS2 genes + ctxB classical/El Tor + tcpA classical/El Tor/O139 markers (13 records) 2026-11-02 - (screen-only)
vpa_pai V. parahaemolyticus VPaI-1..VPaI-10 pathogenicity islands (10 loci, cluster kind; RIMD 2210633 + AQ3810) 2026-11-02 - (screen-only)
vch_oagc V. cholerae O-antigen gene clusters (190 OL loci + ompW control; cluster kind; Murase 2022 PRJDB8600) 2026-11-06 gspec.typing/2 (schemes o_group, species)
vpa_ok V. parahaemolyticus O and K antigen loci (195 loci, vpautils OAgc+CPSgc; cluster kind) 2026-10-12 gspec.typing/2 (schemes o_group, k_group, serotype)
lpn_sero L. pneumophila serogroup 1-15 LPS loci (16 loci, Nakaue 2021; cluster kind) 2026-11-06 gspec.typing/2 (scheme lps_serogroup)
lpn_vf L. pneumophila virulence-factor proteins (275, LegionProfiler; protein kind) 2026-11-06 - (screen-only)
str_lancefield Streptococcus Lancefield A/B/C/G markers + tuf control (29 records) 2026-11-06 gspec.typing/2 (scheme lancefield)
sag_sero GBS capsular serotyping, 10 serotypes + III subtypes (14 records, GBS-SBG) 2026-11-06 gspec.typing/2 (schemes serotype, serotype_iii)
sau_ent S. aureus enterotoxin panel: SEA-SEE, SEG-SEY, SEl26-28, SEl30-33, SElV/X/Z, SE02, SEU, SEO, SElU2, TSST-1 + nuc species control + SEC/SEI/SEN/SEU/TSST-1 variant alleles (41 records; MIT conversion of indexofire/enterotoxin + curated INSDC additions incl. the audited sel26/27/28 and SElU2/SElW nomenclature) 2026-11-17 - (screen-only)
pau_sero P. aeruginosa OSA serogroups O1-O17 + wzyB (14 loci, pasty; cluster kind) 2026-11-06 gspec.typing/2 (schemes osa_serogroup, wzyb)
sen_sero S. enterica subsp. enterica O/H antigen panel (13 curated INSDC CDS markers: invA control, O-group rfb markers, phase-1/phase-2 flagellin alleles) 2026-11-09 gspec.serotype/1
sen_sero S. enterica SISTR O/H antigen alleles + formula table (1443 records; g,m/g,q cross-label folded into the similarity groups 2026-11-16) 2026-11-16 gspec.serotype/2
vpa_vf V. parahaemolyticus haemolysin markers: tlh species control + tdh + trh TRH1/TRH2 alleles (4 records, INSDC) 2026-11-13 - (screen-only)

License provenance. Every eco_dec record was re-sourced from primary public-domain submissions (NCBI RefSeq/GenBank/DDBJ accessions, same alleles as the rightsholder panel); two VFDB-derived records found in the original panel were removed and replaced during the 2026-10 audit, and the byte-identical estA4 (J03311.1) copy of estA3 (M18346.1) — one sth gene, one sequence — was dropped by the build pipeline's exact-duplicate dedup in the 2026-10 rebuild, leaving 16 records. The lmo_sero panel was extracted the same way from public-domain INSDC records (accessions in each header; reverse-complement markers strand-corrected, lmo0737 verified 100% against EGD-e). The vpa_ok cluster snapshot is MIT-licensed vpautils content (lab-curated loci, Bakta-annotated, via indexofire/vpautils); it ships as the resolved sequences + features.json pair a completed gspec.typing/2 build produces. The cje_cps panel is assembled from the GenBank accessions the source paper lists (public-domain INSDC records; the paper itself is CC0), so it clears the same gate. The shi_sero panel is reformatted from ShigaTyper 2.0.5's Public Domain marker FASTA (no ShigaPass GPL content); its serotype.json is the first conservative marker-set resolver and is not a byte-for-byte ShigaTyper port. Its ipaH_c control is split into two non-overlapping presence fragments (1-640 and 641-780) so divergent ipaH alleles remain detectable. The vpa_vf haemolysin panel was rebuilt from public INSDC records (RIMD 2210633 chromosome 2 NC_004605.1, strain 10329 CP045795.1, strain GTVSS-031 CP176647.1) with sequences byte-identical to the earlier locally-built panel — annotations re-derived from INSDC, so no third-party database terms ride the distribution. The cam_vf and cdi_vf panels were rebuilt the same way (NCTC 11168 NC_002163.1, 81-176 pVir AF226280.2 / CP000550.1, LR134499.1, JX436460.1, AF400048.1, AF130984.1; 630 NC_009089.1, AF271719.1) — cam_vf byte-identical except cgtB, strand-corrected to the coding orientation, and cdi_vf byte-identical. A companion audit kept spy_emm, nme_sero, spn_sero and sau_spa fetch-only: their upstream content is GPL-packaged (spy_emm, nme_sero, spn_sero) or academic-use restricted (sau_spa), and no byte-identical public-domain re-source could be verified for their records.

The cje_cpsv2 conversion joins the other permissively-licensed upstream conversions (sen_sero, lpn_vf, pau_sero, sag_sero): the CjejuniTyper capsule database (CC BY 4.0, v1.01, GitHub + Zenodo) ships with full attribution, and it landed as the production cje serotyping panel on 2026-11-14 after a ten-database evaluation on 130 labeled genomes (95.5% accuracy, 98.1% excluding three suspected label errors; the novel-locus limitation is recorded in its caveats). A regression test pins that no VF* / VFDB / ARO: tags appear in any bundle's headers.

A gspec.serotype/1 profile resolves its ordered marker-set rules with one policy knob, decision. The default, ambiguous, reports every matching rule's phenotype as an ambiguity — a marker set that fits two serovars is never decided by declaration order. most_specific instead drops any match whose positive markers are a strict subset of another match, which is what lets a full antigenic formula (O + H1 + H2 → serovar) sit above the generic "O group known, H undetermined" row it implies; matches that are not comparable stay ambiguous. sen_sero is the first profile to use it, and shi_sero keeps the default so its committed output does not move.

A gspec.serotype/2 document (the ranked-antigen shape a full panel needs, e.g. sen_sero) designates in a fixed order: the observed O:H1:H2 formula is looked up verbatim first — a row the table carries is the call, and the serovar's first-declared name is the phenotype when several names share the formula (the WHO table lists the common serovar first: C2-C3:d:1,2 is Muenchen, then Virginia as RUNNER_UP). A family whose top two antigens tie at identical evidence contributes all its tied names and their rows become the candidate list — a tight set, never a guess. Only a formula with no row widens: names expand to their similarity class, an undecided O group reaches every serogroup, and a weak phase-2 falls back to the monophasic - row — several widened matches stay an ambiguous candidate list. Near-ties the margin kept alive ride the definitive call as notes (H1 near-tie within 0.01: g,q), and every family note names the winning allele with its identity and coverage, so the call is auditable without opening the screen table.

A rule may also gate on ranking instead of presence: outranks names one competitor list per positive marker, and the rule matches only when that marker scores strictly higher (identity × coverage, the best_hit metric) than every listed competitor. This is how near-identical alleles are separated — O:2 and O:9 differ in 1–2 % of their tyr gene, so a presence floor cannot decide them between, and sen_sero declares the gate in both directions. A tie matches neither rule, so the profile reports its unresolved string instead of defaulting to a group.

vch_vf is a screen-only gene panel: CTX core (ctxA, ctxB, zot, ace, cep, orfU), RS2 (rstR, rstA, rstB), allele-specific ctxB_classical / ctxB_eltor, and tcpA_classical / tcpA_eltor / tcpA_o139. O139 uses the El Tor ctxB allele; the O139 tcpA marker is the FC1225-associated variant and is ~99.7% identical to canonical El Tor tcpA, so read identity/coverage.

vpa_pai is a screen-only cluster database with one locus per VPaI-1..VPaI-10 pathogenicity island (RIMD 2210633 for VPaI-1..7 and the T6SS VPaI-10; AQ3810 for VPaI-8/9). TSV output reports the best locus; --format json carries every locus with its coverage, identity, present/partial/missing gene evidence.

Snapshots are point-in-time. Each snapshot's sequences file is byte-for-byte what the curated build produces on the snapshot date (a regression test proves the byte-identity for vpa_ok against a gspec db build over the real vpautils GenBank files when local copies exist — features.json included, gene-id resolution included). Bundled databases have no provider and no db fetch path: a refresh means a new snapshot riding a wheel release. bundled.json records the snapshot date for reference.

(db outdated stays manifest-based in v1: it reports the materialization/fetch time of what is installed, not bundled-vs-upstream drift.)

Cluster profiles. A cluster database may carry a small cluster.json (gspec.cluster_profile/1) that opts into a different cluster-engine contract. coverage_mode: "primary_secondary" computes locus coverage from the union of minimap2 primary and secondary rows instead of the historical primary-only set, and fallback_evidence: true keeps the best same-family locus and coverage on an OUT/KUT call, so "no phenotype" is distinguishable from "no locus"; the cluster/2 phenotypes entries then carry locus_status = known, unknown_locus, or none. Optional min_gene_cov / min_gene_id / min_cluster_cov fields supply database defaults when the corresponding CLI flag is left at its historical default; locus_typeable_coverage / locus_typeable_identity add the Kaptive-style locus_confidence = typeable / untypeable. vpa_ok ships this profile (Kaptive-style coverage, a 50% gene-coverage floor, 50/90 typeable floors, and fallback evidence), so its O-locus calls use the same alignment evidence as Kaptive and KUT still names the detected KL locus. Other cluster databases have no profile and keep the historical primary-only behavior byte-for-byte.

How materialization works. The first gspec screen ... --db <bundled-name> against a datadir that does not hold the database builds it there automatically — one stderr note (gspec: materializing bundled database eco_dec (16 records) into <datadir>, silenced by --quiet), then the standard gene-build pipeline: records.jsonl, the sequences FASTA with gspec/v1 headers, the BLAST index, the typing.json copy when the bundle ships one, and a manifest stamped source: "bundled". That pipeline — shared with gspec db build — drops exact (gene, sequence) duplicate records at build time (first kept; a stderr note and the receipt's duplicates_dropped count the drops). Cluster bundles (vpa_ok) run the cluster pipeline instead: materialization rebuilds the locus FASTA and features.json from the committed artifacts through the same cluster build entry a db build uses — gene ids stay snapshot-resolved, the typing spec re-validates against them, no re-resolution. Deterministic, zero network. A missing datadir is bootstrapped by gspec db list, gspec db setup, db fetch/db build, and the first screen against a bundled name; gspec db setup materializes every bundled database alongside indexing; re-running either is a no-op once the manifest exists. db list shows the database as bundled before that and installed (16) after — on all four listing surfaces (TSV, rich table, --json, MCP db_list).

C. jejuni Penner capsule typing (cje_cps)

cje_cps is the Campylobacter jejuni capsule (Penner) panel: the 36 capsule-locus amplicons of the updated multiplex PCR in Poly et al. 2015 (PLoS ONE 10(12):e0144349, Table 3) plus an lpxA species control. Each record is the amplicon the published primer pair produces — the exact sequence the PCR would amplify — extracted from the GenBank accession the paper names for that primer set (the acc field carries the accession and slice). 47 Penner serotypes collapse into 35 capsule types, so the panel targets types and complexes rather than individual serotypes.

Designation is two-stage over a gene database (gspec.typing/2, scheme penner_cps, lpxA as control_gene):

$ gspec screen isolate.fa --db cje_cps --output cj.tsv --quiet
$ gspec typing cj.tsv --quiet
FILE    SCHEME  PHENOTYPE   FORMULA GENES   CONFIDENCE  SCORE   RUNNER_UP   NOTES
isolate.fa  penner_cps  HS4 complex (HS4/13/43/50/62/65)    -   HS4A;lpxA   high    1.0000  HS16 (0.0000)   ...

What the panel can and cannot resolve is encoded in the rules, not hidden:

  • Complexes are single calls — HS4 complex (4/13/43/50/62/65), HS6/7, HS8/17, HS23/36, HS33/35, HS5/31 share their CPS locus at the nucleotide level, so the call names the complex. An individual serotype inside a complex needs antisera or cgMLST.
  • Shared amplicons are profiles, not noise — HS5/31 also amplifies the HS45 band, HS58 shares the HS15 band, HS32/HS60 produce an HS45 band, and HS16/HS64 are separated only by the HS52 band. Those multi-band profiles are declared as complete exact_set rules (HS16 = HS4A+HS4B+HS52, HS64 = HS4A+HS4B, HS5/31 = HS5/31+HS45, HS58 = HS15+HS58, HS32 = HS32+HS45, HS60 = HS45+HS60), each carrying the paper's caveat in its notes.
  • lpxA gates everything — without a positive lpxA call the scheme reports the fallback with the note control gene absent, because the multiplex only means anything on a C. jejuni template.
  • One documented length deviation — the HS1 primer pair amplifies 607 bp in the reference locus (BX545859.1) where the paper reports 610 bp; the record keeps the actual reference slice and its bundled note states the difference.

Fallback untypeable (atypical CPS profile or non-jejuni). Coverage floor 90, identity floor 95 (the HS5/31 rule sits at 90 because the HS45 band in that locus is a divergent amplicon).

gspec db info -d cje_cps carries the panel's four literature references (Poly 2015 for the panel, Klena 2004 for the lpxA control, Penner 1980 for the scheme, Pike 2013 for the serotype distribution) and the seven interpretation caveats — the complex collapse, the shared-amplicon profiles, the lpxA-is-not-speciation warning, the 62 bp HS2 E-value bound, the HS1 607-vs-610 bp difference, the HGT caveat, and the paper's own untypeable-rate observation.

Listeria serogrouping (lmo_sero)

The typed bundle behind Listeria monocytogenes serogroup prediction: five markers — prs, lmo0737, lmo1118, ORF2819, ORF2110 — screened with 95/95 identity and coverage floors and folded by the doumith_serogroup scheme into Doumith's multiplex-PCR groups (Doumith et al. 2004, J Clin Microbiol 42:3819), extended with the Huang 2011 4b variant: prs gates the scheme as a genus-level control gene, IIa (1/2a or 3a), IIc (1/2c or 3c), IIb (1/2b, 3b or 7), IVb (4b, 4d or 4e), and IVb-v (the lmo0737-carrying 4b variant) — the same in-silico semantics as tools like LisSero. Designation runs through the two-stage pipeline: gspec screen -o table.tsv --db lmo_sero, then gspec typing table.tsv.

Known limitations, carried on the calls as notes where relevant:

  • 4b/4d/4e are unresolvable at gene level — the three serovars share every published molecular marker; resolve by cgMLST or antisera.
  • IVb-v is an emergent concern — lmo0737 in an otherwise-4b profile (Huang 2011 "unusual 4b"; ST382/ST554 clones) is declared before IVb so the variant wins.
  • EGD-e types as IIc — the 1/2a reference genome carries lmo1118 and lands in IIc; documented in Doumith 2004, not a tool artifact.
  • Horizontal gene transfer cuts both ways — the lineage-II lmo0737 cassette moves between lineages, and rare HGT of the ORF markers can produce false IIb-looking profiles; treat single-marker IIb calls in epidemiologically unlikely contexts with care.
  • prs is genus-level, not Lm-specific — other Listeria species carry it; a prs+ isolate with no serogroup markers falls back rather than being called non-Listeria.

The fallback call — untypeable (4a/4c, atypical profile, or non-Lm Listeria) — is the honest answer for everything the five markers cannot resolve.

vpa_ok (V. parahaemolyticus O:K, MIT, typed on install)

vpa_ok wraps the two Vibrio parahaemolyticus serotype references of indexofire/vpautils — OAgc.gbk (32 O-antigen gene cluster loci) and CPSgc.gbk (163 capsular polysaccharide loci) — into ONE merged kind: cluster database. It is a PURE built-in bundled database in the eco_dec/lmo_sero pattern: no provider, no source URLs, no gspec db fetch -d vpa_ok. The committed three-scheme typing asset (src/gspec/data/dbs/vpa_ok/typing.json, generated reproducibly by scripts/generate_vp_typing.py) installs with it, so screening renders gspec.cluster/2 with per-file phenotypes o_group, k_group, and the composed serotype "{o_group}:{k_group}" (fallbacks OUT/KUT) — the O:K serotype from a single scan:

$ gspec screen RIMD.fna --db vpa_ok --format json
{"schema": "gspec.cluster/2", ..., "phenotypes": {"o_group": {"phenotype": "O3"},
 "k_group": {"phenotype": "K6"}, "serotype": {"phenotype": "O3:K6"}}}

The database content is MIT (Bakta-annotated, via vpautils), so unlike the kaptive providers it is license-clean for redistribution — a resolved snapshot ships inside the wheel as one of the bundled databases (8.3 MiB committed artifacts, within the 30 MiB budget), and first use materializes it with zero network. The typing rules recompute sequence-unique key genes per locus (variants fold: OL4V1 → O4, KL20V1 → K20; untyped OLU* loci get no rule, while KLU61–KLU100 carry locus-only KUT rules so the detected locus survives the fallback), and the asset validates against the loci at build and materialization time — a drifted upstream GBK fails TYPING_UNKNOWN_GENE instead of installing silently. Calibrated against real genomes with RIMD 2210633 locked to O3:K6 (see the rule notes for the documented per-locus tuning).

Checking database freshness

gspec db outdated reports every installed database's age against the staleness threshold. Against a fully installed datadir (output trimmed to three of twenty-eight rows):

$ gspec db outdated --days 30
NAME    FETCHED_AT  AGE_DAYS    STATUS
argannot    2026-09-17T23:22:06Z    2.58    ok
bacmet2 2026-09-17T23:13:51Z    2.58    ok
card    2026-09-17T23:14:25Z    2.58    ok
...

A database installed long ago simply reports stale:

$ gspec db outdated --datadir /tmp/opencode/gspec-outdated-demo
NAME    FETCHED_AT  AGE_DAYS    STATUS
card    2020-01-01T00:00:00Z    2454.55 stale
Status Meaning
ok Within the threshold
stale age_days past --days (default 90; --days 0 marks everything stale)

Staleness is a report, never an error state: the command exits 0 however stale things are. Exit 4 (DATADIR_NOT_FOUND, DATADIR_EMPTY) covers a missing datadir or one with no installed databases; an unparseable fetched_at is MANIFEST_MALFORMED (exit 5). For bundled databases the report is manifest-based as everywhere else: a materialized bundle ages from its materialization time, and no bundled-vs-upstream comparison happens in v1 (see Bundled databases — future work). For agents, --json emits a gspec.dboutdated/1 document (introspectable via gspec schema dboutdated):

$ gspec db outdated --days 3 --json
{
  "schema": "gspec.dboutdated/1",
  "databases": [
    {
      "db": "argannot",
      "fetched_at": "2026-09-17T23:22:06Z",
      "age_days": 2.58,
      "status": "ok",
      "upstream_version": ""
    },
    {
      "db": "card",
      "fetched_at": "2026-09-17T23:14:25Z",
      "age_days": 2.58,
      "status": "ok",
      "upstream_version": ""
    }
  ]
}

Searching records across databases

gspec db search TERM looks up genes in the records.jsonl truth store of every installed database — no BLAST, just a fast scan. Matching is case-insensitive substring by default; --exact switches to full-field equality:

$ gspec db search ctx-m --limit 3
argannot    (Bla)blaCTX-M-1 X92506:63-938       (Bla)blaCTX-M-1 876
argannot    (Bla)blaCTX-M-10    AF255298:1-873      (Bla)blaCTX-M-10    873
argannot    (Bla)blaCTX-M-100   FR682582:1-876      (Bla)blaCTX-M-100   876
$ gspec db search "blaCTX-M-1" --field gene --exact
ncbi    blaCTX-M-1  NG_048897.1 CEPHALOSPORIN   extended-spectrum class A beta-lactamase CTX-M-1    876
$ gspec db search virulence --db vfdb --field function --limit 2
vfdb    AAA92657    AAA92657    virulence   (AAA92657) unknown protein [TraJ (VF0241) - Invasion (VFC0083)] [Escherichia coli]  606
vfdb    AAC38364    AAC38364    virulence   (AAC38364) Orf1 [Ler (VF0189) - Regulation (VFC0301)] [Escherichia coli O127:H6 str. E2348/69]  390

Rows are DB\tGENE\tACCESSION\tFUNCTION\tPRODUCT\tLENGTH, streamed in database-then-file order; FUNCTION joins the record's function classes with ;. --field picks gene|accession|function|product|any (default any searches all of them, one function class at a time). --limit N caps the output (default 100; 0 = unlimited) and stderr notes a truncation (--quiet silences it); zero hits exit 0 with empty stdout. --json prints one JSON object per hit with the same fields as snake_case (function as an array):

$ gspec db search "tet(M)" --field gene --exact --json | head -1
{"db":"card","gene":"tet(M)","accession":"AB039845.1:25-1945","function":["tetracycline"],"product":"Tet(M) is a ribosomal protection protein that confers tetracycline resistance. It is found on transposable DNA elements and its horizontal transfer between bacterial species has been documented.","length":1920}

An installed database whose records.jsonl is missing is skipped with a stderr warning during a full scan, but targeting it explicitly (--db NAME) fails with exit 4 DB_INCOMPLETE; an unknown --db NAME is a usage error (exit 2) listing what is installed.

Providers

Twenty-one providers ship with gspec. Every one of them — card, ncbi, and vfdb included — downloads from its upstream source at fetch time. No provider snapshot is bundled: only the seven gspec-curated, permissively licensed bundles above ride the package. Several upstream licenses (CARD's McMaster terms, VFDB's CC BY-NC, Kaptive's GPL-3.0) forbid redistribution inside an MIT-licensed distribution, and even permissively licensed provider snapshots carry provenance risk, so they stay fetch-on-demand. Eight providers are cluster databases (built through the cluster pipeline at fetch time): the seven Kaptive providers (Kaptive providers) and vch_oagc; the typed vpa_ok and untyped vpa_pai are bundled-only (vpa_ok).

Name Maintainer Content dbtype
ncbi NCBI NCBI AMRFinderPlus (reference finder) curated AMR nucl
card McMaster University CARD protein homolog resistance models nucl
resfinder DTU CGE CGE ResFinder acquired resistance genes nucl
argannot IHU Méditerranée-Infection ARG-ANNOT acquired resistance genes nucl
nme_sero MDU-PHL N. meningitidis serogroup + ctrA + sodC control (non-MLST); see nme_sero.md nucl
vch_oagc gspec(Hangzhou CDC) V. cholerae O-antigen gene clusters (190 OL loci + ompW control; cluster, NCBI efetch) nucl
plasmidfinder DTU CGE CGE PlasmidFinder replicons nucl
megares MEG Lab MEGARes antimicrobial resistance genes nucl
ecoh Holt lab (srst2) E. coli O and H antigens (srst2 EcOH) nucl
vfdb USTC (VFDB) VFDB virulence factors (set A, nucleotide) nucl
ecoli_vf PHAC-NML E. coli virulence factors (phac-nml) nucl
bacmet2 University of Gothenburg BacMet2 experimentally confirmed biocide/resistance genes (protein) prot
victors University of Chicago Victors virulence factors nucl
upec_expec_vf FordeGenomics UPEC/ExPEC virulence genes (FordeGenomics) nucl
kpsc_k Kaptive (klebgenomics) K. pneumoniae species complex K locus (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl
kpsc_o Kaptive (klebgenomics) K. pneumoniae species complex O locus (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl
kosc_k Kaptive (klebgenomics) K. oxytoca species complex K locus (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl
kosc_o Kaptive (klebgenomics) K. oxytoca species complex O locus (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl
ab_k Kaptive (Kenyon lab) A. baumannii K locus (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl
ab_o Kaptive (Kenyon lab) A. baumannii OC locus — official keyword ab_o (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl
ecoli_kps Kaptive (Gladstone lab) E. coli group 2+3 capsular polysaccharide loci (Kaptive; cluster, GPL-3.0, downloaded on fetch) nucl

Protein databases (bacmet2) screen through blastx; nucleotide ones through blastn. Cluster databases screen through the minimap2 cluster engine (screen.md).

vch_oagc fetches the 190 O-antigen locus records of Murase et al. 2022 from NCBI (LC594800–LC594991 subset) as one efetch batch, appends a committed ompW control locus, and installs a committed gspec.typing/2 asset (o_group + species). The same audited panel also ships as a bundled snapshot (db setup); db fetch rebuilds it from NCBI. Many OL clusters are not serologically verified; OUT means no reference locus matched, not non-O1/non-O139, and OLU loci are not in this build yet. ctxA/ctxB and the CTX/RS2/tcpA markers are in the separate bundled vch_vf panel, not this O-antigen database.

Kaptive providers (GPL, downloaded on fetch)

The seven kaptive providers wrap the reference databases of Kaptive (Wyres et al., J Clin Microbiol 2020 — please cite Kaptive when you use results from these databases). The database NAMEs are the official install keywords from the Kaptive v3 database docs (Available databases), and each fetches its raw GenBank file from the head (main) of the actively curated per-species upstream repository — klebgenomics/KpSC_surface_antigen_loci (kpsc_k, kpsc_o), klebgenomics/KoSC-surface-antigen-loci (kosc_k, kosc_o), johannajkenyon/Abaumannii_surface_polysaccharide_loci (ab_k, ab_o), and rgladstone/EC-K-typing (ecoli_kps) — so a fetched database tracks current upstream curation rather than a frozen release. Those repos also ship .toml metadata with upstream identity thresholds; gspec does not fetch it in v1 (a future typing.json source).

The database content is GPL-3.0, while gspec is MIT — so nothing kaptive is ever bundled: gspec db fetch -d kpsc_k (and the other six keywords) downloads the GenBank file at fetch time and builds a kind: cluster database through the cluster pipeline. The manifest records the upstream URL, the GPL-3.0 (database content) license, and the citation note. No typing model ships with them (phenotype calls stay null); you get kaptive-style best locus calls, and you can later install your own typing.json semantics by rebuilding with gspec db build --typing.

Fetching databases

The default set

gspec db fetch -d all installs the default set, card then vfdb. Like every provider it downloads from upstream, transforms the records, and builds sequences plus the BLAST index locally — so the index always matches the BLAST version actually installed on your machine. Network access is required. A bare gspec db fetch prints the command help: a multi-database download is always named explicitly (all or one or more NAMEs), never implied by an omitted -s.

Fetching a named database

gspec db fetch -d NAME [NAME ...] runs the full pipeline for one or more databases. Here is card (stderr progress lines, then a one-line JSON receipt on stdout):

$ gspec db fetch -d card --datadir /tmp/opencode/gspec-dbs-demo
gspec: downloaded 1 source file(s)
gspec: read 6059 records from card
gspec: generated /tmp/opencode/gspec-dbs-demo/card/sequences
gspec: self-check passed for card
gspec: BLAST index built (nucl)
{"db":"card","records":6059,"dbtype":"nucl","destination":"/tmp/opencode/gspec-dbs-demo/card"}
Receipt field Type Meaning
db string Database name (NAME)
records integer Records written to records.jsonl
dbtype string nucl or prot
destination string Installed database directory

Every database downloads from its upstream source at fetch time, so fetches need network access. Unknown names are rejected before the datadir is even resolved:

$ gspec db fetch -d nosuchdb
{"schema":"gspec.error/1","code":"USAGE_ERROR","message":"unknown database: nosuchdb (available: argannot, bacmet2, card, ecoh, ecoli_vf, megares, ncbi, plasmidfinder, resfinder, upec_expec_vf, vfdb, victors)","context":{"db":"nosuchdb"}}

Refetching

An existing database directory is never overwritten silently. Refetching without flags fails with exit 4:

$ gspec db fetch -d card --datadir /tmp/opencode/gspec-dbs-demo
{"schema":"gspec.error/1","code":"DB_ALREADY_EXISTS","message":"won't overwrite existing database card (use --force)","context":{"db":"card"}}

--force deletes and rebuilds in place:

$ gspec db fetch -d card --datadir /tmp/opencode/gspec-dbs-demo --force
{"db":"card","records":6059,"dbtype":"nucl","destination":"/tmp/opencode/gspec-dbs-demo/card"}

Installing a local file

gspec db install SOURCE --sha256 HASH --output TARGET is a verified local-file install. It knows nothing about the provider catalog, archives, or sequence content: it streams SOURCE through SHA256, compares the digest against --sha256, and only then atomically replaces TARGET. A failed check leaves any existing TARGET untouched.

$ sha256sum card.json
65838c8d4f160923fbf8c296c0f986bd5b55f7f5b5a15a7bbeb35412b945e025  card.json
$ gspec db install card.json \
    --sha256 65838c8d4f160923fbf8c296c0f986bd5b55f7f5b5a15a7bbeb35412b945e025 \
    --output /tmp/opencode/card-copy.json
{"destination":"/tmp/opencode/card-copy.json","sha256":"65838c8d4f160923fbf8c296c0f986bd5b55f7f5b5a15a7bbeb35412b945e025"}

A wrong digest aborts with exit 5:

$ gspec db install card.json \
    --sha256 0000000000000000000000000000000000000000000000000000000000000000 \
    --output /tmp/opencode/card-bad.json
{"schema":"gspec.error/1","code":"CHECKSUM_MISMATCH","message":"SHA256 mismatch for card.json","context":{"source":"card.json","expected":"0000000000000000000000000000000000000000000000000000000000000000","actual":"65838c8d4f160923fbf8c296c0f986bd5b55f7f5b5a15a7bbeb35412b945e025"}}

What's inside a gspec-built database

<datadir>/<name>/
  records.jsonl         truth source: one Record JSON object per line
  sequences             generated FASTA projection (gspec/v1 tagged headers)
  sequences.n*|p*       BLAST index built from sequences
  gspec-manifest.json   provenance sidecar, written last
  typing.json           optional gspec.typing/1 or /2 scoring spec (typed dbs)
  floors.json           optional gspec.floors/1 per-gene identity floors (reads + contigs)
  screen.json           optional gspec.screen/1 per-database reads/contigs defaults

records.jsonl

This is the editable truth. Every screening artifact is generated from it, so editing records and refetching with --force regenerates everything downstream. One JSON object per line; the first card record, verbatim:

{"db":"card","gene":"23S_rRNA_(adenine(2058)-N(6))-methyltransferase_Erm(A)","sequence":"ATGAAACAGAAAAACCCGAAAAATACGCAAAATTTCATTACATCTAAAAAGCATGTAAAGGAAATATTAAAATATACGAATATCAATAAACAAGATAAAATAATAGAAATTGGGTCAGGAAAAGGACATTTTACCAAGGAACTTGTGGAAATGAGTCAACGGGTGAATGCTATAGAGATTGATGAAGGTTTATGTCATGCCACGAAAAAAGCAGTTGAACCTTTTCAGAATATAAAAGTTATTCATGAGGATATTTTGAAGTTTAGCTTTCCTAAAAATACAGACTATAAAATATTTGGTAATATTCCCTACAATATTAGTACTGATATTGTAAAAAAGATTGCTTTTGATAGTCAAGCGAAATATAGCTACCTTATTGTAGAGAGGGGATTTGCTAAAAGGTTGCAAAATACCCAACGAGCTTTAGGTTTGCTGTTAATGGTGGAAATGGATATAAAAATTCTTAAAAAAGTGCCACGAGCATATTTTCACCCTAAGCCTAATGTAGATTCTGTATTGATTGTACTTGAAAGGCATAAACCATTTATTTTAAAGAAGGACTACAAAAAGTATAGATTTTTCGTTTATAAATGGGTAAACAGGGAATATCATGTTCTTTTTACTAAAAATCAATTAAGACAGGTGCTGAAGCATGCGAATGTTACTGATCTTGATAAATTATCCAATGAACAATTTTTGTCTGTTTTCAATAGTTACAAATTATTTCAATAA","accession":"AF002716.1:210-942","function":["lincosamide","macrolide","streptogramin"],"product":"Variant of ErmA (ARO:3000347) found in Streptococcus pyogenes. Confers the MLSb phenotype.","source_id":"3005099"}
Field Type Meaning
db string Source database name
gene string Gene name, the identity gspec reports on
sequence string Normalized sequence (uppercase; N/X for ambiguous bases)
accession string Accession or coordinate span, empty when unpublished
function array of string Functional categories, sorted (see the vocabulary below)
product string Product description, n/a when absent
source_id string Provider-native record identifier

gspec-manifest.json

The manifest certifies the build: what was fetched, when, from where, and with which tool versions. A real one, from the plasmidfinder database:

{
  "schema": "gspec.manifest/1",
  "name": "plasmidfinder",
  "source_urls": [
    "https://bitbucket.org/genomicepidemiology/plasmidfinder_db/get/HEAD.zip"
  ],
  "fetched_at": "2026-09-17T23:11:36Z",
  "sha256": "a18dc9dab762fe1e23a90c11314ee179c37c59dad833a5f465a78dc245970c2a",
  "n_records": 488,
  "dbtype": "nucl",
  "header_format": "gspec/v1",
  "upstream_version": "",
  "tool": {
    "name": "gspec",
    "version": "0.10.0"
  },
  "makeblastdb_version": "blastn: 2.17.0+",
  "minimap2_version": "2.31-r1302"
}
Field Type Meaning
schema string Always gspec.manifest/1
name string Database name
source_urls array of string Upstream URLs the content came from
fetched_at string ISO-8601 UTC timestamp, second precision
sha256 string Digest of the built sequences file, 64 lowercase hex chars
n_records integer Record count, matches records.jsonl
dbtype string nucl or prot, chosen explicitly at build time
header_format string Always gspec/v1 for gspec-built databases
upstream_version string Upstream release label when the source has one
license string Database-content license, present only when the provider declares one (kaptive: GPL-3.0 (database content); card: McMaster non-commercial terms; vfdb: CC BY-NC 4.0)
note string Free-text provenance note (kaptive: source file + citation), present only when set
tool object {name, version} of the gspec that built the database
makeblastdb_version string BLAST+ version that built the index
minimap2_version string minimap2 version in the build environment (reads mode indexes in memory; no .mmi is built)

records.jsonl and the manifest are file contracts. They never appear on stdout and are not registered with gspec schema (the stdio/listing documents dblist, dbsetup, dboutdated, datadir, and dbinfo are).

floors.json — per-gene identity floors

An optional sidecar declaring a MINIMUM alignment identity (%) per gene for reads-mode and contig-mode presence (schema gspec.floors/1, introspect with gspec schema floors; see reads.md for the screening semantics and the pic worked example):

{"schema": "gspec.floors/1", "default": null, "genes": {"pic": 90.0}}
Field Type Meaning
schema string Always gspec.floors/1
default number or null Floor for genes not listed in genes (null = no floor)
genes object {gene: minimum identity %}, values in [0, 100]

The file's presence IS the flag — no manifest field, no CLI switch. A database without the sidecar screens byte-identically to before (the floors are a db-driven opt-in, not a CLI contract change). Both engines read them: reads mode drops sub-floor alignments before aggregation; contig mode post-filters BLAST hits, so set --minid to the lowest floor in the document and let the floor enforce the higher per-gene threshold. Built-in via db build --floors (next sections), or drop the file into an existing db directory; it is validated at screening time too (malformed content fails with FLOORS_MALFORMED, exit 4). The bundled eco_dec ships {"genes": {"pic": 90.0}} — the SPATE-homolog false-positive fix.

Header formats and compatibility

gspec reads two header formats and detects them per record:

  • abricate legacy: >DB~~~GENE~~~ACCESSION~~~RESISTANCE PRODUCT. Fields may be missing; missing trailing fields decode to empty strings.
  • gspec-native gspec/v1: >gspec|db=<v>|gene=<v>|acc=<v>|func=<v> PRODUCT with percent-encoded values, so gene names and products survive BLAST and minimap2 byte for byte, spaces and pipes included.

Both decode into the same four identity fields, and the TSV/JSON outputs are identical in shape either way. For native databases the RESISTANCE column carries the func value.

Warning: abricate cannot read gspec-built databases. The gspec/v1 header format is not the ~~~ convention. gspec reading abricate datadirs is one-directional by design; keep a legacy copy if a downstream tool still runs abricate.

The func vocabulary

Each native provider fills function from a fixed vocabulary, and these values flow through to the TSV RESISTANCE column and the JSON resistance field:

Provider(s) func value(s)
ncbi, resfinder, argannot, card The source's antibiotic classes
megares The MEGARes class field
ecoh H-antigen, O-antigen, or an antigen fallback derived from the allele
vfdb, ecoli_vf, victors, upec_expec_vf virulence
plasmidfinder replicon
bacmet2 biocide

Bringing your own database

gspec db build NAME FASTA turns any FASTA of reference genes into a fully built gspec-native database — records.jsonl, the sequences projection with gspec/v1 headers, the BLAST index, and the manifest — in one command. Here is a two-gene synthetic FASTA plus a metadata TSV (fields below), run against a scratch datadir:

$ gspec db build tinyamr my_genes.fa --datadir ./db --tsv my_meta.tsv
gspec: generated /tmp/opencode/gspec-build-demo/db/tinyamr/sequences
gspec: self-check passed for tinyamr
gspec: BLAST index built (nucl)
{"db":"tinyamr","records":2,"dbtype":"nucl","destination":"/tmp/opencode/gspec-build-demo/db/tinyamr"}

stderr carries the per-step progress, stdout the one-line JSON receipt (same fields as db fetch, see the table above). The database screens immediately:

$ gspec screen --datadir ./db --db tinyamr contig.fa
Processing: contig.fa
Found 1 genes in contig.fa
#FILE   SEQUENCE    START   END STRAND  GENE    COVERAGE    COVERAGE_MAP    GAPS    %COVERAGE   %IDENTITY   DATABASE    ACCESSION   PRODUCT RESISTANCE
contig.fa   contig1 1   240 +   syn_betalac 1-240/240   =============== 0/0 100.00  100.00  tinyamr SYN-0001    synthetic class A beta-lactamase    ampicillin;cephalosporin

The ACCESSION and RESISTANCE values came from the TSV merge; the PRODUCT from the FASTA description. --dbtype nucl|prot forces the molecule type; by default the abricate mol-type heuristic decides from the sequences themselves. Input may be plain, .gz, or .bz2.

Header detection

The header kind is detected per record, so mixed files work:

FASTA header Gene Accession Function Product
>syn_betalac synthetic class A beta-lactamase syn_betalac — — synthetic class A beta-lactamase
>olddb~~~sul1~~~U12338.4:1-940~~~SULFONAMIDE sulfonamide resistance sul1 U12338.4:1-940 SULFONAMIDE sulfonamide resistance
>gspec\|db=old\|gene=sul2\|acc=X\|func=streptomycin aminoglycoside sul2 X streptomycin aminoglycoside

Plain headers without any description text fall back to --description TEXT, then to the gene name. The db field of every record is always NAME (the database being built), and source_id keeps the original id token verbatim. Malformed gspec| headers fail the build with HEADER_MALFORMED (exit 4); structurally invalid FASTA fails with INVALID_FASTA (exit 5).

Merging metadata from a TSV

--tsv FILE adds or overrides accession and function classes per gene. The rules:

  • The header row is mandatory and must contain a gene column; accession and function are optional per file (absent columns are simply not merged), and extra columns are ignored. A missing gene column fails with exit 5 METADATA_MALFORMED.
  • Rows are keyed by gene: the first row wins on duplicates, with a warning on stderr (--quiet silences it).
  • The function column is ;-separated for multiple classes, e.g. ampicillin;cephalosporin.
  • Genes present only in the TSV produce a stderr warning and are skipped — the FASTA is the truth for what exists.

The example TSV used above, in full:

$ cat my_meta.tsv
gene    accession   function
syn_betalac SYN-0001    ampicillin;cephalosporin

Per-gene identity floors (--floors)

--floors FILE installs a gspec.floors/1 document as the database's floors.json sidecar — the per-gene minimum alignment identity for reads-mode and contig-mode presence (see reads.md). The document is validated before any artifact is written: every gene in genes must exist in the FASTA (FLOORS_UNKNOWN_GENE, exit 4 — a floor for a missing gene is silently dead safety config), values must lie in [0, 100] and the structure parse (FLOORS_MALFORMED, exit 4). The file is then copied in byte-identical; the file's presence is the flag (no manifest field changes). Gene builds only — a GBK/GFF cluster input rejects --floors as a usage error.

$ cat my_floors.json
{"schema": "gspec.floors/1", "default": null, "genes": {"syn_betalac": 95.0}}
$ gspec db build tinyamr my_genes.fa --datadir ./db --tsv my_meta.tsv --floors my_floors.json
{"db":"tinyamr","records":2,"dbtype":"nucl","destination":"/tmp/opencode/gspec-build-demo/db/tinyamr"}
$ cat ./db/tinyamr/floors.json
{"schema": "gspec.floors/1", "default": null, "genes": {"syn_betalac": 95.0}}

Per-database screening defaults (--screen)

--screen FILE installs a gspec.screen/1 document as the database's screen.json sidecar — the reads/contigs defaults (breadth, identity prefilter, MAPQ, depth, relative-depth control, contig identity/coverage, merge-fragments). The document is parsed before any artifact is written (SCREEN_DEFAULTS_MALFORMED, exit 4); a relative control gene must exist in the FASTA (SCREEN_DEFAULTS_UNKNOWN_GENE, exit 4). CLI flags still win per run. See screen.json.

$ cat my_screen.json
{"schema": "gspec.screen/1",
 "reads": {"min_identity": 80.0, "min_mapq": 20, "min_depth": 5.0,
           "min_relative_depth": 0.10, "relative_to": "lpxA"},
 "contigs": {"minid": 80.0, "mincov": 80.0, "merge_fragments": true}}
$ gspec db build tinyamr my_genes.fa --datadir ./db --screen my_screen.json
$ cat ./db/tinyamr/screen.json

Rebuilding

Like db fetch, an existing database is never overwritten silently:

$ gspec db build tinyamr my_genes.fa --datadir ./db
{"schema":"gspec.error/1","code":"DB_ALREADY_EXISTS","message":"won't overwrite existing database tinyamr (use --force)","context":{"db":"tinyamr"}}
$ gspec db build tinyamr my_genes.fa --datadir ./db --tsv my_meta.tsv --force
gspec: generated /tmp/opencode/gspec-build-demo/db/tinyamr/sequences
gspec: self-check passed for tinyamr
gspec: BLAST index built (nucl)
{"db":"tinyamr","records":2,"dbtype":"nucl","destination":"/tmp/opencode/gspec-build-demo/db/tinyamr"}

Because records.jsonl is the editable truth, editing it and rebuilding regenerates every downstream artifact. Omitting the input does exactly that — no source FASTA needed:

$ vim ~/.local/share/gspec/db/mypanel/records.jsonl   # curate: rename, merge, drop, fix
$ gspec db build mypanel
gspec: rebuilding mypanel from records.jsonl
gspec: generated .../mypanel/sequences
gspec: self-check passed for mypanel
gspec: BLAST index built (nucl)
{"db":"mypanel","records":4,"dbtype":"nucl","destination":".../mypanel"}

The in-place mode re-projects sequences, re-runs the self-check, rebuilds the BLAST index, and re-stamps the manifest — preserving its provenance (fetched_at, source URLs, licence, typing_schema, source) and carrying the typing.json/floors.json/info.json sidecars across verbatim. Records are republished as written: records.jsonl is the truth, and the build-time duplicate dropper cleans provider input, not a curator's file (delete the duplicate line to drop it).

Two guard rails keep the two modes from being confused:

  • the input-shaping options (--tsv, --dbtype, --description, --kind, --typing, --floors) describe a new database and are rejected without an input — a usage error names the offending flags instead of ignoring them;
  • the rebuild is staged, so a malformed record or a typing rule that no longer resolves leaves the installed database untouched.

Cluster databases cannot be re-projected this way: their locus FASTA and features.json are generated from a source GBK/GFF (and their typing rules key on resolved gene ids), so the call fails with DB_REBUILD_CLUSTER — rebuild them with gspec db build NAME FILE.

Renaming an installed database

gspec db rename OLD NEW re-homes a database under a new name without a re-download:

$ gspec db rename cam cam_vf
gspec: renaming cam -> cam_vf (gene database)
gspec: BLAST index built (nucl)
{"db":"cam_vf","renamed_from":"cam","records":17,"kind":"gene","destination":".../cam_vf"}

Gene databases carry the name inside every records.jsonl record and every gspec/v1 header, so the directory is rebuilt through the standard build pipeline with db re-pointed (records, sequences, self-check, BLAST index, manifest). Cluster databases carry the name only in the manifest — locus headers are bare ids — so their content is copied verbatim and the manifest re-stamped. Typing/floors/feature sidecars travel along, and both paths are staged: a failure leaves OLD untouched, and OLD is removed only after NEW is published (the manifest provenance, including fetched_at, is preserved).

Use it when a name predates the naming convention; it is also the generic escape hatch for a lab's own naming choices. --force replaces an existing target. Directories without a manifest (abricate-style imports) have no name to rewrite and are refused with DATABASE_NOT_FOUND — rebuild them with db build instead.

The manual (abricate-style) path

db build is the recommended route, but any abricate-format datadir also works as-is: point --datadir at a directory containing <name>/sequences (a nucleotide FASTA with ~~~ headers) and run gspec db setup once to build the BLAST index. The mol-type heuristic from abricate picks nucl vs prot.

End to end with a tiny three-gene database copied into a scratch datadir:

$ ls /tmp/opencode/gspec-own-db/db/tinyamr
sequences
$ gspec screen --datadir /tmp/opencode/gspec-own-db/db --db tinyamr /tmp/opencode/gspec-own-db/gap.fa
Processing: /tmp/opencode/gspec-own-db/gap.fa
{"schema":"gspec.error/1","code":"DATABASE_NOT_INDEXED","message":"Database /tmp/opencode/gspec-own-db/db/tinyamr/sequences is not indexed, please try: gspec db setup","context":{"db":"/tmp/opencode/gspec-own-db/db/tinyamr/sequences"}}
$ gspec db setup --datadir /tmp/opencode/gspec-own-db/db
Indexed tinyamr (3 sequences, nucl)
$ gspec screen --datadir /tmp/opencode/gspec-own-db/db --db tinyamr /tmp/opencode/gspec-own-db/gap.fa
#FILE   SEQUENCE    START   END STRAND  GENE    COVERAGE    COVERAGE_MAP    GAPS    %COVERAGE   %IDENTITY   DATABASE    ACCESSION   PRODUCT RESISTANCE
/tmp/opencode/gspec-own-db/gap.fa   contig1 1   97  +   sul1    1-94/94 ========/====== 1/3 100.00  96.91   tinyamr U12338.4:1-940  sulfonamide-resistant dihydropteroate synthase Sul1 SULFONAMIDE

gspec db setup indexes every subdirectory with a readable sequences file and exits 0 when all of them have sequences.nin or sequences.pin.

Reads mode and legacy datadirs

For reads screening (see reads.md), minimap2 always indexes the sequences FASTA in memory; no .mmi is built, and one left in a datadir by an older gspec is never consulted. Persisted indexes were tried and rejected: a default-built .mmi overrides the -x sr preset's indexing parameters (minimap2 warns "-k, -w or -H overridden by prebuilt index"), which misassigns close homologs (CTX-M/SHV allele divergence in the deciding benchmark) and ran slower than in-memory indexing at current database scale. Legacy abricate datadirs take the same in-memory path.

A complete db build walkthrough with worked examples for every header format, protein databases, metadata TSVs, and a troubleshooting table lives in Custom databases.

Cluster databases (GBK/GFF)

gspec db build NAME input.gbk (or .gbff, .gb, .gff, .gff3, each plain or .gz/.bz2) builds a different kind of database: one record = one gene locus. The input kind is detected by suffix (--kind gene|cluster must agree or the build is a usage error); the FASTA gene pipeline of the previous section is untouched.

$ gspec db build mycps cps_loci.gbk --datadir ./db
gspec: generated ./db/mycps/sequences
gspec: self-check passed for mycps
gspec: BLAST index built (nucl)
{"db":"mycps","records":2,"dbtype":"nucl","destination":"./db/mycps"}

Parsing (no Biopython): GenBank records become loci (LOCUS name = locus id) with their CDS features as genes; the source-feature notes carry the label and type (kaptive K locus:/K type: style, with Bakta-style fallbacks to the locus id). GFF3 inputs take the sequences from an embedded ##FASTA block or a <stem>.fa/.fna/.fasta sidecar. Compound join() CDS locations are rejected with a typed error — split the record or use simple CDS annotations.

The artifacts differ from a gene database: sequences holds one bare-locus-id record per locus (plain headers — abricate cannot read these), features.json is the gspec.features/1 feature table (introspect with gspec schema features), the manifest declares kind: cluster, and there is no records.jsonl. Screening dispatches to the minimap2 cluster engine (screen.md).

Cluster screening takes assembly FASTA only: --r1/--r2 and --aligner minimap2 are rejected for a cluster database, and FASTQ must be assembled first. The reads-mode gene-presence path remains available for gene databases. Rationale and thresholds: screen.md.

The build also writes a sequences.asm20.mmi minimap2 target index (when minimap2 is on PATH); db setup refreshes it. Legacy cluster screening uses that index when fresh, while gseek maintains its own cache.

typing.json — declarative phenotype scoring

--typing FILE installs a validated gspec.typing/1 or gspec.typing/2 document into the database as typing.json; screening then annotates every best call with a phenotype and an explainable score breakdown (the PHENOTYPE TSV column and phenotype_detail in gspec.cluster/1 — outputs.md). A minimal weighted_genes example:

{
  "schema": "gspec.typing/1",
  "rules": [
    {
      "model": "weighted_genes",
      "phenotype": "K1",
      "weights": {"wzx": 1.0, "wzy": 3.0},
      "negative": {"rfaD": -1.0},
      "identity_floor": 95.0,
      "require_any": ["wzx", "wzy"]
    }
  ],
  "cutoff": 0.9,
  "ambiguity_margin": 0.05,
  "fallback": "unknown"
}

Three rule kinds exist — weighted_genes (gene presence with an identity floor, negative markers, and an any-of gate), cluster_match (weighted locus coverage/identity/key-genes components with per-component floors), and learned_linear (a trained sigmoid over named features gene:<id>:<cov|ident|present> / cluster:<locus>:<coverage|identity>) — plus the document-level cutoff, ambiguity_margin, and fallback the decision layer applies. The full schema prints with gspec schema typing. Validation is strict at build time: a malformed document fails with TYPING_MALFORMED, and a rule referencing a gene or locus the input does not carry fails with TYPING_UNKNOWN_GENE before any artifact is written (the same check reruns at screen time, so hand-edited databases cannot smuggle dead references).

gspec.typing/2 wraps the same rules in NAMED schemes (schemes: [{"name": "pathotype", "rules": [...], "cutoff": ..., "ambiguity_margin": ..., "fallback": ...}], names [a-z0-9_] and unique); a /1 document loads as one anonymous default scheme, so existing typed databases keep their output. --typing also works on GENE (FASTA) builds — weighted_genes rules only in v1, gene references checked against the FASTA records. A typed gene db screens exactly like an untyped one (pure gene detection); its designations come from the two-stage pipeline — gspec screen -o result.tsv writes the table, and gspec typing result.tsv renders one call per scheme as gspec.typing_result/1 (typing.md).

typing/2 stage 2 adds six rule/scheme primitives (all optional and additive; full detail in gspec schema typing): the exact_set rule (Doumith/Shigella-style marker tables — score 1.0 iff every requires gene is present AND every excludes gene is absent, floors defaulting to 90/90; a 1.0 tie involving a satisfied exact_set resolves by declaration order instead of the ambiguity margin), an optional coverage_floor on weighted_genes/exact_set, scheme-level control_gene (prs/ipaH-style gate: when absent the whole scheme outputs its fallback with a "control gene absent" note), unique_group + mixed_phenotype (when more than one gene of a group is present, the scheme calls the mixed phenotype with the pair in ambiguous), compose schemes ("{o_group}:{k_group}" rendered from sibling schemes' calls — fallback strings flow through, an ambiguous ingredient yields a null composition carrying that ingredient's variants), and rule-level notes surfaced verbatim on winning calls.

Six researched designation schemes — the complete Doumith Listeria table, ShigaTyper-semantics Shigella/EIEC, the meningotype serogroup panel with allele probes, the Vibrio parahaemolyticus O/K Kaptive pattern, V. cholerae O1/O139 + Ogawa/Inaba, and a documented DEC placeholder — are encoded as validated example documents (synthetic marker fixtures, self-checked by the test suite) and walked through in Typing schemes.

Tuning a typing document against labeled assemblies is what scripts/cluster_calibration.py is for (developer tool): it screens every labeled sample, prints the per-expected-phenotype score distribution, the called×expected agreement matrix, and the divergence list — the loop a future learned_linear training flow will consume:

$ python scripts/cluster_calibration.py mycps --datadir ./db labels.tsv

screen.json — per-database screening defaults

Sequence length, allele diversity, and a control gene change what a good hit means: a 62 bp amplicon needs a higher identity floor than an 857 bp one, and a panel with lpxA can gate presence on relative depth. A database may ship a screen.json sidecar (schema gspec.screen/1) declaring its own defaults:

{
  "schema": "gspec.screen/1",
  "reads": {
    "min_breadth": 90.0,
    "min_identity": 80.0,
    "min_mapq": 20,
    "min_depth": 5.0,
    "min_relative_depth": 0.10,
    "relative_to": "lpxA"
  },
  "contigs": {
    "minid": 80.0,
    "mincov": 80.0,
    "merge_fragments": true
  }
}

Precedence: CLI flag > screen.json > global CLI default. Only options the user did not pass are filled from the sidecar, so gspec screen -d cje_cps ... works with no flags while --min-mapq 30 still wins for one run.

Install it with gspec db build NAME INPUT --screen FILE or drop screen.json into an installed database directory (then gspec db build NAME re-projects the gene database and carries the sidecar verbatim). gspec schema screen prints the JSON Schema.

The bundled cje_cps panel ships one: MAPQ 20, 10% lpxA relative-depth, depth 5, and contig --merge-fragments. Per-gene identity remains in floors.json (default 90%, lpxA/HS12 80% in the curated panel).

Upgrading an existing cje_cps directory: the wheel's bundle is only materialized when the database is absent, so an already-installed copy keeps its old records/sidecars. Copy the new records.jsonl/floors.json/ screen.json into the directory and run gspec db build cje_cps, or remove the directory and let the next screen re-materialize the bundle.