Struct rust_htslib::bam::IndexedReader [−][src]
pub struct IndexedReader { /* fields omitted */ }
Implementations
Define the region from which .read() or .records will retrieve reads.
Both iterating (with .records()) and looping without allocation (with .read() are a two stage process:
- ‘fetch’ the region of interest
- iter/loop trough the reads.
Example:
use rust_htslib::bam::{IndexedReader, Read}; let mut bam = IndexedReader::from_path(&"test/test.bam").unwrap(); bam.fetch(("chrX", 10000, 20000)); // coordinates 10000..20000 on reference named "chrX" for read in bam.records() { println!("read name: {:?}", read.unwrap().qname()); }
The arguments may be anything that can be converted into a FetchDefinition such as
- fetch(tid: u32) -> fetch everything on this reference
- fetch(reference_name: &u8 | &str) -> fetch everything on this reference
- fetch((tid: i32, start: i64, stop: i64)): -> fetch in this region on this tid
- fetch((reference_name: &u8 | &str, start: i64, stop: i64) -> fetch in this region on this tid
- fetch(FetchDefinition::All) or fetch(“.”) -> Fetch overything
- fetch(FetchDefinition::Unmapped) or fetch(“*”) -> Fetch unmapped (as signified by the ‘unmapped’ flag in the BAM - might be unreliable with some aligners.
The start / stop coordinates will take i64 (the correct type as of htslib’s ‘large coordinates’ expansion), i32, u32, and u64 (with a possible panic! if the coordinate won’t fit an i64).
This replaces the old fetch and fetch_str implementations.
Trait Implementations
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
.
Read next BAM record into given record. Use this method in combination with a single allocated record to avoid the reallocations occurring with the iterator. Read more
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
Auto Trait Implementations
impl !RefUnwindSafe for IndexedReader
impl !Sync for IndexedReader
impl Unpin for IndexedReader
impl !UnwindSafe for IndexedReader