Install & Compatibility
Where this runs
tested against v1.9.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 102.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.5s · import 0.000s · 96MB
101MB installed
● package 101MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BgenReader
✓ from bgen import BgenReader
✗ from bgen import BGENFile
BgenVar
✓ from bgen import BgenVar
BgenWriter
✓ from bgen import BgenWriter
Open a BGEN file and read basic information and variant genotypes.
from bgen import BGENFile
# Replace with your actual BGEN file path
bgen = BGENFile('example.bgen')
# Get number of samples
print('Number of samples:', bgen.nsamples)
# Get number of variants
print('Number of variants:', bgen.nvariants)
# Iterate over first 5 variants
for i, variant in enumerate(bgen):
if i >= 5:
break
print('Variant:', variant.rsid, variant.chromosome, variant.position)
# Access genotype probabilities (3D array: samples x alleles x ploidy)
probs = variant.genotype()
print('Genotype probs shape:', probs.shape)
Upgrade
Version history
1.9.10latest on PyPI · released May 25, 2026
Audit
Dependencies
numpyrequiredRequired for array operations.
cythonoptionalRequired for building from source if wheel not available.