Struct noodles_sam::Writer[][src]

pub struct Writer<W> where
    W: Write
{ /* fields omitted */ }
Expand description

A SAM writer.

The SAM format is comprised of two parts: 1) a header and 2) a list of records.

Each header line is prefixed with an @ (at sign). The header is optional and may be empty.

SAM records are line-based and follow directly after the header or the start of the file until EOF.

Examples

use noodles_sam as sam;

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

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

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

let expected = b"@CO\tnoodles-sam
*\t4\t*\t0\t255\t*\t*\t0\t0\t*\t*
";

assert_eq!(&writer.get_ref()[..], &expected[..]);

Implementations

Creates a SAM writer.

Examples

use noodles_sam as sam;
let writer = sam::Writer::new(Vec::new());

Returns a reference to the underlying writer.

Examples

use noodles_sam as sam;
let writer = sam::Writer::new(Vec::new());
assert!(writer.get_ref().is_empty());

Returns the underlying writer.

Examples

use noodles_sam as sam;
let writer = sam::Writer::new(Vec::new());
assert!(writer.into_inner().is_empty());

Writes a SAM header.

The SAM header is optional, though recommended to include. A call to this method can be omitted if it is empty.

Examples

use noodles_sam as sam;
let mut writer = sam::Writer::new(Vec::new());
let header = sam::Header::builder().add_comment("noodles-sam").build();
writer.write_header(&header)?;
assert_eq!(writer.get_ref(), b"@CO\tnoodles-sam\n");

Writes a SAM record.

Examples

use noodles_sam as sam;
let mut writer = sam::Writer::new(Vec::new());
let record = sam::Record::default();
writer.write_record(&record)?;
assert_eq!(writer.get_ref(), b"*\t4\t*\t0\t255\t*\t*\t0\t0\t*\t*\n");

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

Performs the conversion.

Performs the conversion.

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.