Struct noodles_cram::reader::Reader [−][src]
pub struct Reader<R> where
R: Read, { /* fields omitted */ }
Expand description
A CRAM reader.
The CRAM format is comprised of four main parts: 1) a file definition, 2) a file header, 3) a list of data containers, and 4) an end-of-file (EOF) container.
Examples
use noodles_cram as cram; let mut reader = File::open("sample.cram").map(cram::Reader::new)?; reader.read_file_definition()?; reader.read_file_header()?; for result in reader.records() { let record = result?; println!("{:?}", record); }
Implementations
Creates a CRAM reader.
Examples
use noodles_cram as cram; let mut reader = File::open("sample.bam").map(cram::Reader::new)?;
Reads the CRAM file definition.
The CRAM magic number is also checked.
The position of the stream is expected to be at the start.
Examples
use noodles_cram as cram; let mut reader = File::open("sample.cram").map(cram::Reader::new)?; let file_definition = reader.read_file_definition()?;
Reads the raw SAM header.
The position of the stream is expected to be at the CRAM header container, i.e., directly after the file definition.
This returns the raw SAM header as a std::string::String
. It can subsequently be parsed
as a noodles_sam::Header
.
Examples
use noodles_cram as cram; let mut reader = File::open("sample.cram").map(cram::Reader::new)?; reader.read_file_definition()?; let header = reader.read_file_header()?;
Returns a iterator over records starting from the current stream position.
The stream is expected to be at the start of a data container.
Examples
use noodles_cram as cram; let mut reader = File::open("sample.cram").map(cram::Reader::new)?; reader.read_file_definition()?; reader.read_file_header()?; for result in reader.records() { let record = result?; println!("{:?}", record); }
Seeks the underlying reader to the given position.
Positions typically come from the associated CRAM index file.
Examples
use std::io::SeekFrom; use noodles_cram as cram; let mut reader = File::open("sample.cram").map(cram::Reader::new)?; reader.seek(SeekFrom::Start(17711))?;