rust-bio / rust-htslib

This library provides HTSlib bindings and a high level Rust API for reading and writing BAM files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quickest way for pileup at known position?

ebioman opened this issue · comments

Hi thanks for this great library!
I am a bit confused currently what the fastest way is to get a pileup at a known position.
Currently I found the only way being from IndexedReader where here bam would be the IndexedReader:

bam.fetch((chr,start,end)).expect("ERROR: could not fetch region");

for pile in bam.pileup().map(|x| x.expect("ERROR: could not parse BAM file")) {
   if pile.pos() as u64 == start {
      // here comes the the analysis of that position
   }
}

This iterator part and checking the position to match my position of interest is though pretty slow and I am wondering whether I am doing here something very obviously wrong ?
I guess by fetching a 1bp specific position I still can get quite a large range depending on my read length, but still I feel I am missing something here...