Struct rust_htslib::bam::Reader
source · pub struct Reader { /* private fields */ }
Expand description
A BAM reader.
Implementations§
source§impl 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> ⓘ
pub fn iter_chunk( &mut self, start: Option<i64>, end: Option<i64> ) -> ChunkIterator<'_, Self> ⓘ
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§
source§impl Read for Reader
impl Read for Reader
source§fn 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())
}
source§fn records(&mut self) -> Records<'_, Self> ⓘ
fn records(&mut self) -> Records<'_, Self> ⓘ
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
.
source§fn rc_records(&mut self) -> RcRecords<'_, Self> ⓘ
fn rc_records(&mut self) -> RcRecords<'_, Self> ⓘ
source§fn header(&self) -> &HeaderView
fn header(&self) -> &HeaderView
source§fn set_thread_pool(&mut self, tpool: &ThreadPool) -> Result<()>
fn set_thread_pool(&mut self, tpool: &ThreadPool) -> Result<()>
crate::tpool::ThreadPool::new(n_threads)
Read more