[−][src]Struct bam::bam_reader::IndexedReader
BAM file reader. In contrast to Reader the IndexedReader
allows to fetch records from arbitrary positions,
but does not allow to read all records consecutively.
The following code would load BAM file test.bam
and its index test.bam.bai
, take all records
from 2:100001-200000
and print them on the stdout.
extern crate bam; fn main() { let mut reader = bam::IndexedReader::from_path("test.bam").unwrap(); // We need to clone the header to have access to reference names as the // reader will be blocked during fetch. let header = reader.header().clone(); let mut stdout = std::io::BufWriter::new(std::io::stdout()); for record in reader.fetch(1, 100_000, 200_000) { record.unwrap().write_sam(&mut stdout, &header).unwrap(); } }
You can find more detailed help on the main page.
Methods
impl IndexedReader<File>
[src]
pub fn build() -> IndexedReaderBuilder
[src]
Creates IndexedReaderBuilder.
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
[src]
Opens bam file from path
. Bai index will be loaded from {path}.bai
.
Same as Self::build().from_path(path)
.
impl<R: Read + Seek> IndexedReader<R>
[src]
ⓘImportant traits for RegionViewer<'a, R>pub fn fetch<'a>(
&'a mut self,
ref_id: i32,
start: i32,
end: i32
) -> RegionViewer<'a, R>
[src]
&'a mut self,
ref_id: i32,
start: i32,
end: i32
) -> RegionViewer<'a, R>
Returns an iterator over records aligned to the reference ref_id
(0-based),
and intersecting half-open interval [start-end)
.
ⓘImportant traits for RegionViewer<'a, R>pub fn fetch_by<'a, F>(
&'a mut self,
ref_id: i32,
start: i32,
end: i32,
predicate: F
) -> RegionViewer<'a, R> where
F: 'static + Fn(&Record) -> bool,
[src]
&'a mut self,
ref_id: i32,
start: i32,
end: i32,
predicate: F
) -> RegionViewer<'a, R> where
F: 'static + Fn(&Record) -> bool,
Returns an iterator over records aligned to the reference ref_id
(0-based),
and intersecting half-open interval [start-end)
.
Records will be filtered by predicate
. It helps to slightly reduce fetching time,
as some records will be removed without allocating new memory and without calculating
alignment length.
pub fn header(&self) -> &Header
[src]
Returns BAM header.
pub fn write_record_as_sam<W: Write>(
&self,
writer: &mut W,
record: &Record
) -> Result<()>
[src]
&self,
writer: &mut W,
record: &Record
) -> Result<()>
Writes record in sam format. Same as Record::write_sam.
Auto Trait Implementations
impl<R> Send for IndexedReader<R> where
R: Send,
R: Send,
impl<R> Unpin for IndexedReader<R> where
R: Unpin,
R: Unpin,
impl<R> Sync for IndexedReader<R> where
R: Sync,
R: Sync,
impl<R> UnwindSafe for IndexedReader<R> where
R: UnwindSafe,
R: UnwindSafe,
impl<R> RefUnwindSafe for IndexedReader<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,