Related to my other question (Samtools sort: most efficient memory and thread settings for many samples on a cluster), we need to optimize samtools sort
as we prepare to analyze thousands of .bam
files, beginning with re-alignment, sorting, etc.
Ultimate question: what is the fastest way to sort a single sample after aligning the sample across many separate cluster jobs? i.e., after splitting .fastq
s for a single sample and aligning as distinct jobs. I'm looking for recent and clear time/thread/memory comparisons.
Unless I'm missing something, samtools merge
was designed exactly for the purpose of merging pre-sorted bams. An excerpt from the manpage (http://www.htslib.org/doc/samtools-merge.html): "Merge multiple sorted alignment files, producing a single sorted output file that contains all the input records and maintains the existing sort order."
Is it fastest to:
samtools sort
each 'mini-bam' and thensamtools merge
?samtools cat
the 'mini-bams' together and thensamtools sort
?- Another option I haven't considered?
Note: I have seen the following similar questions on other forums, but they are outdated (~8 years ago) and do not answer this question directly: