Extract bam file to sam inside code?
1
1
Entering edit mode
7 weeks ago
Uveyik ▴ 40

Hi everyone, how can I check if a given file is zipped or not(sam or bam) without looking at the file name in C++ code? Then, how can I convert bam files to sam in C++ code? I can use samtools view in terminal, but how can do it with code?

bam sam • 270 views
ADD COMMENT
3
Entering edit mode
7 weeks ago

A bam/cram is compressed with gzip. just look at the two first bytes, they should be 1f and 8b. https://stackoverflow.com/a/6059342/58082

but in the end, you should just use the htslib library https://github.com/samtools/htslib

ADD COMMENT

Login before adding your answer.

Traffic: 2330 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6