pub fn query<I, RS>(
        &mut self,
        reference_sequences: &ReferenceSequences,
        index: &I,
        region: &Region,
    ) -> io::Result<Query<'_, R>>
    where
        I: BinningIndex<RS>,
        RS: ReferenceSequenceExt,
    {
        let (reference_sequence_id, interval) = resolve_region(reference_sequences, region)?;
        let chunks = index.query(reference_sequence_id, interval)?;
        Ok(Query::new(self, chunks, reference_sequence_id, interval))
    }
/// Returns an iterator over records that intersect the given region.
///
/// # Examples
///
/// ```no_run
/// # use std::fs::File;
/// use noodles_bam::{self as bam, bai};
/// use noodles_core::Region;
/// use noodles_sam as sam;
///
/// let mut reader = File::open("sample.bam").map(bam::Reader::new)?;
/// let header: sam::Header = reader.read_header()?.parse()?;
///
/// let reference_sequences = header.reference_sequences();
/// let index = bai::read("sample.bam.bai")?;
/// let region = Region::mapped("sq0", 17711..=28657);
/// let query = reader.query(reference_sequences, &index, &region)?;
///
/// for result in query {
///     let record = result?;
///     println!("{:?}", record);
/// }
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
Returns an iterator over records that intersect the given region.
Returns an iterator over records that intersect the given region .
pub fn query<I, RS>(
        &mut self,
        reference_sequences: &ReferenceSequences,
        index: &I,
        region: &Region,
    ) -> io::Result<Query<'_, R>>
    where
        I: BinningIndex<RS>,
        RS: ReferenceSequenceExt,
    {
        let (reference_sequence_id, interval) = resolve_region(reference_sequences, region)?;
        let chunks = index.query(reference_sequence_id, interval)?;
        Ok(Query::new(self, chunks, reference_sequence_id, interval))
    }
pub fn query < I , RS > ( & mut self , reference_sequences : & ReferenceSequences , index : & I , region : & Region , ) -> io :: Result < Query < ' _ , R > > where I : BinningIndex < RS > , RS : ReferenceSequenceExt , { let ( reference_sequence_id , interval ) = resolve_region ( reference_sequences , region ) ? ; let chunks = index . query ( reference_sequence_id , interval ) ? ; Ok ( Query :: new ( self , chunks , reference_sequence_id , interval ) ) }
Returns an iterator over records that intersect the given region.
Returns an iterator over records that intersect the given region .
&mut self
reference_sequences
&ReferenceSequences
index
&I
region
&Region
&mut self
reference_sequences
&ReferenceSequences
index
&I
region
&Region
examples
None
use std::fs::file;
use noodles_bam::{self as bam, bai};
use noodles_core::Region;
use noodles_sam as sam.

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

let reference_sequences = header.reference_sequences();
let index = bai::read("sample.bam.bai")?;
let region = Region::mapped("sq0", 17711..=28657);
let query = reader.query(reference_sequences, &index, &region)?.

for result in query {
let record = result?;
println!("{:?}", record);
}
use noodles_bam :: { self as bam bai } ; use noodles_core :: Region ; use noodles_sam as sam . let mut reader = File :: open ( " sample . bam " ) . map ( bam :: Reader :: new ) ? ; let header : sam :: Header = reader . read_header () ? . parse () ? . let reference_sequences = header . reference_sequences () ; let index = bai :: read ( " sample . bam . bai " ) ? ; let region = Region :: mapped ( " sq0 " 17711 .. = 28657 ) ; let query = reader . query ( reference_sequences &index &region ) ? . for result in query { let record = result? ; println! ( " { : ? } " record ) ; }
ok::<(), box<dyn std::error::error>>(())
None