This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools return seek position

I was wondering if there is a way to return byte ranges instead of a slice with samtools view on a bam file?

In other words, with samtools view -bh foo.bam 1:10-100, it returns a pair of ints (start_byte_pos, end_byte_pos) for the resulting query, or a list of such pairs if the data are not located contiguously in the foo.bam.

samtools bam

1 answer

You can't get that with the command line program. If you really need that information, then I presume you're programming anyway, so you'll want to look at htslib, which underlies samtools and provides the functionality that you're looking for.

Log in to answer this question.