noodles_sam::io::writer::record

Function write_cigar

Source
pub fn write_cigar<W, C>(writer: &mut W, cigar: &C) -> Result<()>
where W: Write, C: Cigar,
Expand description

Writes a SAM record CIGAR string.

ยงExamples

use noodles_sam::{
    alignment::{
        record::cigar::{op::Kind, Op},
        record_buf::Cigar,
    },
    io::writer::record::write_cigar,
};

let mut buf = Vec::new();
let cigar = Cigar::default();
write_cigar(&mut buf, &cigar)?;
assert_eq!(buf, b"*");

let mut buf = Vec::new();
let cigar: Cigar = [Op::new(Kind::Match, 4)].into_iter().collect();
write_cigar(&mut buf, &cigar)?;
assert_eq!(buf, b"4M");
Ok::<_, std::io::Error>(())