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.
Resources
- Homepage: https://github.com/rust-bio/rust-htslib
- API documentation: http://rust-bio.github.io/rust-htslib
- Continuous integration tests: https://travis-ci.org/rust-bio/rust-htslib
Usage
To use Rust-HTSlib in your Rust project, import the crate from your source code:
extern crate rust_htslib;
Rust-HTSlib provides a high level BAM API. Reading and writing BAM files is as easy as
use bam;
use Read;
let bam = new.ok.expect;
let mut out = with_template.ok.expect;
// copy reverse reads to new BAM file
for r in bam.records
Pileups can be performed with
use bam;
use Read;
let bam = new.ok.expect;
// pileup over all covered sites
for p in bam.pileup
In both cases, indexed BAM files can be seeked for specific regions, constraining either the record iterator or the pileups:
use bam;
let mut bam = new.ok.expect;
// seek to chr1:50000-100000
let tid = bam.header.tid.unwrap;
bam.seek.ok.expect;
// afterwards, read or pileup in this region
Authors
Contributors
License
Licensed under the MIT license http://opensource.org/licenses/MIT. This project may not be copied, modified, or distributed except according to those terms.