I have BAM file sorted based on the position. But to process each read, I also need to access its mate information. I'm using htsjdk package and right now, I'm accessing the mate information with queryMate(). However, queryMate() is extremely expensive and for large BAM file it is taking a lot of time (as it should). Is there a faster way of handling a read its mate?
My idea is to create a index file. One swipe through the whole BAM file and store one-to-one information for each read with queryMate(). Still doesn't seem like the best idea. Is there any other way this can be done more efficiently? Thanks.
1 answer
Hello,
you should sort your bam file by readname. Then you have the mates next to each other and can just iterate one time over your file to collect all information you need.
fin swimmer
Log in to answer this question.