# BWA: the Burrows-Wheeler aligner that the field is moving past

> lh3/bwa is a C implementation of the Burrows-Wheeler transform based short read aligner, with three algorithms covering different read lengths, and it is the tool many pipelines still call. Its own README now points long reads at minimap2 and short reads at minibwa, which makes it a project to understand and plan around rather than to newly adopt.

**lh3/bwa** — Burrow-Wheeler Aligner for short-read alignment (see minimap2 for long-read alignment)

- Repository: https://github.com/lh3/bwa
- Stars: 1,769 · Forks: 580
- Language: C
- License: GPL-3.0
- Published: 2026-10-16 · Updated: 2026-10-16 · Language: en
- Canonical page: https://hysenlabs.com/projects/lh3-bwa

## Three algorithms behind one executable

BWA is a software package for mapping DNA sequences against a large reference genome, such as the human genome, and it consists of three algorithms. BWA-backtrack is designed for Illumina sequence reads up to 100 base pairs. BWA-SW and BWA-MEM are for longer sequences, ranging from 70 base pairs to a few megabases.

BWA-MEM is the one most people mean when they say BWA. It is the latest of the three, and it is generally recommended because it is faster and more accurate, and it also performs better than BWA-backtrack for reads in the 70 to 100 base pair range. BWA-MEM and BWA-SW share similar features such as support for long reads and chimeric alignment, which is the ability to report a read that spans a breakpoint as two separate alignments.

The structure of the tool is worth understanding because the sub-commands are not interchangeable. For all the algorithms, BWA first needs to construct the FM-index for the reference genome, which is the index command. The alignment algorithms are then invoked with different sub-commands: aln, samse, and sampe for BWA-backtrack, bwasw for BWA-SW, and mem for BWA-MEM.

That means the same executable, and the same index, serves all three algorithms. If you have a reference genome indexed once, you can align with any of them, and the choice of algorithm is a property of the reads rather than of the reference.

The primary language is C, the project is GPLv3 licensed, and the last push to the repository was on 2026-08-07. The most recent release is v0.7.19, BWA-0.7.19 (r1273), published on 2025-03-22, after v0.7.18 in April 2024 and v0.7.17 in October 2017.

## Building it, and the whole pipeline in four lines

The build is a make and a single dependency, which is the first thing that distinguishes this from the modern bioinformatic toolchain.

```
git clone https://github.com/lh3/bwa.git
cd bwa; make
./bwa index ref.fa
./bwa mem ref.fa read-se.fq.gz | gzip -3 > aln-se.sam.gz
./bwa mem ref.fa read1.fq read2.fq | gzip -3 > aln-pe.sam.gz
```

Those five lines are the complete workflow. You clone, compile, build the FM-index once, and then align, with the output piped through gzip at level 3, which is the compression level that trades a little size for a lot of speed, a sensible choice when the SAM file is large and gets written once.

The README states that the only dependency required to build BWA is zlib, and that after acquiring the source you simply use make to compile and copy the single executable bwa to the destination you want. A single binary with one library dependency is a genuine operational advantage in a bioinformatics environment, where a tool that pulls in a dozen transitive dependencies is a tool that breaks when a cluster image is rebuilt.

The Makefile shows how little there is to it. The compiler is gcc by default, the flags are -g -Wall -Wno-unused-function -O3, the library list is -lm -lz -lpthread with -lrt added on Linux and on GNU/kFreeBSD, and the program is linked from a static archive libbwa.a plus the algorithm-specific objects. There is a separate bwamem-lite target, and the asan variable switches on the address sanitizer with -fsanitize=address, which is how a memory tool of this kind gets debugged.

The source layout matches the algorithms. The top level is a wall of C and header files named after what they do, bwt.c for the Burrows-Wheeler transform, bwtindex.c for indexing, bwamem.c and bwamem_pair.c for the MEM algorithm, bwashm.c for BWA-SW, bwase.c for backtrack, bamlite.c for the alignment output, and the small utility libraries khash.h, kstring.h, kvec.h, ksort.h, and kbtree.h that Heng Li wrote for this and reused elsewhere.

## Choosing the algorithm from the read length

The FAQ answers the first question with a table of recommended settings, and the table is the practical guide to using the tool.

For Illumina, 454, or IonTorrent single-end reads longer than about 70 base pairs, or assembly contigs up to a few megabases mapped to a closely related reference genome, the recommendation is bwa mem. For single-end reads shorter than about 70 base pairs, the recommendation drops to the older three-step path:

```
bwa aln ref.fa reads.fq > reads.sai; bwa samse ref.fa reads.sai reads.fq > aln-se.sam
```

For paired-end reads longer than about 70 base pairs, it is bwa mem with both files. For paired-end reads shorter than about 70 base pairs, the path is aln for each mate followed by sampe to pair them up:

```
bwa aln ref.fa read1.fq > read1.sai; bwa aln ref.fa read2.fq > read2.sai
bwa sampe ref.fa read1.sai read2.sai read1.fq read2.fq > aln-pe.sam
```

For PacBio subreads and Oxford Nanopore reads, bwa mem with a preset is the route, with -x pacbio and -x ont2d.

The reason BWA-MEM is recommended for query sequences longer than about 70 base pairs across a variety of error rates is stated in the FAQ: it is more tolerant with errors given longer query sequences, because the chance of missing all seeds is small. And the documentation is explicit that with non-default settings it works with Oxford Nanopore reads whose sequencing error rate is over 20 percent. That is the case where the older algorithms, which were designed around Illumina's low error rate, stop working entirely.

## The behaviour questions that come up in practice

The FAQ covers the questions that come up in real pipelines, and several of them describe genuine subtleties in the output.

The first is why a read can appear more than once in the SAM output. BWA-SW and BWA-MEM perform local alignments, so if there is a translocation, a gene fusion, or a long deletion, a read bridging the breakpoint has two hits and occupies two lines. With the default BWA-MEM setting, one and only one line is primary and is soft clipped, and the other lines are tagged with the 0x800 SAM flag for a supplementary alignment and are hard clipped. Downstream tools that ignore the supplementary flag will therefore mis-handle reads that span a structural variant.

The second is mapping quality. The documentation is clear that mapping quality is assigned for an individual read, not for a read pair, so it is possible for one mate to have a high mapping quality and the other to have zero, and that this is correct rather than a bug. A filtering rule written at the pair level rather than the read level will therefore behave unexpectedly.

The third is the reference size limit. Since 0.6.x all BWA algorithms work with a genome with total length over 4GB, but an individual chromosome should not be longer than 2GB. The 2GB per chromosome limit is a real constraint for some assemblies, and it comes from the file format choices the tool makes rather than from the algorithm.

The fourth is memory, and the answer to why BWA uses a lot of memory is one of the FAQ entries in its own right.

## The replacement note at the top of the README

The most consequential thing in the repository is a note at the top of the README, and it is the reason to read this project carefully rather than just install it.

BWA-MEM has been replaced by minimap2 for long reads, and will be replaced by minibwa for short reads. If you still prefer the exact legacy output of BWA-MEM, the README suggests BWA-MEM2 or the compatibility mode of BWA-MEM3.

Only minimap2 is by the same author; the two fallbacks are separate projects. minimap2 is the same author's aligner for long reads, and the README frames it as the long-read replacement. minibwa is the announced short-read successor to BWA-MEM, and it is the one to watch if you are planning a migration.

The two fallbacks are worth understanding separately. BWA-MEM2 is a different project, maintained separately, that reproduces the legacy BWA-MEM output. BWA-MEM3 is a different project again, from a different organisation, and the compatibility mode is the part that matches legacy behaviour. So the advice is not that the exact old output is gone, it is that keeping it means depending on a third-party project rather than on lh3/bwa itself.

What this means in practice is that BWA is a project to plan around rather than to newly adopt. It is not abandoned, the last push was on 2026-08-07, and it remains a small, fast, dependency-light tool that a great deal of existing infrastructure depends on. But the author is telling you, in the first lines of the README, that the recommended path for new work is elsewhere.

## The bwakit bundle, and the citation rules

Two practical arrangements are documented that matter for anyone running BWA at scale.

The first is bwakit, a self-consistent package that, since 0.7.11, includes a precompiled binary for x86_64-linux. It is not just BWA: the package also comes with BWA-associated and third-party tools for proper BAM to FASTQ conversion, mapping to ALT contigs, adapter trimming, duplicate marking, HLA typing, and associated data files. The point of the bundle is version consistency, since a pipeline that mixes a BAM to FASTQ tool from one release with an aligner from another is a pipeline that produces subtly wrong output.

The second is the citation. The README asks for a different reference depending on which algorithm you used. The BWA-backtrack paper is Li and Durbin from 2009 on fast and accurate short read alignment with the Burrows-Wheeler transform, in Bioinformatics volume 25, pages 1754 to 1760. The BWA-SW paper is Li and Durbin from 2010 on long-read alignment, in Bioinformatics volume 26, pages 589 to 595. The BWA-MEM reference is Li's 2013 preprint, Aligning sequence reads, clone sequences and assembly contigs with BWA-MEM, arXiv:1303.3997v2, and the note about it is that it is a preprint hosted on arXiv.org and the author does not plan to submit it to a peer-reviewed journal in the near future. The same reference also covers the fastmap command and the package as a whole.

The man page ships with the source and can be read with man ./bwa.1 in a terminal, and an HTML version is on the BWA website. The support channels are a mailing list at bio-bwa-help@sourceforge.net, and the BioStar and SEQanswers forums.

## Conclusion

Adopt BWA if you are maintaining an existing pipeline that already calls bwa mem, since it is stable, small, and fast to build. Do not start a new short read pipeline on BWA-MEM, because the author states it is being replaced by minibwa. Verify first which of the three algorithms your data needs, since the shorter than roughly 70 base pair path uses a completely different set of sub-commands.

## FAQ

### What are the three algorithms in BWA and which should I use?

BWA-backtrack is for Illumina reads up to 100bp, while BWA-SW and BWA-MEM are for longer sequences from 70bp to a few megabases. BWA-MEM is generally recommended because it is faster and more accurate, and it also performs better than BWA-backtrack for 70 to 100bp reads.

### How do I build BWA and run my first alignment?

Clone the repository, run make, then run ./bwa index ref.fa to build the FM-index, and align with ./bwa mem ref.fa reads.fq.gz for single-end or ./bwa mem ref.fa read1.fq read2.fq for paired-end. The only dependency required to build BWA is zlib, and the result is a single executable named bwa.

### Why does the BWA README tell me to use another aligner?

The note says BWA-MEM has been replaced by minimap2 for long reads and will be replaced by minibwa for short reads. If you prefer the exact legacy output, the README points to BWA-MEM2 or the compatibility mode of BWA-MEM3, both separate projects.

### Why does a read appear twice in my BWA SAM output?

BWA-SW and BWA-MEM perform local alignments, so a read bridging a translocation, a gene fusion, or a long deletion has two hits and takes two lines. With the default setting, one line is primary and soft clipped and the others carry the 0x800 supplementary alignment flag and are hard clipped.

### Does BWA handle a human reference genome and long chromosomes?

Yes. Since 0.6.x all BWA algorithms work with a genome with total length over 4GB. The constraint is that an individual chromosome should not be longer than 2GB, and the documentation has a separate FAQ entry on ALT contigs in the GRCh38 release.

## Sources

- [Issues](https://github.com/lh3/bwa/issues)
- [lh3/bwa on GitHub](https://github.com/lh3/bwa)
- [License: GPL-3.0](https://github.com/lh3/bwa/blob/master/LICENSE)
- [README](https://github.com/lh3/bwa/blob/master/README.md)
- [Releases](https://github.com/lh3/bwa/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/lh3-bwa
