Skip to content
Discussion options

You must be logged in to vote

You can build a sam::alignment::RecordBuf using its associated Builder. Alignment records implement sam::alignment::Record, which you would want to use between your implementation and tests.

Here's an example that counts the number of unmapped records in a BAM using a function that's generic over an alignment record.

// cargo add noodles@0.101.0 --features bam,sam

use std::{env, fs::File, io};

use noodles::{bam, sam};

fn main() -> io::Result<()> {
    let src = env::args().nth(1).expect("missing src");

    let mut reader = File::open(src).map(bam::io::Reader::new)?;
    let _header = reader.read_header()?;

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

    while reader

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Poshi
Comment options

@Wan-Yifei
Comment options

Answer selected by Poshi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #353 on October 19, 2025 16:37.