This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools view sample.bam >sample2.sam : lost the header

First ,

samtools view -Sb sample.sam >sample.bam

Second,

samtools view sample.bam >sample2.sam

I used this method: sam2bam2sam found that the head of the original sam file was lost at the end. So was it lost in sam2bam or bam2sam?

ps:sample.sam have header information,sample2.sam don't have header information.

samtools

2 answers

samtools view -h sample.bam > sample.sam

You must use the -h parameter when converting from bam to sam.

But why are you doing this?

Log in to answer this question.