Thanks! for the clear explanation
Hi! I would like to ask what is the difference between commands bellow. This wrote in oneliner:
bowtie2 -x {input.index} -U {input.fastq} | samtools view -bS -> {output}
and this two:
bowtie2 -x {input.index} -U {input.fastq} -S {output}
samtools view -u {input} -o {output}
or this is the same or the first one is shorter?
1 answer
Using the first option, the output will be directly a BAM file.
Using the second option, you will get a SAM file from the first command, and a BAM file from the second. If you don't need a SAM file, I will recommend going for the first option, it is faster and you will avoid generating huge SAM files in your computer that take a lot of space and you don't need them.
One more question. Why the final bam file is much bigger (about 70%) when I use the second commands, those with support sam files?
-u, --uncompressed Output uncompressed data. This also changes the default output format to BAM, but this can be overridden by the explicit format options or using a filename with a known suffix.
that is mean that bam in not always comprased type of file?
Hi! No problem. I have never used -u myself. Here you can read the manual of samtools, which says the same as what @GenoMax has pointed out, and also This option saves time spent on compression/decompression and is thus preferred when the output is piped to another samtools command. I guess the output is a SAM file instead of a BAM file, or some kind of uncompressed file, and that is why is bigger. You can try to see the content of the file. A BAM file is always compressed.
Log in to answer this question.