Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about bam::IndexedReader::fetch() #463

Open
epiliper opened this issue Jan 26, 2025 · 0 comments
Open

Question about bam::IndexedReader::fetch() #463

epiliper opened this issue Jan 26, 2025 · 0 comments

Comments

@epiliper
Copy link

epiliper commented Jan 26, 2025

Before I start, I just wanted to thank you for this library; It's a staple of the software I'm writing.

I had a question about the fetch() method of the IndexedReader, for use with indexed .bam files:

I noticed that running fetch on a specified range of coordinates across a reference can take quite a while with larger alignment files (e.g. 9GB), even without iterating across the reads in the fetched region. Importantly, I noticed that fetching a range of coordinates with 0 mapped reads takes a similarly long time.

I'm assuming that this is because, for every call of fetch(), the line pointer in the BAM file must be moved to the appropriate line each time, from the beginning? If this is the case, is there any way to reduce the overhead of repeatedly calling fetch(), or some way to get the line pointer from the previous fetch call and simply navigate to the next position from there?

For context, I'm processing alignment files iteratively in groups of coordinate windows; the code below gets all reads from a given reference in a given window size (say 100bp, from coordinates 0 - 100):

for window in window_chunk {
    let start = window[0];
    let end = window[1];

       
    reader
        .fetch((tid, start, end))
        .expect("Error: invalid window value supplied!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant