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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for cbgen-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d90e1eff682b318ef5f57604232a87c8cf4bf6353040c744367e175721b5cb2 |
|
MD5 | ef576ea4b9e3fb83564855c32fd31127 |
|
BLAKE2b-256 | 1ba3acfe3a6f5435e18980972ce2d9339fe2b551dad97259e7a0341718eb7f3a |
Hashes for cbgen-1.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6dcfa70bee6d4ef284558ae73868035f39dfbdc2dde486e7df8c366e656315 |
|
MD5 | 02910818ef222cc1c29737b4a43f7ef9 |
|
BLAKE2b-256 | 304a9fd043c58b09657d4743251ceca85ff12c8c4c1fea55525d8e140abae1e2 |
Hashes for cbgen-1.0.2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e5d8a0acde4b0e866accd3d1e3b35eb12a29d31af40545e4a8d6656ec87dcd8 |
|
MD5 | 390eb5de9e9c0022944070d516864f9c |
|
BLAKE2b-256 | 6f21773f51e731709ad02164ed45419dcc598790d6a180b11b9ca8561156739f |
Hashes for cbgen-1.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e39c978c23cec8fcd261c45f8cbb1eaef50b12e82bee1105c7a179cbb1f513bb |
|
MD5 | 8b3296b799c00482586f1f0305d6f92c |
|
BLAKE2b-256 | cb9c0c6a815c283dfd495e9b2cec8c20d0c020b3aec4c9bb2161b095f154ceec |
Hashes for cbgen-1.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce51355437b3a83a685d53f98b7db2c751a11a89a7f373bd7e22008ec379fe93 |
|
MD5 | d44100be7698b5254bdef85dceb51bb2 |
|
BLAKE2b-256 | 71e4ff4274faabca0d669d640bd7849f027bf044865057b77f1e8503abbf4127 |
Hashes for cbgen-1.0.2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b170f50ba8965304fa8b37f9fcb533e0fc1e14218b2513c7ef412e408f9962a |
|
MD5 | ed1afd8bc6ce7694055b76877e1894a8 |
|
BLAKE2b-256 | 80c3b43eb626ebf4b74b84c0b7f28442753e66f1322902af1f89364d992334f2 |
Hashes for cbgen-1.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb019a8bc1a9909b48802e978a961443dcc2868a36192bd5ded42106712712f8 |
|
MD5 | 549f38ba1bde73d9b7f74fec0edb846a |
|
BLAKE2b-256 | 479cfa5aff541c54d12117ed7999bac656ac928728d31c5241de8796553bed8f |
Hashes for cbgen-1.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbadacba89c3ba3004ee64f52ebf840fb721b1a4751aecb2f6ad6b9498927a59 |
|
MD5 | ec63ef1d5fb02b4e4447c0b4f2166311 |
|
BLAKE2b-256 | 8c5ed9667d2086af3a86a4c769003572ca44128793db564a47c7cd21657c25a1 |
Hashes for cbgen-1.0.2-cp38-cp38-macosx_10_16_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62b22b145f5172bc0e18ec681c4f51dd39a3dd15222a953df192084e2e1eba7d |
|
MD5 | 7cdde20b6f20b284770fd6ac4b354c1a |
|
BLAKE2b-256 | feba9035c57eb755c2f8a11fb961e6c3961b71e17d1895783bcb3b4358dfe464 |