Skip to main content

bgen

C library and Python bindings for reading BGEN files (format specifications 1.2 and 1.3).

This repository is a maintained fork of the original limix/bgen and limix/cbgen projects, merged into a single codebase with a modern build system, nanobind-based Python bindings, and S3 support.

Features

  • Fast C library for parsing BGEN genotype files
  • Python bindings via nanobind
  • Supports BGEN 1.2 and 1.3 format specifications
  • zlib and zstd decompression support
  • Metafile indexing for efficient random access

Quick start (pixi)

pixi install
pixi run test

Building the C library

cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure

System dependencies: zlib, zstd (installed via your system package manager or conda).

Installing the Python package

pip install .

Or in development mode:

pip install -e ".[test]"
pytest python/tests

Python usage

from cbgen import BgenFile, BgenMetafile

# Open a BGEN file
with BgenFile("example.bgen") as bgen:
    print(f"Variants: {bgen.nvariants}, Samples: {bgen.nsamples}")

    if bgen.contain_samples:
        samples = bgen.read_samples()

    # Create a metafile index for efficient access
    bgen.create_metafile("example.bgen.metafile")

# Read variant data via metafile
with BgenFile("example.bgen") as bgen:
    with BgenMetafile("example.bgen.metafile") as mf:
        partition = mf.read_partition(0)
        for variant in partition.variants:
            gt = bgen.read_genotype(variant.offset)
            print(f"{variant.rsid}: {gt.probability.shape}")

C API

Link against the bgen library:

find_package(bgen REQUIRED)
target_link_libraries(mytarget PRIVATE BGEN::bgen)

See include/bgen/bgen.h for the full C API.

Acknowledgments

  • Marc Jan Bonder for bug-reporting and improvement suggestions.
  • Yan Wong for bug-reporting and improvement suggestions.
  • Carl Kadie for bug-reporting and improvement suggestions.

Authors

License

This project is licensed under the MIT License.

Metadata

Release files for bgen-limix 4.10.2

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

Source distribution (sdist)

Source distribution for bgen-limix 4.10.2
File Size Uploaded
bgen_limix-4.10.2.tar.gz 4.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for bgen-limix 4.10.2
File
bgen_limix-4.10.2-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
bgen_limix-4.10.2-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
bgen_limix-4.10.2-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
bgen_limix-4.10.2-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 18.4 MB

Release files / bgen_limix-4.10.2.tar.gz

Download URL bgen_limix-4.10.2.tar.gz
Size 4.9 MB
Tags Source
SHA-256 checksum
How to use checksums
48a0759d7e787bb49807f10fd74cb7ef0b18e327f32235555953a2d27690b998
BLAKE2b-256 checksum
How to use checksums
0cba7f95b1deb99f1b6e7a73092d4758149719efb74b6ff3b569dc70d8cef877
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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

Transparency log

Release files / bgen_limix-4.10.2-cp311-abi3-win_amd64.whl

Download URL bgen_limix-4.10.2-cp311-abi3-win_amd64.whl
Size 3.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
957d93870438fa1b29b5ecc7e8deb03fb2596b70b9a0ccf7782fd72bd6c61c43
BLAKE2b-256 checksum
How to use checksums
f9054cf37c32d4406b1bb4e5f1760dd5c1efa9080ac21a0ed1cf843c1d6e41b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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

Transparency log

Release files / bgen_limix-4.10.2-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL bgen_limix-4.10.2-cp311-abi3-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
22656ab56133641a5edff54bc96c0f8c117aa66e7a563a2a08a47889f49e6d55
BLAKE2b-256 checksum
How to use checksums
5e1f69ddeaa0abe697c8943394626167b0d1e0bcc3e4a3fb4818ce3c751889f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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

Transparency log

Release files / bgen_limix-4.10.2-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL bgen_limix-4.10.2-cp311-abi3-manylinux_2_28_aarch64.whl
Size 4.0 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
03fe96d828b2fd1c7f94367d5fcc7b15e7ed4d30b543397b5fdf3af5e2d50b03
BLAKE2b-256 checksum
How to use checksums
fa43d245c160114770ff77691199ec8bcef083e97eef2af8becd7cba2fa47ec8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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

Transparency log

Release files / bgen_limix-4.10.2-cp311-abi3-macosx_11_0_arm64.whl

Download URL bgen_limix-4.10.2-cp311-abi3-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
110e02c4804287c4d0c57e29c7a163b3328dd5f2cfd6cb9613ebdf31c5e51e36
BLAKE2b-256 checksum
How to use checksums
9bccca1c88bda315d5d6adccd41faa5473da3731af2cf3995208ac63cf9da1fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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

Transparency log

Release history Release notifications | RSS feed

4.12.0

5 release files

4.11.0

5 release files

This release

4.10.2 This release

5 release files

4.10.1

5 release files

4.10.0

5 release files

4.9.1

5 release files

4.8.3

5 release files

4.8.2

5 release files

4.8.1

5 release files

4.8.0

5 release files

4.7.5

5 release files

4.7.4

5 release files

4.7.3

5 release files

4.7.2

5 release files

4.7.1

5 release files

4.4.0

5 release files

4.3.0

5 release files

4.2.1

5 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