Skip to main content

Query

Struct Query 

Source
pub struct Query<'r, R> { /* private fields */ }
Expand description

A reader over records of a BAM reader that intersects a given region.

This is created by calling super::Reader::query.

Implementations§

Source§

impl<'r, R> Query<'r, R>
where R: BufRead + Seek,

Source

pub fn read_record(&mut self, record: &mut Record) -> Result<usize>

Reads a record.

§Examples
use noodles_bam::{self as bam, bai};

let mut reader = File::open("sample.bam").map(bam::io::Reader::new)?;
let header = reader.read_header()?;

let index = bai::fs::read("sample.bam.bai")?;
let region = "sq0:8-13".parse()?;
let mut query = reader.query(&header, &index, &region)?;

let mut record = bam::Record::default();

while query.read_record(&mut record)? != 0 {
    // ...
}
Source

pub fn records(self) -> Records<'r, R>

Returns an iterator over records.

use noodles_bam::{self as bam, bai};

let mut reader = File::open("sample.bam").map(bam::io::Reader::new)?;
let header = reader.read_header()?;

let index = bai::fs::read("sample.bam.bai")?;
let region = "sq0:8-13".parse()?;
let query = reader.query(&header, &index, &region)?;

let mut record = bam::Record::default();

for result in query.records() {
    let record = result?;
    // ...
}

Auto Trait Implementations§

§

impl<'r, R> Freeze for Query<'r, R>

§

impl<'r, R> RefUnwindSafe for Query<'r, R>
where R: RefUnwindSafe,

§

impl<'r, R> Send for Query<'r, R>
where R: Send,

§

impl<'r, R> Sync for Query<'r, R>
where R: Sync,

§

impl<'r, R> Unpin for Query<'r, R>

§

impl<'r, R> UnsafeUnpin for Query<'r, R>

§

impl<'r, R> !UnwindSafe for Query<'r, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.