SAMBAMBA-SORT(1)
π SAMBAMBA-SORT(1) π
okay bestie, sit down, grab a strawberry π β this is sambamba-sort, the tool for sorting BAM files. yes, that one. she's a section 1 manual page and she is lowkey iconic.
β¨ SYNOPSIS β¨
sambamba sort OPTIONS <input.bam>
π¦ DESCRIPTION π¦
so a BAM file can be in one of two sort orders, right? it's either coordinate or qname, and no you don't get to freestyle it.
coordinate means the file is sorted by (integer) reference ID, and then, inside each reference, the reads get sorted by start coordinate. very demure, very orderly. π
qname means the reads are sorted lexicographically by their names. alphabetical girlie behavior, we love her.
now here's the tea: sambamba sort does an external stable-type sort on your input file. what does that even mean? it means she reads the source BAM in chunks that fit into memory, sorts each chunk, writes those chunks out to a temporary directory, and then merges them all together. and after the merge? the temporary files get removed automatically. she cleans up after herself. main character energy fr fr. β¨
both sort orders are supported, but the default is coordinate, because that's the one you need for building an index later. iykyk. if you wanna switch over to qname, just use the -n|--sort-by-name flag. easy.
π OPTIONS π
-m,--memory-limit=LIMITβ sets an upper bound on the memory used. fair warning bestie: this is very approximate, it's giving vibes not precision. the default memory limit is512MiB. if you raise it, the chunk sizes get bigger and you get fewer I/O seeks, which means the overall performance goes up. slay.LIMIThas to be a number with an optional suffix that says what unit you mean. these endings are recognized:K,KiB,KB,M,MiB,MB,G,GiB,GB.--tmpdir=TMPDIRβ useTMPDIRfor writing out the sorted chunks. default behavior is to use the system temporary directory.-o,--out=OUTPUTFILEβ the output file name. if you don't provide one, the result gets written to a file with the.sorted.bamextension. she'll name it herself, she's independent like that. π-n,--sort-by-nameβ sort by read name instead of doing a coordinate sort. this is the switch that flips you intoqnameland.-l,--compression-level=COMPRESSION_LEVELβ the compression level to use for the sorted BAM, from0(known as uncompressed BAM in samtools) all the way up to9.-u,--uncompressed-chunksβ write the sorted chunks as uncompressed BAM. default behavior is to write them with compression level1, because that cuts down the time spent on I/O, but in some cases using this option can give you better speed. BUT. note that the disk space you'll need for sorting will typically be 3-4 times more than without enabling this option. so like, check your disk first, bestie π-p,--show-progressβ show a wget-like progressbar inSTDERR. and actually it's two of them, one after another β the first one for sorting, and then another one for merging. double the bars, double the serotonin π-t,--nthreads=NTHREADSβ number of threads to use. go forth and parallelize π§
π SEE ALSO π
for more info on the original samtools SORT behavior, check out the samtools documentation at http://samtools.sourceforge.net/samtools.shtml. go read it, i'll wait π«Ά
π BUGS π
at the moment, the memory is used quite ineffectively for really large files. not me exposing her flaws on main, but transparency is important bestie π
okay that's the whole page! this was brought to you by SAMBAMBA-SORT(1), dated February 2015 β yeah she's an older queen but she still ate and left no crumbs. mwah πβ¨
π¦ where this page comes from
- debian bookworm: sambamba 1.0+dfsg-1 Β· GPL-2.0-or-later
- debian trixie: sambamba 1.0.1+dfsg-2+b1 Β· GPL-2.0-or-later
- ubuntu jammy: sambamba 0.8.2+dfsg-2 Β· GPL-2.0-or-later
- ubuntu noble: sambamba 1.0.1+dfsg-1build3 Β· GPL-2.0-or-later
- ubuntu questing: sambamba 1.0.1+dfsg-2build1
- ubuntu resolute: sambamba 1.0.1+dfsg-3ubuntu1 Β· GPL-2.0-or-later
- ubuntu stonking: sambamba 1.0.1+dfsg-3ubuntu3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms