Skip to content

NickRoz1/bam_parallel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallel BAM reader

This is a modificated, parallel version of noodles BAM reader written in Rust. The library also includes Rust rewrite of sambamba parallel sort. It currently supports 3 modes: sort by name, sort by name and match mates, sort by coordinate and strand.

Currently sort just dumps sorted stream records bytes into file. One can direct sorted stream into any other BAM writer and obtain sorted BAM file.

Installation

Add this to Cargo.toml:

[dependencies]
bam_parallel = { git = "https://github.com/NickRoz1/bam_parallel" }

Testing

bam_tools crate utilizes python script to do testing. To test bam_tools:

cargo build --release
python3 test.py

Usage

To read all records in BAM file and print them into stdout:

use bam_tools::Reader;

let mut bgzf_reader = Reader::new(reader, std::cmp::min(num_cpus::get(), 20));

bgzf_reader.read_header().unwrap();

let mut records = bgzf_reader.records();
while let Some(Ok(rec)) = records.next_rec() {
    println!("{:?}", rec);
}

To sort:

cargo build --release

# sort by name
./target/release/bam_binary -i -n test_files/input.bam -o test_files/out.bam 

# sort by name and match mates
./target/release/bam_binary -i -n -M test_files/input.bam -o test_files/out.bam 

# sort by coordinate and strand
./target/release/bam_binary -i test_files/input.bam -o test_files/out.bam 

About

Parallel BAM reader in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published