Skip to main content

A package for working with Bioinformatics data with SQL and Arrow

Project description

biobear

biobear is a Python library designed for reading and searching bioinformatic file formats, using Rust as its backend and producing Arrow Batch Readers and other downstream formats (like polars or duckdb).

The python package has minimal dependencies and only requires Polars. Biobear can be used to read various bioinformatic file formats, including FASTA, FASTQ, VCF, BAM, and GFF locally or from an object store like S3. It can also query some indexed file formats locally like VCF and BAM.

Release

Please see the documentation for information on how to get started using biobear.

Quickstart

To install biobear, run:

pip install biobear
pip install polars # needed for `to_polars` method

Create a file with some GFF data:

echo "chr1\t.\tgene\t1\t100\t.\t+\t.\tgene_id=1;gene_name=foo" > test.gff
echo "chr1\t.\tgene\t200\t300\t.\t+\t.\tgene_id=2;gene_name=bar" >> test.gff

Then you can use biobear to read a file:

import biobear as bb

session = bb.connect()
df = session.sql("""
    SELECT * FROM gff_scan('test.gff')
""").to_polars()

print(df)

This will print:

┌─────────┬────────┬──────┬───────┬───┬───────┬────────┬───────┬───────────────────────────────────┐
│ seqname ┆ source ┆ type ┆ start ┆ … ┆ score ┆ strand ┆ phase ┆ attributes                        │
│ ---     ┆ ---    ┆ ---  ┆ ---   ┆   ┆ ---   ┆ ---    ┆ ---   ┆ ---                               │
│ str     ┆ str    ┆ str  ┆ i64   ┆   ┆ f32   ┆ str    ┆ str   ┆ list[struct[2]]                   │
╞═════════╪════════╪══════╪═══════╪═══╪═══════╪════════╪═══════╪═══════════════════════════════════╡
│ chr1    ┆ .      ┆ gene ┆ 1     ┆ … ┆ null  ┆ +      ┆ null  ┆ [{"gene_id","1"}, {"gene_name","… │
│ chr1    ┆ .      ┆ gene ┆ 200   ┆ … ┆ null  ┆ +      ┆ null  ┆ [{"gene_id","2"}, {"gene_name","… │
└─────────┴────────┴──────┴───────┴───┴───────┴────────┴───────┴───────────────────────────────────┘

Using a Session w/ Exon

BioBear exposes a session object that can be used with exon to work with files directly in SQL, then eventually convert them to a DataFrame if needed.

See the BioBear Docs for more information, but in short, you can use the session like this:

import biobear as bb

session = bb.connect()

session.sql("""
CREATE EXTERNAL TABLE gene_annotations_s3 STORED AS GFF LOCATION 's3://BUCKET/TenflaDSM28944/IMG_Data/Ga0451106_prodigal.gff'
""")

df = session.sql("""
    SELECT * FROM gene_annotations_s3 WHERE score > 50
""").to_polars()
df.head()
# shape: (5, 9)
# ┌──────────────┬─────────────────┬──────┬───────┬───┬────────────┬────────┬───────┬───────────────────────────────────┐
# │ seqname      ┆ source          ┆ type ┆ start ┆ … ┆ score      ┆ strand ┆ phase ┆ attributes                        │
# │ ---          ┆ ---             ┆ ---  ┆ ---   ┆   ┆ ---        ┆ ---    ┆ ---   ┆ ---                               │
# │ str          ┆ str             ┆ str  ┆ i64   ┆   ┆ f32        ┆ str    ┆ str   ┆ list[struct[2]]                   │
# ╞══════════════╪═════════════════╪══════╪═══════╪═══╪════════════╪════════╪═══════╪═══════════════════════════════════╡
# │ Ga0451106_01 ┆ Prodigal v2.6.3 ┆ CDS  ┆ 2     ┆ … ┆ 54.5       ┆ -      ┆ 0     ┆ [{"ID",["Ga0451106_01_2_238"]}, … │
# │ Ga0451106_01 ┆ Prodigal v2.6.3 ┆ CDS  ┆ 228   ┆ … ┆ 114.0      ┆ -      ┆ 0     ┆ [{"ID",["Ga0451106_01_228_941"]}… │
# │ Ga0451106_01 ┆ Prodigal v2.6.3 ┆ CDS  ┆ 1097  ┆ … ┆ 224.399994 ┆ +      ┆ 0     ┆ [{"ID",["Ga0451106_01_1097_2257"… │
# │ Ga0451106_01 ┆ Prodigal v2.6.3 ┆ CDS  ┆ 2261  ┆ … ┆ 237.699997 ┆ +      ┆ 0     ┆ [{"ID",["Ga0451106_01_2261_3787"… │
# │ Ga0451106_01 ┆ Prodigal v2.6.3 ┆ CDS  ┆ 3784  ┆ … ┆ 114.400002 ┆ +      ┆ 0     ┆ [{"ID",["Ga0451106_01_3784_4548"… │
# └──────────────┴─────────────────┴──────┴───────┴───┴────────────┴────────┴───────┴───────────────────────────────────┘

Ecosystem

BioBear aims to make it simple to move easily to and from different prominent data tools in Python. Generally, if the tool can read Arrow or Polars, it can read BioBear's output. To see examples of how to use BioBear with other tools, see:

Performance

Please see the exon's performance metrics for thorough benchmarks, but in short, biobear is generally faster than other Python libraries for reading bioinformatic file formats.

For example, here's quick benchmarks for reading one FASTA file with 1 million records and reading 5 FASTA files each with 1 million records for the local file system on an M1 MacBook Pro:

Library 1 file (s) 5 files (s)
BioBear 4.605 s ± 0.166 s 6.420 s ± 0.113 s
BioPython 6.654 s ± 0.003 s 34.254 s ± 0.053 s

The larger difference multiple files is due to biobear's ability to read multiple files in parallel.

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

biobear-0.23.2.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

biobear-0.23.2-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (20.1 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

biobear-0.23.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.2 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

biobear-0.23.2-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (20.1 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

biobear-0.23.2-cp312-none-win_amd64.whl (20.8 MB view details)

Uploaded CPython 3.12Windows x86-64

biobear-0.23.2-cp312-cp312-manylinux_2_28_aarch64.whl (20.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

biobear-0.23.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

biobear-0.23.2-cp312-cp312-macosx_11_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

biobear-0.23.2-cp312-cp312-macosx_10_12_x86_64.whl (20.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

biobear-0.23.2-cp311-none-win_amd64.whl (20.8 MB view details)

Uploaded CPython 3.11Windows x86-64

biobear-0.23.2-cp311-cp311-manylinux_2_28_aarch64.whl (20.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

biobear-0.23.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

biobear-0.23.2-cp311-cp311-macosx_11_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

biobear-0.23.2-cp311-cp311-macosx_10_12_x86_64.whl (20.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

biobear-0.23.2-cp310-none-win_amd64.whl (20.8 MB view details)

Uploaded CPython 3.10Windows x86-64

biobear-0.23.2-cp310-cp310-manylinux_2_28_aarch64.whl (20.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

biobear-0.23.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

biobear-0.23.2-cp39-none-win_amd64.whl (20.8 MB view details)

Uploaded CPython 3.9Windows x86-64

biobear-0.23.2-cp39-cp39-manylinux_2_28_aarch64.whl (20.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

biobear-0.23.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file biobear-0.23.2.tar.gz.

File metadata

  • Download URL: biobear-0.23.2.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for biobear-0.23.2.tar.gz
Algorithm Hash digest
SHA256 200ce4f40bbdfffdb355764052365d4e3fbbede8e76c124aeb23b0a5104a235c
MD5 6184663fc849303ca61363ecdc8bf924
BLAKE2b-256 ca600ad00951f149efed8d222042a3b2d484688f6880ad1afc2111ff4228a392

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bcb5ca9fc44bb1dfa34ceb1887af68a9695270933b3837aba31e1c666024133d
MD5 b2456817867313d10604cc3c9ea0cdf1
BLAKE2b-256 485fccad810b6c2750b77b1ff4879b7ba8f9197ad6b5f9f64a7fd908e5dcdc1f

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55d6dccaaf831e746abc784e0f29e689cbd797140ab284e46769c2e87f9ba684
MD5 a04fd74c51dcadc7cb65ab8c6c27efc5
BLAKE2b-256 73d5c9297a55aaf323be5df3bdc548037bc16db094bb68b37cb157ab1bf0fcb5

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 68223c3bc6e7a4ab48a1059976ba9897dbd9d92c14f9ebc5b7e66a7ffb20da2f
MD5 199149a2d944108e3a194390d88deb77
BLAKE2b-256 4d355aeca819750aec45c5ad187bb1c23d549f9a05abe0e01f6cd0e381d56eb1

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp312-none-win_amd64.whl.

File metadata

  • Download URL: biobear-0.23.2-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 20.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for biobear-0.23.2-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 e82ccff166ad3260732b8f5d0a979980687b1ea65f54810995e42eba79170aee
MD5 ce82bc0535b86fc3f41acf897ba3ec82
BLAKE2b-256 3e213c282e21b8efbe1dce41fd322447c57d6585910c8381b735974281e40b0f

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e75ace20d248039a6b88eb463667f08dd4a9fdb673ad04f9d15805a685f68ad4
MD5 45de7712f19e6582f7232f912cded813
BLAKE2b-256 f89202b9a21b2101b48cfc8bc4f8bafb1910277a7fb9d1cb737132c055c19b6d

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b33fa4bef873a3254addc6b6ca6edd01fef582500998d40e0eb44b74c1d205e
MD5 7b7ac59b731f607589dc0758ad8f9e54
BLAKE2b-256 2c4d53087c1e360a4e0461eaa8e15f99169806b222d7116c57fd999b7b503bc1

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb7e083e4cac418da74f66a0977c6606dc730aa63cf9c2e4782e8991a9c3fcbb
MD5 499f537c01871fa9e4b166d6c01915ab
BLAKE2b-256 73b4a7aee3ead068816213020d442b8df40fd197ffce7ab1fb4539f2b5133755

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cbe2fb1ab57282b0a76ffea532cafcf50fe8af86aa02049353a4600351c18437
MD5 43031f66027243d8e84c6f866a498e45
BLAKE2b-256 6694660c96a50ee6a087fe2a6a64a7211f18d224694e7cc4a63496b1d494bdf0

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp311-none-win_amd64.whl.

File metadata

  • Download URL: biobear-0.23.2-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 20.8 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for biobear-0.23.2-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 0b277bae2eb130e8a4f14fbab1286ed2ce1f1ad0936c183966977924ac44d31a
MD5 61e9ad5bc9f85048adafdde4694d33f7
BLAKE2b-256 7d079ca0298168701c12e97a49129833b332a2b2ace4fcb693867a5f661e6d0d

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1b178dff7ec79724ad1cdf445f5ecf9a93e381e0a4d09d5bc9d6037697871ce2
MD5 dd5e5a44725045d98dd3465fe008c806
BLAKE2b-256 8d953763232ad45f063273649c7cc036575ac12dbc4fe373a97770af1bcdff3f

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67570d0738c469eba14d0756b3a4af72af5f9bd8d43ba419002e731f1dd0af2c
MD5 911d971486aabcc90ca34f4cb9c1d70b
BLAKE2b-256 84171af81d9fa24913f0d62d9bdc53656819df3135f656f4860d63c4e5782c71

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a77a0bff007d06cd96651974167febcd847d949652bc689f07ae7a9a8caac36f
MD5 90270a0b9b193fa69e63122b30a8d909
BLAKE2b-256 6247a08464fd4893e616dbc4af776ef05a4ff7371248f6d5a8fdb8c8beedab19

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 65c462c646fbd313c15af9987c50721d28be451e1a492e3d9dce1c13c904ca41
MD5 dbdf50a9e9bb1904dbed72b34b61a358
BLAKE2b-256 ce6dfde1ab61fc8ed7bd44072d156d380044f7830c0b26874e72f2dace7c4e8e

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp310-none-win_amd64.whl.

File metadata

  • Download URL: biobear-0.23.2-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 20.8 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for biobear-0.23.2-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 af6e162cf469cd8d26f0bbfbd0d6daf6dd0ca5e7ac9b76e983d9b8e7aae4a964
MD5 a03ddc8ef27d558add8197d3c9e56f52
BLAKE2b-256 149b51147e0b40ea4d4d7109599a099d1193f79d21909b32fad6fbdd4db2be0b

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 be30febf8fe74acfd11a0d3896d211d1b386677a6152e2bd03eefd2c43340b14
MD5 457ebeb7833186d6e349c2eacebba5a9
BLAKE2b-256 595df232696d2f80af0c43f12ae09e35e84e68ecd736b79998530502106011b6

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24bb335e44c1a53b174df8104adc9eaa69d98e03f9d7521a98b777a8ef80eb90
MD5 ebc3318bd91f5d0f0bc796e9a11a06e9
BLAKE2b-256 8f1a1ea8d70a7f1a254b8a08ebd9156663a87539fdb97f8562b147e48045bb33

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp39-none-win_amd64.whl.

File metadata

  • Download URL: biobear-0.23.2-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 20.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for biobear-0.23.2-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 82b8b63038a848a9fc928eac8b3200dffb82e1ad201b175b0421b6a58d8c0de6
MD5 23f3956e619d714fc9e0569f69d03623
BLAKE2b-256 9373ff284f50d09fe32c9fcd704a732f42003c94d261f5dd44ccf322d675527d

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp39-cp39-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f3bcef7af4307fa6b032f234229dbbf73d1cd68573510def0c16a06fb7a45a73
MD5 be8217600cb4bd8706c7c1ea00b2458e
BLAKE2b-256 96827efb2e564f62f2eec59f692741b84c7e78f6f40ee03d54ef3fbc7857b235

See more details on using hashes here.

File details

Details for the file biobear-0.23.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for biobear-0.23.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2357c36a743468174c5fb94c861ae4d97995d034c206875cfb58570ecec0ac0c
MD5 bc6453e8bbf22933be22cdfcc03feec5
BLAKE2b-256 7c40d74b2e94ec68dcbf54b3293a2d38662d25fe6d8775d2a1ce88632df8abef

See more details on using hashes here.

Supported by

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