Skip to main content

gffbase gffbase

PyPI version PyPI downloads Python versions License Docs CI

What is GFFBase?

A high-performance genomic-annotation engine — a SIMD Rust parser, a DuckDB columnar backend and a zero-copy PyArrow interface — built for whole-genome ingest and bulk machine-learning feature extraction, and a drop-in successor to gffutils.

The legacy FeatureDB / Feature / create_db / DataIterator / GFFWriter / merge_criteria API is preserved verbatim, so most scripts migrate by changing one import line.

Install

pip install gffbase

Universal abi3 wheels: one binary per platform covers CPython 3.10 through 3.14, and no Rust toolchain is needed. Source and development builds are in the installation guide.

0.2.1 is the current release — correctness fixes to 0.2.0, several of which silently lost data; upgrade. Coming from 0.1.0, 0.2.x also fixes two SQL injection vulnerabilities (advisory) and has breaking changes. Both are in the changelog.

Quick start

from gffbase import create_db

# Ingest a GTF or GFF3 — format auto-detected, gzip transparent.
with create_db("gencode.v49.basic.annotation.gtf.gz", "gencode.duckdb") as db:

    # Walk one gene's hierarchy. GENCODE ids carry their version.
    for tx in db.children("ENSG00000139618.19", level=1, featuretype="transcript"):
        print(tx.id, tx.start, tx.end)

    # Overlap query, routed to the per-seqid R-tree.
    for exon in db.region("chr17:43044295-43125483", featuretype="exon"):
        print(exon)

Coming from gffutils? import gffbase as gffutils is usually the only change you need — but read the migration guide first, for the one loop pattern you should not port unchanged.

Bulk extraction without Python objects

The workload GFFBase exists for: pull every exon for tens of thousands of transcripts, hand the columns to a tensor, train. One set-based query returns DuckDB's own Arrow buffers, and no Feature object is constructed at any layer — where a per-feature Python loop allocates millions of throwaway objects and that allocation dominates everything else.

exons = db.children_batched(
    transcript_ids,              # an iterable of 50 000 IDs
    featuretype="exon",
    format="arrow",              # "df" and "polars" also supported
)
# A pyarrow.Table sharing memory with DuckDB. Its "anchor" column carries the
# input id for each row, so per-transcript groups survive without N queries.

import torch
starts = torch.from_numpy(exons.column("start").to_numpy())

region_batched() and parents_batched() offer the same zero-copy contract for spatial and parent workloads. One trade to know: iterating for i in ids: db.children(i) is slower here than legacy's row-by-row SQLite path, because DuckDB pays vectorization startup on every call — which is why the batched API exists.

End-to-end PyTorch and Hugging Face pipelines are in the ML workflows cookbook, and every method has a snippet in the usage gallery.

Measured against gffutils

Head-to-head across five canonical human-genome annotations — one run, one machine, one commit. Read the ingest column as a draw rather than a win: gffbase spans 1.21× to 0.69×, ahead where per-feature overhead dominates and behind on the attribute-dense whole-genome files, because both engines are attribute-bound and effectively serial at a comparable rate. The durable advantages — batched extraction, spatial indexing, SQL over the whole corpus — are untouched by that result.

Corpus Format Lines gffbase ingest legacy ingest speedup peak RSS (ingest + full validation) spatial qps batched (5 k anchors)
GENCODE v49 (basic) GTF 6,068,892 10 min 14 s 7 min 1 s 0.69× 53.57 GB 707 ±0% (n=5) 963 ms / 1.93 M desc
GENCODE v49 (basic) GFF3 6,066,054 11 min 8 s 9 min 59 s 0.90× 62.00 GB 705 ±0% (n=5) 1096 ms / 1.93 M desc
RefSeq GRCh38.p14 GFF3 4,932,571 7 min 2 s 6 min 34 s 0.93× 26.80 GB 540 ±0% (n=5) 588 ms / 999 k desc
CHESS 3.1.3 GFF3 2,761,061 1 min 53 s 2 min 17 s 1.21× 3.38 GB 702 ±0% (n=5) 202 ms / 161 k desc
MANE v1.5 (Ensembl) GFF3 524,834 40.0 s 45.7 s 1.14× 3.98 GB 840 ±0% (n=5) 206 ms / 156 k desc

Measured on AMD EPYC 7702 64-Core Processor · 128 cores · 1007.22 GB RAM · Linux-5.14.0-503.15.1.el9_5.x86_64-x86_64-with-glibc2.34
Versions: Python 3.11.16 · gffbase 0.2.0rc1 · duckdb 1.5.5 · pyarrow 25.0.1 · gffutils 0.14
Commit: 42bb900e328c · Run: 2026-09-10T19:56:52Z
Generated from benchmarks/results/06_mega.linux-x86_64.json by tools/gen_benchmark_tables.py. Do not edit by hand.

peak RSS is ingest plus exhaustive validation, not the cost of ingest: validate_db defaults to sample=200 and the CLI never overrides it. No speedup is published unless both engines' correctness signatures match first, and every number is generated from a committed measurement file — a test fails if a published table stops matching it. The per-corpus analysis, the fairness constraints and the measured run-to-run spread are on the performance and methodology pages.

What's inside

  • Rust + PyO3 parser — SIMD line and tab splitting, percent-decoding in and encoding back out, GTF semicolon-in-quotes safe, gzip transparent, failures raised as line-numbered GFFFormatError.
  • DuckDB columnar storage — an 11-table schema plus 3 compatibility views, set-based GTF gene/transcript synthesis, recursive-CTE transitive closure, and a per-seqid-banded R-tree built inline during ingest.
  • Smart routing — region() picks R-tree or B-tree; children() picks the closure cache or a dynamic CTE from the corpus's measured hierarchy depth.
  • Vectorized batched API — children_batched, parents_batched and region_batched return pyarrow.Table, pandas.DataFrame or polars.DataFrame straight out of DuckDB's buffer pool.
  • Drop-in legacy API — plus bed12, interfeatures, an execute() SQL escape hatch and export_sqlite(), with every remaining difference from gffutils 0.14 declared and tested.
  • Discontinuous features — several lines sharing one ID are one logical feature, with per-segment phase, covered_length and explode_segments=.
  • A command line and validation — gffbase create|fetch|children|parents|region|search|rmdups|sanitize|validate|migrate, structural validation at two depths, and in-place migration of a v1 database.

Documentation

Full site: khchao.com/gffbase

Page What's there
Quickstart A ten-minute walkthrough on a demo annotation
Migration guide Drop-in checklist, and the OLAP/OLTP gotcha
Usage gallery Every public method, copy-pasteable
Cookbooks GENCODE/Ensembl, RefSeq, MANE, ML workflows
Performance The numbers, and what they do not claim
Command line Every gffbase subcommand
API reference Full signatures and docstrings
FAQ and troubleshooting Short answers; errors organized by message

Contributing

Pull requests, bug reports and feature suggestions are welcome. CONTRIBUTING.md covers the Rust and Python development setup, the test suite and its coverage gates, branch naming and the PR checklist. The repository ships issue and pull-request templates.

License

Apache License 2.0 — see LICENSE.

Citation

If GFFBase contributes to your research, please cite it:

@software{chao_gffbase_2026,
  author  = {Chao, Kuan-Hao},
  title   = {{GFFBase}: Rust-accelerated GFF3/GTF parser with a
             DuckDB-backed storage engine and zero-copy PyArrow interface},
  year    = 2026,
  version = {0.2.1},
  url     = {https://github.com/Kuanhao-Chao/gffbase},
}

The repository also ships a CITATION.cff, so GitHub's "Cite this repository" button produces an up-to-date reference. Per-version DOIs are tracked on the releases page.

Metadata

Release files for gffbase 0.2.1

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

Source distribution (sdist)

Source distribution for gffbase 0.2.1
File Size Uploaded
gffbase-0.2.1.tar.gz 893.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for gffbase 0.2.1
File
gffbase-0.2.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
gffbase-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
gffbase-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
gffbase-0.2.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
gffbase-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 3.6 MB

Release files / gffbase-0.2.1.tar.gz

Download URL gffbase-0.2.1.tar.gz
Size 893.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8e622f8b6f3e59199c585c6510e6773cc378ca1cc57154b4bb7b579f01d5a472
BLAKE2b-256 checksum
How to use checksums
d79490cf635fc07e54b95e49d055998c8735c69ee39b891cd7371f57be89541b
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 Sep 26, 2026.

Transparency log

Release files / gffbase-0.2.1-cp310-abi3-win_amd64.whl

Download URL gffbase-0.2.1-cp310-abi3-win_amd64.whl
Size 472.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6f3d88eab43ae1165459d0ff5eea959dd9a6f40e368b7b4631ec1b131fb609a8
BLAKE2b-256 checksum
How to use checksums
36f285ea85479c89bf41e9b54c018777512d00a2525460922e4833781ba5141d
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 Sep 26, 2026.

Transparency log

Release files / gffbase-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL gffbase-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 562.9 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b738c2d4862b32d7115537f4066674bf6d425fae0fa4f3a2edcbd9ad9f9f2ac5
BLAKE2b-256 checksum
How to use checksums
5650d8e3f5eaafa007b0ad69ecc6276cd1995cfec2085d1802e0b0f2309c9c19
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 Sep 26, 2026.

Transparency log

Release files / gffbase-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL gffbase-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 556.6 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0999cec4c2356bb34cb0f684f340754bd943fab9ba4189794bf3ab25dea48cb3
BLAKE2b-256 checksum
How to use checksums
f4bae36ba871a8eb3020840408d6ee22b5ada45ce5d67e768e10e87fb4d0fe9a
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 Sep 26, 2026.

Transparency log

Release files / gffbase-0.2.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL gffbase-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Size 532.3 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8b8231388da25d26dbe9eeb860ddf83d720663618dee41e686ddb356dbd285d7
BLAKE2b-256 checksum
How to use checksums
ac052a12a3dad5997dd286c679cc833472f39ca81fd730cfc4d5667ff209d5a4
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 Sep 26, 2026.

Transparency log

Release files / gffbase-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL gffbase-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 538.8 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1e21bd12445d142523e3993ebc73df5fe6fdb0abd582f96d7b21be8adb9709de
BLAKE2b-256 checksum
How to use checksums
7fa177c440509983535f94ee527f9beeb0e8c652e3147ce7ad3d1745d2c2953d
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 Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

6 release files

This release

0.2.1 This release

6 release files

0.2.0

6 release files

0.1.0

6 release files

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