mako
Fast SAM/BAM sorter.
mako is a focused, single-purpose command-line tool for sorting SAM and
BAM files. It sorts by coordinate, queryname (lexicographic or natural),
or template-coordinate, and can verify whether a file is already
correctly sorted without rewriting it.
Highlights
- External merge-sort — handles BAM files larger than available RAM via spill-to-disk.
- Parallel radix sort for in-memory chunks.
- Multiple sort orders:
coordinate— standard genomic order (tid → pos → strand); use for IGV, variant calling, etc.queryname— lexicographic read name (default sub-sort, fast).queryname::natural—samtools-compatible natural numeric order.template-coordinate— paired-end reads grouped by template position.
--verifymode — check a file's sortedness in one streaming pass without writing output.- Drop-in for
samtools sortfor the common cases.
Install
From crates.io — note the
package name is fg-mako (the unprefixed mako is taken on
crates.io by an unrelated, abandoned crate), but the installed binary
is mako:
Or grab a pre-built binary from the GitHub releases page for Linux and macOS on x86_64 and aarch64.
Usage
Sort by coordinate:
Sort by query name (samtools-compatible natural order):
Verify sort order without rewriting:
Run mako --help for the full list of options including memory limits,
temp-directory placement, compression level, and verification mode.
Sort orders
--order |
Order | Typical use |
|---|---|---|
coordinate |
tid → pos → strand |
IGV, variant calling, indexing |
queryname |
Lexicographic read name (default) | Fast queryname sort |
queryname::natural |
Natural numeric read name | samtools-compatible |
template-coordinate |
Paired reads grouped by template | UMI grouping pipelines |
Performance
Mako inherits its sort engine from fgumi.
On a 30M-read WGS BAM, the engine sorts roughly 1.9× faster than
samtools sort for template-coordinate order. See the fgumi
documentation for detailed benchmarks and tuning guidance.
Built on
mako is a focused packaging of the SAM/BAM sort engine from
fgumi. All sort logic lives
upstream; mako tracks fgumi releases and exists to provide a small,
stable, easily installed sort binary for users who don't need fgumi's
broader UMI tooling.
Contributing
See CONTRIBUTING.md. Issues that look like sort engine bugs (correctness, performance) belong on the fgumi issue tracker; mako-specific issues (CLI ergonomics, packaging, distribution) belong here.
License
MIT — see LICENSE and THIRDPARTY.toml.