#bioinformatics #bam #sequencing #htslib #pileup

rust-htslib

This library provides HTSlib bindings and a high level Rust API for reading and writing BAM files

64 releases (breaking)

0.49.0 Dec 2, 2024
0.48.0 Nov 12, 2024
0.47.1 Nov 12, 2024
0.47.0 May 24, 2024
0.3.1 Mar 23, 2015

#2 in Biology

Download history 892/week @ 2024-08-22 811/week @ 2024-08-29 697/week @ 2024-09-05 772/week @ 2024-09-12 879/week @ 2024-09-19 1148/week @ 2024-09-26 720/week @ 2024-10-03 917/week @ 2024-10-10 893/week @ 2024-10-17 734/week @ 2024-10-24 694/week @ 2024-10-31 935/week @ 2024-11-07 1186/week @ 2024-11-14 1358/week @ 2024-11-21 1515/week @ 2024-11-28 1674/week @ 2024-12-05

5,954 downloads per month
Used in 55 crates

MIT license

1MB
19K SLoC

Crates.io Crates.io Crates.io docs.rs GitHub Workflow Status Coverage Status

HTSlib bindings for Rust

This library provides HTSlib bindings and a high level Rust API for reading and writing BAM files.

To clone this repository, issue

$ git clone --recursive https://github.com/rust-bio/rust-htslib.git

ensuring that the HTSlib submodule is fetched, too. If you only want to use the library, there is no need to clone the repository. Go on to the Usage section in this case.

Requirements

rust-htslib comes with pre-built bindings to htslib for Mac and Linux. You will need a C toolchain compatible with the cc crate. The build script for this crate will automatically build a link htslib.

Usage

Add this to your Cargo.toml:

[dependencies]
rust-htslib = "*"

By default rust-htslib links to bzip2-sys and lzma-sys for full CRAM support. If you do not need CRAM support, or you do need to support CRAM files with these compression methods, you can deactivate these features to reduce you dependency count:

[dependencies]
rust-htslib = { version = "*", default-features = false }

rust-htslib has optional support for serde, to allow (de)serialization of bam::Record via any serde-supported format.

Http access to files is available with the curl feature.

Beta-level S3 and Google Cloud Storge support is available with the s3 and gcs features.

rust-htslib can optionally use bindgen to generate bindings to htslib. This can slow down the build substantially. Enabling the bindgen feature will cause hts-sys to use a create a binding file for your architecture. Pre-built bindings are supplied for Mac and Linux. The bindgen feature on Windows is untested - please file a bug if you need help.

[dependencies]
rust-htslib = { version = "*", features = ["serde_feature"] }

For more information, please see the docs.

Alternatives

There's noodles by Michael Macias which implements a large part of htslib's C functionality in pure Rust (still experimental though).

Authors

For other contributors, see here.

License

Licensed under the MIT license https://opensource.org/licenses/MIT. This project may not be copied, modified, or distributed except according to those terms. Some test files are taken from https://github.com/samtools/htslib.

Dependencies

~10–23MB
~363K SLoC