Skip to main content

Python bindings to UCSC Big Binary (bigWig/bigBed) file library

Project description

pybbi

Python interface to Jim Kent's big binary file (bbi) [1] library from the UCSC Genome Browser source tree using Cython.

This provides read-level access to local and remote bigWig and bigBed files but no write capabilitites. The main feature is fast retrieval of range queries into numpy arrays.

Installation

Wheels for pybbi are available on PyPI for Pythons 3.5, 3.6, 3.7, 3.8 on Linux and Mac OSX.

$ pip install pybbi

API

Introspection

These accept a local file path or URL.

  • bbi.is_bbi(path) --> bool
  • bbi.is_bigwig(path) --> bool
  • bbi.is_bigbed(path) --> bool
  • bbi.chromsizes(path) --> OrderedDict
  • bbi.zooms(path) --> list
  • bbi.info(path) --> dict

Array output

These accept either a bigWig or bigBed file path / URL. The signal of a bigBed file is the genomic coverage of its intervals.

For a single range query:

  • bbi.fetch(path, chrom, start, end, [bins [, missing [, oob, [, summary]]]]) --> 1D numpy array

For a list of equal-length segments (i.e. to produce a stacked heatmap):

  • bbi.stackup(path, chroms, starts, ends, [bins [, missing [, oob, [, summary]]]]) --> 2D numpy array

Summary querying is supported by specifying the number of bins for coarsegraining. The summary statistic can be one of: 'mean', 'min', 'max', 'cov', or 'std'. (default = 'mean').

Missing data can be filled with a custom fill value, missing (default = 0).

Out-of-bounds ranges (i.e. start less than zero or end greater than the chromosome length) are permitted because of their utility e.g., for generating vertical heatmap stacks centered at specific genomic features. A separate custom fill value, oob can be provided for out-of-bounds positions (default = NaN).

Interval output

Accepts either a bigWig or bigBed file path / URL.

  • bbi.fetch_intervals(path, chrom, start, end) --> iterator

See the docstrings for complete documentation.

Related projects

  • libBigWig: Alternative C library for bigWig and bigBed files by Devon Ryan
  • pyBigWig: Python bindings for libBigWig by the same author
  • bw-python: Alternative Python wrapper to libBigWig by Brent Pederson
  • bx-python: Python bioinformatics library from James Taylor's group that includes tools for bbi files.

This library provides bindings to the reference UCSC bbi library code. Check out @dpryan79's libBigWig for an alternative and dedicated C library for big binary files. pyBigWig also provides numpy-based retrieval and bigBed support.

References

[1]: http://bioinformatics.oxfordjournals.org/content/26/17/2204.full

From source

If wheels for your platform or Python version aren't available or you want to develop, you'll need to install pybbi from source. The source distribution on PyPI ships with (slightly modified) kent utils source, which will compile before the extension module is built.

Requires

  • Linux/MacOS
  • C compiler, zlib, pthreads, libpng, openssl, make
  • Python 2.7/3.4+
  • numpy and cython

On fresh Ubuntu instance, you'll need build-essential, make, zlib1g-dev, libssl-dev, libpng16-dev. It seems to work on the Windows Subsystem for Linux too.

On a Centos/RedHat (rpm) system you'll need gcc, make, zlib-devel, openssl-devel, libpng-devel.

For development, clone the repo and install in editable mode:

$ git clone https://github.com/nvictus/pybbi.git
$ cd pybbi
$ pip install -e .

Troubleshooting

On OSX, you may get errors about missing header files (e.g., png.h, openssl/sha.h), which even if installed may not be located in standard include locations. Either create the required symlinks or update the C_INCLUDE_PATH environment variable accordingly before installing pybbi.

export C_INCLUDE_PATH="/usr/local/include/libpng:/usr/local/opt/openssl/include:$C_INCLUDE_PATH"

Notes

Unfortunately, Kent's C source is not well-behaved library code, as it is littered with error calls that call exit(). pybbi will catch and pre-empt common input errors, but if somehow an internal error does get raised, it will terminate your interpreter instance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybbi-0.2.2.tar.gz (21.4 MB view details)

Uploaded Source

Built Distributions

pybbi-0.2.2-cp38-cp38-manylinux2010_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pybbi-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pybbi-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

pybbi-0.2.2-cp37-cp37m-macosx_10_6_intel.whl (1.4 MB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

pybbi-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

pybbi-0.2.2-cp36-cp36m-macosx_10_6_intel.whl (1.5 MB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

pybbi-0.2.2-cp35-cp35m-manylinux2010_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

pybbi-0.2.2-cp35-cp35m-macosx_10_6_intel.whl (1.4 MB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

File details

Details for the file pybbi-0.2.2.tar.gz.

File metadata

  • Download URL: pybbi-0.2.2.tar.gz
  • Upload date:
  • Size: 21.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2859e9e9cb4415dcaada6c1183c14b33d9f57020af0a038f1f3e1fb2d77c9bca
MD5 d32f8ae3950e92126c8983d5d6845ce9
BLAKE2b-256 a6fe2048d44782ac1048e92eafd28107f645c5991a23cc9f980968f01dcc5a0a

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a32142c114257d12a0f66b3e9afdeca90b592f79b83d9a0695afeea2ae0c5228
MD5 5f7744b49f785469f2461a67d025f871
BLAKE2b-256 cd090e7c795b6d467aaa6b63d9f8e0d4cf79004837a89b5f601406c93c0505e2

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c3c1fa417791bbda96fd0418876ad07ebcb391346774490af679fa77e85b0c11
MD5 3c4239f00ceff97f9f36390a828c4dd6
BLAKE2b-256 ae1ef4d4d6a7fe9ce50bf2ec4146728f0de1239058d8b9225e4beb136a47d089

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5a5952f65e51bd3b6d06138a1bb8d1a8dc81af931883c5c0e8fb12bb61c92118
MD5 971174a20ba6ba8f1b296a01744f49ba
BLAKE2b-256 f0f964b7f011d1e3f06f731fd85500a7faf3dc71de4a5d1f2d3c13b15fd697d1

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 693b730035137e0735635d357a5cde17679e579e142edc24ec4bc272057dbd0f
MD5 467072c32a2410bcb9d4e976f3e98296
BLAKE2b-256 07285502a4bd47bfab0f1fa3ec91b070c74d2ef4c5b6e6908c8f87a5d314e010

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 decc17c1812bdb8e42c48ade60f5159b9b8402d5163e71fb1556593fd91930c9
MD5 19ff03fa462813f37b18fa3a2dd24aa6
BLAKE2b-256 933daedbba1b7e1ad158818e9183ddd72b6029b6a68188bb3c1a61c05106a82b

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.6m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 b8f01f715d716650bd4b7312f96c7408b4961c7ff8f4416818ba48f1c6584c70
MD5 6de1590df55f7d5a9605a9c651664d73
BLAKE2b-256 b1252a9b7b248f103d91503e47f58d2797a5cf8348878d4d580afbdf5e9810de

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c63012a20e4b8bb22970d1a02048fda25b7789e4f3c3de686ed991afba114b56
MD5 189759a8553febe3ffd9283f0ce52dff
BLAKE2b-256 3c1988672d00720051e1c66ce3bb5b8b4ce2f8b779bf2f8d19be107ae8351509

See more details on using hashes here.

File details

Details for the file pybbi-0.2.2-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pybbi-0.2.2-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.5m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for pybbi-0.2.2-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 86d288d109b6417bf883a63bdc420c25c0061b5602524707273cc8920933f1e2
MD5 614a66056b7296f386d557fcadb9d0ee
BLAKE2b-256 ce1c5288e14aa29b8c5c3c90828c79e66a31be101b789ad098de9105340b00e2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page