My confusion arose because both b and u flag seem to do the same task, except one outputs the compressed and the other uncompressed bam.
It says samtools view -u outputs bam file in uncompressed. Is this just for performance, or if I fail to give this flag, would this cause any problem?
For example, what is the difference between other than the computing time?
samtools view -bS some.sam | samtools sort - some_sort
samtools view -uS some.sam | samtools sort - some_sort
Most importantly, If u flag just for performance, why is it not default? what is the purpose having b flag?
1 answer
b flag is when you need to store file on disk, -u is for piping purposes. If you have plenty of disk space and the disk is fast, there's indeed no reason to store BAMs compressed (unless you run a FTP server which provides access to these files). But usually disk performance is not that great, and it's faster to read compressed file and unpack it on the fly, than to read uncompressed file. Plus, as I mentioned, if BAMs are to be accessible via HTTP/FTP, traffic becomes another reason.
Log in to answer this question.