Rust API docs Crates.io

bam-builder

A library for easily building bams for testing.

Example

```rust use bambuilder::{bamorder::BamSortOrder, BamBuilder};

fn main() { // Create a builder with all defaults except the readlen is 100 let mut builder = BamBuilder::new( 100, // default read length 30, // default base quality "Pair".toowned(), // name of sample None, // optional read group id BamSortOrder::Unsorted, // how to sort reads when .sort is called None, // optional sequence dictionary None, // optional seed used for generating random bases );

// Create a builder for read pair spec
let records = builder
    .pair_builder()
    .contig(0)               // reads are mapped to tid 0
    .start1(0)               // start pos of read1
    .start2(200)             // start pos of read2
    .unmapped1(false)        // override default of unmapped
    .unmapped2(false)        // override default of unmapped
    .bases1("A".repeat(100)) // override default random bases with "A"s
    .bases2("C".repeat(100)) // override default random bases with "C"s
    .build()                 // inflate the underlying records and set mate info
    .unwrap();

// Add the pair to bam builder
builder.add_pair(records);

// Write records to a file
let tmp_file = builder.to_tmp().unwrap();

} ```