Struct rust_htslib::bam::Reader [−][src]
pub struct Reader { /* fields omitted */ }Expand description
A BAM reader.
Implementations
Create a new Reader from STDIN.
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>;
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
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()) }
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.
Iterator over pileups.
Return the header.
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