[][src]Struct bam_builder::BamBuilder

pub struct BamBuilder {
    pub read_length: usize,
    pub base_quality: u8,
    pub sample_name: SampleName,
    pub read_group_id: ReadGroupId,
    pub sort_order: BamSortOrder,
    pub header: Header,
    pub rng: StdRng,
    pub records: Vec<Record>,
    pub default_quals: String,
    pub counter: usize,
}

Builder for BAM records.

Sets up defaults for reads that are added as well as the BAM header information. Use BamBuilder::new to generate a BamBuilder with appropriately populated fields.

The pattern of interaction with BamBuilder is to use the BamBuilder::frag_builder and BamBuilder::pair_builder methods to create a respective ReadFragSpecBuilder and ReadPairSpecBuilder. The *SpecBuilder is creates a record with its .build() method, and the result can be added to the builder with BamBuilder::add_pair or BamBuilder::add_frag.

Fields

read_length: usize

Length of reads to generate

base_quality: u8

Default base quality to use across all qualities

sample_name: SampleName

Name of the sample

read_group_id: ReadGroupId

The read group to include in tags

sort_order: BamSortOrder

The sort order of the generated reads

header: Header

The BAM header

rng: StdRng

Random number generator

records: Vec<Record>

The collection of records being accumulated

default_quals: String

The default string o qualities to use

counter: usize

Counter for helping to increment the name

Implementations

impl BamBuilder[src]

pub fn new(
    read_length: usize,
    base_quality: u8,
    sample_name: String,
    read_group_id: Option<String>,
    sort: BamSortOrder,
    pseudo_sd: Option<SequenceDict>,
    seed: Option<usize>
) -> BamBuilder
[src]

Create a BamBuilder that fills in defaults based on the passed in options.

Example

use bam_builder::{bam_order::BamSortOrder, BamBuilder};

let mut builder = BamBuilder::new(
    100,                    // default read_length
    30,                     // default base_quality
    "Pair".to_owned(),      // name of samples
    None,                   // optional read group id
    BamSortOrder::Unsorted, // how to sort reads when `.sort` is called
    None,                   // optional sequence_dict
    None,                   // seed used for generating random bases
);
assert_eq!(builder.read_group_id.0, String::from("A"));
assert_eq!(builder.sample_name.0, String::from("Pair"));
assert_eq!(builder.records.len(), 0);

pub fn frag_builder(&mut self) -> ReadFragSpecBuilder[src]

Create a ReadFragSpecBuilder with defaults filled in based on BamBuilder.

pub fn add_frag(&mut self, frag_spec: ReadFragSpec)[src]

Add a single fragment to the builder.

pub fn pair_builder(&mut self) -> ReadPairSpecBuilder[src]

Create a ReadPairSpecBuilder with defaults filled in based on the BamBuilder.

pub fn add_pair(&mut self, pair_spec: ReadPairSpec)[src]

Add a read pair to the builder.

pub fn to_path(&self, path: &Path) -> Result<(), Error>[src]

Writes BAM records to specified path.

Note that BamBuilder::sort should be called ahead of writing to ensure records are sorted.

pub fn to_tmp(&self) -> Result<NamedTempFile, Error>[src]

Write records to a tempfile. Tempfile will be deleted when NamedTempFile goes out of scope.

Note that BamBuilder::sort should be called ahead of writing to ensure records are sorted.

pub fn sort(&mut self)[src]

Sort the records added thus far by whichever BamSortOrder was specified.

Trait Implementations

impl Debug for BamBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,