pub struct Writer<W> { /* private fields */ }
Expand description

A BAM writer.

Examples

use noodles_bam as bam;
use noodles_sam::{self as sam, alignment::Record};

let mut writer = bam::Writer::new(Vec::new());

let header = sam::Header::default();
writer.write_header(&header)?;
writer.write_reference_sequences(header.reference_sequences())?;

let record = Record::default();
writer.write_record(&header, &record)?;

Implementations

Returns a reference to the underlying writer.

Examples
use noodles_bam as bam;
let writer = bam::Writer::from(Vec::new());
assert!(writer.get_ref().is_empty());

Returns a mutable reference to the underlying writer.

Examples
use noodles_bam as bam;
let mut writer = bam::Writer::from(Vec::new());
assert!(writer.get_mut().is_empty());

Returns the underlying writer.

Examples
use noodles_bam as bam;
let writer = bam::Writer::from(Vec::new());
assert!(writer.into_inner().is_empty());

Writes a SAM header.

Examples
use noodles_bam as bam;
use noodles_sam as sam;

let mut writer = bam::Writer::new(Vec::new());

let header = sam::Header::builder().add_comment("noodles-bam").build();
writer.write_header(&header)?;

Writes SAM reference sequences.

The reference sequences here are typically the same as the reference sequences in the SAM header.

Examples
use noodles_bam as bam;
use noodles_sam::{self as sam, header::ReferenceSequence};

let mut writer = bam::Writer::new(Vec::new());

let header = sam::Header::builder()
    .add_reference_sequence(ReferenceSequence::new("sq0".parse()?, 8)?)
    .add_comment("noodles-bam")
    .build();

writer.write_header(&header)?;
writer.write_reference_sequences(header.reference_sequences())?;

Writes a BAM record.

Examples
use noodles_bam as bam;
use noodles_sam::{self as sam, alignment::Record};

let mut writer = bam::Writer::new(Vec::new());

let header = sam::Header::default();
let record = Record::default();
writer.write_record(&header, &record)?;

Creates a BAM writer with a default compression level.

The given stream is wrapped in a BGZF encoder.

Examples
use noodles_bam as bam;
let writer = bam::Writer::new(Vec::new());

Attempts to finish the output stream.

This is typically only manually called if the underlying stream is needed before the writer is dropped.

Examples
use noodles_bam as bam;
let mut writer = bam::Writer::new(Vec::new());
writer.try_finish()?;

Trait Implementations

Writes a SAM header.

Writes an alignment record.

Shuts down an alignment format writer.

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts to this type from the input type.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more