pybigtools

raw JSON →
0.2.5 verified Fri May 01 auth: no python

Python bindings to the Bigtools Rust library for high-performance BigWig and BigBed I/O. Version 0.2.5 (latest) focuses on reading and writing genomic interval files with performance comparable to the Rust implementation. Release cadence is irregular; the library is actively maintained.

pip install pybigtools
error AttributeError: module 'pybigtools' has no attribute 'read_bigwig'
cause API changed from read_bigwig to open in v0.2.0.
fix
Use 'from pybigtools import open' and call 'open(filename)'.
error TypeError: 'Bytes' object cannot be interpreted as an integer
cause Fetch returns values as bytes; expecting int list.
fix
Use '.tolist()' or specify dtype; ensure the region coordinates are correct.
breaking In pybigtools v0.1.x, the main function was named 'read_bigwig' instead of 'open'. Code written for v0.1.x must be updated.
fix Replace 'read_bigwig' with 'open' from pybigtools.
gotcha The 'open' function does not auto-detect file type; you must use the correct class (BigWig or BigBed) or rely on the context manager which returns a generic object with common methods. Manually constructing BigWig or BigBed objects is preferred for type safety.
fix Use 'from pybigtools import BigWig, BigBed' and instantiate directly: 'bw = BigWig('file.bw')' to get BigWig-specific methods.
gotcha File handles must be closed explicitly or used with 'with' statement; resources are not freed on garbage collection alone.
fix Always use 'with open(...) as f:' or call '.close()' on the object.

Open a BigWig file, list chromosomes, and fetch values over a region.

from pybigtools import open

with open('example.bw') as bw:
    print(bw.chroms)
    vals = bw.fetch('chr1', 1000000, 1000100)
    print(vals)