Skip to content

noodles-bam lazy_records question #182

Answered by zaeleus
andypexai asked this question in Q&A
Discussion options

You must be logged in to vote

In general, if the BAM is indexed, I recommend using Reader::query. This parses and validates the data in each record and returns it as an owned sam::alignment::Record. Here is a basic count example that counts the number of records in a list of given regions.

use std::env;

use noodles::{bam, core::Region};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut args = env::args().skip(1);

    let src = args.next().expect("missing src");
    let regions: Vec<Region> = args.map(|s| s.parse()).collect::<Result<_, _>>()?;

    let mut reader = bam::indexed_reader::Builder::default().build_from_path(src)?;
    let header = reader.read_header()?;

    let mut n = 0;

    for region 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andypexai
Comment options

Answer selected by andypexai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants