pub struct Scanner { /* private fields */ }Expand description
A CRAM scanner.
§Examples
use oxbow::alignment::format::cram::Scanner;
use std::fs::File;
use noodles::fasta::io::indexed_reader::Builder as FastaIndexedReaderBuilder;
use noodles::fasta::repository::adapters::IndexedReader as FastaIndexedReaderAdapter;
let fa_reader = FastaIndexedReaderBuilder::default().build_from_path("reference.fa").unwrap();
let adapter = FastaIndexedReaderAdapter::new(fa_reader);
let repository = noodles::fasta::Repository::new(adapter);
let inner = File::open("sample.cram").unwrap();
let mut fmt_reader = noodles::cram::io::Reader::new(inner);
let header = fmt_reader.read_header().unwrap();
let scanner = Scanner::new(header);
let tag_defs = scanner.tag_defs(&mut fmt_reader, Some(1000)).unwrap();
let batches = scanner.scan(fmt_reader, repository, None, Some(tag_defs), None, Some(1000));Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn chrom_names(&self) -> Vec<String>
pub fn chrom_names(&self) -> Vec<String>
Returns the reference sequence names.
Sourcepub fn chrom_sizes(&self) -> Vec<(String, u32)>
pub fn chrom_sizes(&self) -> Vec<(String, u32)>
Returns the reference sequence names and lengths.
Sourcepub fn field_names(&self) -> Vec<String>
pub fn field_names(&self) -> Vec<String>
Returns the fixed field names.
Source§impl Scanner
impl Scanner
Sourcepub fn tag_defs<R: Read>(
&self,
fmt_reader: &mut Reader<R>,
scan_rows: Option<usize>,
) -> Result<Vec<(String, String)>>
pub fn tag_defs<R: Read>( &self, fmt_reader: &mut Reader<R>, scan_rows: Option<usize>, ) -> Result<Vec<(String, String)>>
Discovers tag definitions by scanning over records.
The scan will begin at the current position of the reader and will move the cursor to the end of the last record scanned.
Sourcepub fn scan<R: Read>(
&self,
fmt_reader: Reader<R>,
repo: Repository,
fields: Option<Vec<String>>,
tag_defs: Option<Vec<(String, String)>>,
batch_size: Option<usize>,
limit: Option<usize>,
) -> Result<impl RecordBatchReader>
pub fn scan<R: Read>( &self, fmt_reader: Reader<R>, repo: Repository, fields: Option<Vec<String>>, tag_defs: Option<Vec<(String, String)>>, batch_size: Option<usize>, limit: Option<usize>, ) -> Result<impl RecordBatchReader>
Returns an iterator yielding record batches.
The scan will begin at the current position of the reader and will move the cursor to the end of the last record scanned.
Sourcepub fn scan_query<R: Read + Seek>(
&self,
fmt_reader: Reader<R>,
repo: Repository,
region: Region,
index: Index,
fields: Option<Vec<String>>,
tag_defs: Option<Vec<(String, String)>>,
batch_size: Option<usize>,
limit: Option<usize>,
) -> Result<impl RecordBatchReader>
pub fn scan_query<R: Read + Seek>( &self, fmt_reader: Reader<R>, repo: Repository, region: Region, index: Index, fields: Option<Vec<String>>, tag_defs: Option<Vec<(String, String)>>, batch_size: Option<usize>, limit: Option<usize>, ) -> Result<impl RecordBatchReader>
Returns an iterator yielding record batches satisfying a genomic range query.
This operation requires a CRAI Index and the FASTA reference repository must be provided separately from the CRAM reader.
The scan will traverse one or more CRAM data containers and slices and filter for records that overlap the given region. The cursor will stop at the end of the last record scanned.
Auto Trait Implementations§
impl Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnwindSafe for Scanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more