This is a test version of Biostars. For the public version, visit https://www.biostars.org.
What is the algorithm or formula for converting SAM to BAM?

I have seen some tools which converts SAM to BAM format. I wanted to know how they are converted. SAM file contains nucleotides (A, T, G, C) and how these data are converted to binaries?

ngs samtools sam bam

2 answers

Section 4 page 11. SAM file contains more than just nucleotides. Original paper from Heng et al here.

You'll want to read the BAM specification. In short, bases are encoded as 4 bit integers (see section 4.2).

Log in to answer this question.