sam: expose header parsing for reuse in bam parsers

It happens that BAM files carry the SAM header in plain text, so it would be useful to reuse the code from the `Sam` module. I tried my best to expose the function without breaking anything, but I'd rather have @agarwal have a look at it before pushing it on the repo.