Skip to main content

Python wrapper around a BGEN library

Project description

cbgen

Python wrapper around a BGEN library. (cbgen documentation).

BGEN is a file format for storing large genetic datasets. It supports both unphased genotypes and phased haplotype data with variable ploidy and number of alleles. It was designed to provide a compact data representation without sacrificing variant access performance. This Python package is a wrapper around the bgen library, a low-memory footprint reader that efficiently reads bgen files. It fully supports the bgen format specifications: 1.2 and 1.3; as well as their optional compressed formats.

Installation

pip install cbgen

Usage example

>>> import cbgen
>>>
>>> bgen = cbgen.bgen_file(cbgen.example.get("haplotypes.bgen"))
>>> bgen.create_metafile("haplotypes.bgen.metafile")
>>> mf = cbgen.bgen_metafile("haplotypes.bgen.metafile")
>>> print(mf.npartitions)
1
>>> print(mf.nvariants)
4
>>> print(mf.partition_size)
4
>>> part = mf.read_partition(0)
>>> gt = bgen.read_genotype(part.variants.offset[0])
>>> print(gt.probability)
[[1. 0. 1. 0.]
 [0. 1. 1. 0.]
 [1. 0. 0. 1.]
 [0. 1. 0. 1.]]
>>> mf.close()
>>> bgen.close()

Authors

License

This project is licensed under the MIT License.

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

cbgen-1.0.4.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distributions

cbgen-1.0.4-cp311-cp311-win_amd64.whl (305.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

cbgen-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (775.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

cbgen-1.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (679.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

cbgen-1.0.4-cp311-cp311-macosx_11_0_x86_64.whl (562.0 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ x86-64

cbgen-1.0.4-cp310-cp310-win_amd64.whl (232.6 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

cbgen-1.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (585.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

cbgen-1.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (513.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

cbgen-1.0.4-cp310-cp310-macosx_11_0_x86_64.whl (425.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ x86-64

cbgen-1.0.4-cp39-cp39-win_amd64.whl (160.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

cbgen-1.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (395.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

cbgen-1.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (347.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

cbgen-1.0.4-cp39-cp39-macosx_11_0_x86_64.whl (288.4 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

cbgen-1.0.4-cp38-cp38-win_amd64.whl (87.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

cbgen-1.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (205.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

cbgen-1.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (181.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

cbgen-1.0.4-cp38-cp38-macosx_11_0_x86_64.whl (151.6 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ x86-64

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