rust-bio / rust-htslib

This library provides HTSlib bindings and a high level Rust API for reading and writing BAM files.
MIT License
308 stars 80 forks source link

Are there some default filters in alignment pileup? #409

Open huangnengCSU opened 1 year ago

huangnengCSU commented 1 year ago

hi, I am using the function pileup(). I found that the alignments of some reads are not showing in pileup.alignments()but I can see them in IGV. So are there some default filtering strategies? Here is my code as follows:

let mut bam: bam::IndexedReader = bam::IndexedReader::from_path(bam_path).unwrap();
bam.fetch((region.chr.as_str(), region.start, region.end)).unwrap(); // set region
for p in bam.pileup() {
    let pileup = p.unwrap();
    let pos = pileup.pos(); // 0-based
    for alignment in pileup.alignments() {
        let record = alignment.record();
        let qname = std::str::from_utf8(record.qname()).unwrap().to_string();
    }
}

Thank you! Neng