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 2.7, 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.1.tar.gz (21.4 MB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pybbi-0.2.1-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.1-cp37-cp37m-manylinux2010_x86_64.whl (2.5 MB view details)

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

pybbi-0.2.1-cp37-cp37m-macosx_10_6_intel.whl (1.5 MB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

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

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

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

Uploaded CPython 3.6m macOS 10.6+ intel

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

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

pybbi-0.2.1-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.1.tar.gz.

File metadata

  • Download URL: pybbi-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b37c55bc7bd7254cd94ebf46a83cd9f27de01836e5cc131b1b4feb4cb79b2288
MD5 f7995fed70e4319b9e55e6984d44aeb7
BLAKE2b-256 85df221c03b18221d653b6cf6d387b2263c9855ab98e7708b9ba867c727a6c41

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f500d82c2ba85e1a614e54302c3a87869425fb5a23497199f8183f9634e34d41
MD5 42dd925bb3d98f6cd3b79344b583487f
BLAKE2b-256 097c802198575fd21e0335911255c0ec821032b1685f863a0990078b8a9fd19e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9b019545c217bd89ebb0d44635e93856af48bda25e39a36f12db388178b4eed6
MD5 90b134d1bbdd13df46e2e5c0600dd550
BLAKE2b-256 15cb837cd0b7cb7a6dade10d2c0ec139ecd8dc3bf1afe7851f0bd3ceae2f782f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cce9d35532aeccd2ffbf47b459a7887c778f8b0efbf4109ca21d798fce83b34c
MD5 ca80d5a9d77ac9395018323fd26a4d2b
BLAKE2b-256 c0bd77a84a72d458795402ff151a1eda5ea1a5d4d2404f22a291015204e34b73

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 33ebe2322f9f59f4b4235f1e7a512df5f829466c198452d412f57797383d351c
MD5 9d020ec54ef8f0f4c3e8053ae7591645
BLAKE2b-256 1b37b69b5b5212bb37f8dba472dec9dbde2814144652228d64c1946c6b2e4dc8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a6691ffa2f8c84e26b047675eb126337d03f702a07fcfd818cfa3284354d7a35
MD5 18bc2c298756783433d0709e2677a595
BLAKE2b-256 9c9b564b771ef0e8283c39aad7333a2d5fc23f7f53891f5a36e4b38d16050ed2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 e8871b33899f9ca4eb8d725b735e91b67b27f80a3affa3a047b13b6df0936fe1
MD5 c4ecce6f6e97e75433c19049821f5370
BLAKE2b-256 7b5fe16e23d918a278239339ffeefea866bf90279d9103de4db9965c5c166f16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 846fc4e0044dc5fa943dc2b5094136c9ec149f1f567b9a9c28d340f1905b96ea
MD5 c2142429c65dee62a74f5a30f00f616b
BLAKE2b-256 d79964b03eafbebda17ac170298602e79ce5a24caa60108193334a05f2fb90cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybbi-0.2.1-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.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pybbi-0.2.1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 37480c3a19716b2cf0419b669505b1f888a07f75d3821ca6232a221f1115261e
MD5 91742750d05069ed24249b24f7c5ab0e
BLAKE2b-256 b592292a7721469f8b8672b07cc46dcaeca60c6bbb08e6708e0612eeb4fc5ac8

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