Struct noodles_cram::Writer [−][src]
pub struct Writer<W> where
W: Write, { /* fields omitted */ }
Expand description
A CRAM writer.
Examples
use noodles_cram as cram; use noodles_sam as sam; let mut writer = cram::Writer::new(Vec::new(), Vec::new()); writer.write_file_definition()?; let header = sam::Header::builder().add_comment("noodles-cram").build(); writer.write_file_header(&header)?; let record = cram::Record::default(); writer.write_record(record)?;
Implementations
Creates a new CRAM writer.
Examples
use noodles_cram as cram; let writer = cram::Writer::new(Vec::new(), Vec::new());
Returns a reference to the underlying writer.
Examples
use noodles_cram as cram; let writer = cram::Writer::new(Vec::new(), Vec::new()); assert!(writer.get_ref().is_empty());
Attempts to finish the output stream by writing any pending containers and a final EOF container.
This is typically only manually called if the underlying stream is needed before the writer is dropped.
Examples
use noodles_cram as cram; let mut writer = cram::Writer::new(Vec::new(), Vec::new()); writer.try_finish()?;
Writes a CRAM file definition.
The file ID is set as a blank value ([0x00; 20]
).
Examples
use noodles_cram as cram; let mut writer = cram::Writer::new(Vec::new(), Vec::new()); writer.write_file_definition()?; assert_eq!(writer.get_ref(), &[ // magic number (CRAM) 0x43, 0x52, 0x41, 0x4d, // format (major, minor) 0x03, 0x00, // file ID 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ]);
Writes a CRAM file header container.
The position of the stream is expected to be directly after the file definition.
Reference sequence dictionary entries must have MD5 checksums (M5
) set.
Examples
use noodles_cram as cram; use noodles_sam as sam; let mut writer = cram::Writer::new(Vec::new(), Vec::new()); writer.write_file_definition()?; let header = sam::Header::default(); writer.write_file_header(&header)?;