#htslib #bam #bioinformatics #pileup #sequencing


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

40 releases (breaking)

✓ Uses Rust 2018 edition

new 0.30.0 Apr 3, 2020
0.29.0 Mar 26, 2020
0.28.0 Mar 26, 2020
0.26.1 Dec 3, 2019
0.3.1 Mar 23, 2015

#8 in Science

Download history 413/week @ 2019-12-14 243/week @ 2019-12-21 189/week @ 2019-12-28 377/week @ 2020-01-04 266/week @ 2020-01-11 382/week @ 2020-01-18 170/week @ 2020-01-25 103/week @ 2020-02-01 273/week @ 2020-02-08 229/week @ 2020-02-15 370/week @ 2020-02-22 116/week @ 2020-02-29 222/week @ 2020-03-07 287/week @ 2020-03-14 402/week @ 2020-03-21 129/week @ 2020-03-28

1,099 downloads per month
Used in 8 crates

MIT license

15K SLoC

Crates.io Crates.io Crates.io docs.rs GitHub Workflow 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.


To compile this crate you need the development headers of zlib, bzip2 and xz. For instance, in Debian systems one needs the following dependencies:

$ sudo apt-get install zlib1g-dev libbz2-dev liblzma-dev clang

On OSX, this will take a significant amount of time due to musl cross compiling toolchain:

$ brew install FiloSottile/musl-cross/musl-cross
$ brew install bzip2 zlib xz curl-openssl


Add this to your Cargo.toml:

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:

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

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

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

For more information, please see the docs.


For other contributors, see here.


Licensed under the MIT license http://opensource.org/licenses/MIT. This project may not be copied, modified, or distributed except according to those terms.


~265K SLoC