Struct rust_htslib::bam::Reader
source · [−]pub struct Reader { /* private fields */ }Expand description
A BAM reader.
Implementations
sourceimpl Reader
impl Reader
sourcepub fn from_stdin() -> Result<Self>
pub fn from_stdin() -> Result<Self>
Create a new Reader from STDIN.
sourcepub fn iter_chunk(
&mut self,
start: Option<i64>,
end: Option<i64>
) -> ChunkIterator<'_, Self>ⓘNotable traits for ChunkIterator<'a, R>impl<'a, R: Read> Iterator for ChunkIterator<'a, R> type Item = Result<Record>;
pub fn iter_chunk(
&mut self,
start: Option<i64>,
end: Option<i64>
) -> ChunkIterator<'_, Self>ⓘNotable traits for ChunkIterator<'a, R>impl<'a, R: Read> Iterator for ChunkIterator<'a, R> type Item = Result<Record>;
Iterator over the records between the (optional) virtual offsets start and end
Arguments
-
start- Optional starting virtual offset to seek to. Throws an error if it is not a valid virtual offset. -
end- Read until the virtual offset is less thanend
Trait Implementations
sourceimpl Read for Reader
impl Read for Reader
sourcefn read(&mut self, record: &mut Record) -> Option<Result<()>>
fn read(&mut self, record: &mut Record) -> Option<Result<()>>
Read the next BAM record into the given Record.
Returns None if there are no more records.
This method is useful if you want to read records as fast as possible as the
Record can be reused. A more ergonomic approach is to use the records
iterator.
Errors
If there are any issues with reading the next record an error will be returned.
Examples
use rust_htslib::errors::Error;
use rust_htslib::bam::{Read, Reader, Record};
let mut bam = Reader::from_path(&"test/test.bam")?;
let mut record = Record::new();
// Print the TID of each record
while let Some(r) = bam.read(&mut record) {
r.expect("Failed to parse record");
println!("TID: {}", record.tid())
}sourcefn records(&mut self) -> Records<'_, Self>ⓘNotable traits for Records<'a, R>impl<'a, R: Read> Iterator for Records<'a, R> type Item = Result<Record>;
fn records(&mut self) -> Records<'_, Self>ⓘNotable traits for Records<'a, R>impl<'a, R: Read> Iterator for Records<'a, R> type Item = Result<Record>;
Iterator over the records of the fetched region.
Note that, while being convenient, this is less efficient than pre-allocating a
Record and reading into it with the read method, since every iteration involves
the allocation of a new Record.
sourcefn rc_records(&mut self) -> RcRecords<'_, Self>ⓘNotable traits for RcRecords<'a, R>impl<'a, R: Read> Iterator for RcRecords<'a, R> type Item = Result<Rc<Record>>;
fn rc_records(&mut self) -> RcRecords<'_, Self>ⓘNotable traits for RcRecords<'a, R>impl<'a, R: Read> Iterator for RcRecords<'a, R> type Item = Result<Rc<Record>>;
sourcefn pileup(&mut self) -> Pileups<'_, Self>ⓘNotable traits for Pileups<'a, R>impl<'a, R: Read> Iterator for Pileups<'a, R> type Item = Result<Pileup>;
fn pileup(&mut self) -> Pileups<'_, Self>ⓘNotable traits for Pileups<'a, R>impl<'a, R: Read> Iterator for Pileups<'a, R> type Item = Result<Pileup>;
Iterator over pileups.
sourcefn header(&self) -> &HeaderView
fn header(&self) -> &HeaderView
Return the header.
sourcefn set_thread_pool(&mut self, tpool: &ThreadPool) -> Result<()>
fn set_thread_pool(&mut self, tpool: &ThreadPool) -> Result<()>
Use a shared thread-pool for writing. This permits controlling the total
thread count when multiple readers and writers are working simultaneously.
A thread pool can be created with crate::tpool::ThreadPool::new(n_threads) Read more
impl Send for Reader
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more