I was just wondering why we always needs to convert .sam to .bam and the sort it and convert back to .sam Any programming bottle necks to handle .sam file directly for this?
3 answers
Sorting is a resource consuming operation, the binary formats will sort much faster.
Why would you convert back to sam? Leave things in .bam as much as possible. You probably only need to eyeball exerpts of your .sam file. pipe samtools view into something else if you have to run awk or grep or something like that on a ,bam file
I did all the piping and to get the sorted sam. I have methylation data (bismark generated sam file); Some of the R packages (say methylKit) need sorted SAM files only.
You could use Picard's SortSam tool to just sort the .sam file directly.
Log in to answer this question.
If you convert a sorted .bam file to .sam file, are you sure the .sam file is sorted?
yes, the samtools view command output the records in the bam file in the order they are stored.