This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Difference between samtools cat and the unix command cat?

I am wondering, if I want to concatenate several .bam files, what's the difference between using samtools cat and the unix command cat?

samtools unix

2 answers

I think samtools cat would treat the body and the header differently, whereas cat would just concatenate them, breaking the SAM format.

Using samtools will allow you to use -hwhich will copy the header from a selected bam file (default: first file) into the resulting file (regardless of the number of total files merged). 'Cat'ing a bunch of BAMs together with their headers using normal cat would not be pretty. You can also use lists of input files with the -b option.

You don't need -h to copy header from file1 - that is the default behavior without -h.

Log in to answer this question.