noodles_cram/io/
indexed_reader.rsmod builder;
pub use self::builder::Builder;
use std::io::{self, Read, Seek};
use noodles_core::Region;
use noodles_fasta as fasta;
use noodles_sam as sam;
use super::{
reader::{Query, Records},
Reader,
};
use crate::{crai, DataContainer, FileDefinition};
pub struct IndexedReader<R> {
inner: Reader<R>,
index: crai::Index,
}
impl<R> IndexedReader<R>
where
R: Read,
{
pub fn new(inner: R, index: crai::Index) -> Self {
Self {
inner: Reader::new(inner),
index,
}
}
pub fn get_ref(&self) -> &R {
self.inner.get_ref()
}
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut()
}
pub fn into_inner(self) -> R {
self.inner.into_inner()
}
pub fn reference_sequence_repository(&self) -> &fasta::Repository {
self.inner.reference_sequence_repository()
}
pub fn read_file_definition(&mut self) -> io::Result<FileDefinition> {
self.inner.read_file_definition()
}
pub fn read_file_header(&mut self) -> io::Result<sam::Header> {
self.inner.read_file_header()
}
pub fn read_header(&mut self) -> io::Result<sam::Header> {
self.inner.read_header()
}
pub fn read_data_container(&mut self) -> io::Result<Option<DataContainer>> {
self.inner.read_data_container()
}
pub fn records<'r>(&'r mut self, header: &'r sam::Header) -> Records<'r, R> {
self.inner.records(header)
}
pub fn index(&self) -> &crai::Index {
&self.index
}
}
impl<R> IndexedReader<R>
where
R: Read + Seek,
{
pub fn query<'a>(
&'a mut self,
header: &'a sam::Header,
region: &Region,
) -> io::Result<Query<'a, R>> {
self.inner.query(header, &self.index, region)
}
}