# hifiasm: Haplotype-Resolved Assembly Without a Separate Purging Step

> hifiasm is a MIT licensed C++ assembler that resolves haplotypes directly from PacBio HiFi reads and purges haplotig duplications itself, so the pipeline does not need purge_dups or a polishing stage. It suits genome teams assembling heterozygous samples where phased output matters.

**chhylp123/hifiasm** — Hifiasm: a haplotype-resolved assembler for accurate Hifi reads 

- Repository: https://github.com/chhylp123/hifiasm
- Stars: 818 · Forks: 134
- Language: C++
- License: MIT
- Published: 2026-10-20 · Updated: 2026-10-20 · Language: en
- Canonical page: https://hysenlabs.com/projects/chhylp123-hifiasm

## Building the assembler from source

hifiasm is a C++ assembler that builds with make, and the requirement list is short: g++ and zlib. The documentation is explicit that no Python, R or C++11 compiler is needed, and that the result is a single executable. That matters more than it sounds, because assemblers are usually the part of a pipeline that drags in a Python environment and a package manager, and this one does not.

```sh
# Install hifiasm (requiring g++ and zlib)
git clone https://github.com/chhylp123/hifiasm
cd hifiasm && make
```

The Makefile confirms the shape of the thing. The compiler flags are `-g -O3 -msse4.2 -mpopcnt -fomit-frame-pointer -Wall`, so the build assumes a reasonably modern x86 machine, and the only libraries linked are `-lz -lpthread -lm`. There is also an `asan` build switch that adds address sanitisation to the compiler flags and the link line, which is a useful thing to have available when an assembly crashes on an awkward input. The source is flat C++ with headers and sources at the repository root, including dedicated files for the trio binning path, Hi-C handling, duplication purging and the GFA output writer.

## A first run on the bundled test data

The getting started section walks through a run on a small dataset, which is the right way to size up the tool before pointing it at a human genome. The test data is a compressed FASTA of chromosome 11, and the `-f0` flag is used because the initial bloom filter is memory hungry.

```sh
# Run on test data (use -f0 for small datasets)
wget https://github.com/chhylp123/hifiasm/releases/download/v0.7/chr11-2M.fa.gz
./hifiasm -o test -t4 -f0 chr11-2M.fa.gz 2> test.log
awk '/^S/{print ">"$2;print $3}' test.bp.p_ctg.gfa > test.p_ctg.fa  # get primary contigs in FASTA
```

Two conventions are established here and they carry through everything else. The `-t` option sets the number of CPUs in use, and `-o` sets the prefix of the output files, so the outputs of a run are named after the prefix rather than after the input. The primary contigs land in a GFA file with the `.bp.p_ctg.gfa` suffix, and the awk one-liner converts that GFA into FASTA, since the assembly graph is not directly a sequence file.

## Phasing that comes out of the assembler, not out of a later tool

The output structure is where the haplotype resolution shows. The primary contigs are written to `NA12878.asm.bp.p_ctg.gfa`, and since version 0.15 the assembler also produces two sets of partially phased contigs at `NA12878.asm.bp.hap?.p_ctg.gfa`. Those two files can be read as the two haplotypes of a diploid genome, with the caveat that occasional switch errors remain, and the frequency of those switches is determined by the heterozygosity of the input sample. That is a different contract from an assembler that emits one collapsed contig set: you get two haplotypes with a known error mode, and the phasing quality is a function of how heterozygous the sample is rather than something you can tune afterwards. The typical single-dataset invocation is short.

```sh
hifiasm -o NA12878.asm -t 32 NA12878.fq.gz
```

## Purging duplications inside the assembler

The claim that distinguishes hifiasm in practice is that it purges duplications between haplotigs without relying on third-party tools such as purge_dups, and that it does not need polishing tools like pilon or racon. The project describes this as simplifying the assembly pipeline and saving running time, since duplication purging normally happens after assembly and has to re-analyse the graph. The mechanism is enabled by default, and the readme documents the inverse case as well: for inbred or homozygous genomes you disable purging with `-l0`, since a homozygous sample has no true duplicates to purge and purging would only remove real sequence. Other documented options cover read trimming and memory: old HiFi reads can contain short adapter sequences at the ends, and `-z20` trims 20 bases from both ends. For small genomes `-f0` disables the initial bloom filter, which otherwise takes 16GB of memory at the start, while genomes much larger than human are better served by `-f38` or `-f39` to save memory during k-mer counting.

## Hi-C, trio binning and ultralong reads

Beyond plain HiFi, the assembler supports three ways of adding phasing information. Hi-C integration takes paired-end Hi-C reads in two FASTQ files with `--h1` and `--h2`, and in this mode each contig is supposed to come from one parental haplotype. The documentation is candid about the limits: hifiasm often puts all contigs from the same parental chromosome into one assembly, it has cleanly separated chrX and chrY for a human male dataset, phasing across centromeres is challenging, and contigs from different parental chromosomes are randomly mixed because phasing across chromosomes with Hi-C is not possible. Trio binning uses counts built by yak for the father and mother, with the two count files passed as `-1` and `-2`. Ultralong ONT reads are added with `--ul`, and ONT reads can also be assembled on their own using `--ont`, which requires input reads in FASTQ format.

## What hifiasm does not do for you

The limitation the readme states most plainly is scaffolding. hifiasm does not perform scaffolding, and you need a standalone scaffolder such as SALSA or 3D-DNA to scaffold phased haplotigs. That is a real structural gap in a pipeline, because scaffolding is what turns contigs into chromosome-scale sequences, and doing it separately means the two steps cannot share their own view of the graph. The `--dual-scaf` option exists and is described as improving contiguity for diploid genome assembly by self-scaffolding, which suggests some of the gap is being closed, but the primary statement in the limitations section still points to an external tool. The telomeres are also a separate concern: `--telo-m CCCTAA` preserves more telomeres for human genomes, so getting complete chromosome ends is something you ask the assembler for explicitly rather than something it guarantees.

## Reusing overlaps instead of recomputing them

One operational detail is worth planning for. At the first run, hifiasm saves corrected reads and overlaps to disk as `NA12878.asm.*.bin`, and it reuses those saved results to avoid the time-consuming all-versus-all overlap calculation on the next run. If you change the input reads in a way that invalidates the overlaps, you can ask it to ignore the precomputed values and redo overlapping from the raw reads with `-i`. The same reuse applies to the corrected reads, which you can dump as FASTA, and to the overlaps, which you can dump in PAF format.

```sh
hifiasm -o NA12878.asm -t 32 --write-paf --write-ec /dev/null
```

Writing the error-corrected reads to `/dev/null` keeps them out of your disk usage while still producing the PAF overlap dump. The speed claim in the project documentation is that a human genome can be assembled in half a day and a roughly 30Gb redwood genome in three days.

## Release history and the state of the code

The version history has a long tail and one recent entry. Releases 0.23.0 and 0.24.0 came in December 2024, 0.25.0 followed on 2025-03-18, and the last push to the repository was on 2026-05-31. The releases are tagged with a revision suffix, such as Hifiasm-0.25.0-r726, which points to a specific upstream revision rather than only a version number, and the readme refers to feature availability by revision as well, for example the ONT support having arrived in version 0.21.0 at revision r686 and later releases being required for it. The licence is MIT, and there is a code of conduct alongside the documentation directory. The project also names the Human Pangenome Project as using it as the assembler of choice for the first batch of samples, which is a strong external signal that the phasing output holds up on real human samples.

## Conclusion

hifiasm fits a team assembling a heterozygous or telomere-to-telomere genome that wants phasing and duplication purging in one tool instead of a multi-step pipeline. It is the wrong choice if you need scaffolding, since the project states it does not perform scaffolding and points you to a standalone tool, or if you lack HiFi depth, since the whole design assumes high-accuracy reads. Before running a large assembly, run the small test dataset in the getting started section and inspect the primary contig GFA.

## FAQ

### How do I build hifiasm and run it on test data?

Clone the repository, run make inside the hifiasm directory, then fetch the bundled chromosome 11 test data and run ./hifiasm -o test -t4 -f0 on it. The -f0 flag avoids the initial bloom filter, which would otherwise take 16GB of memory.

### Does hifiasm need purge_dups or a polishing step?

No. The project states that hifiasm purges duplications between haplotigs itself without third-party tools like purge_dups, and does not need polishing tools like pilon or racon. Purging is on by default and is disabled with -l0 for inbred or homozygous genomes.

### Where are the phased haplotypes in the hifiasm output?

Since version 0.15 the assembler writes two sets of partially phased contigs at NA12878.asm.bp.hap?.p_ctg.gfa, alongside the primary contigs in NA12878.asm.bp.p_ctg.gfa. Switch errors can occur, and their frequency depends on the heterozygosity of the sample.

### Does hifiasm do scaffolding?

No. The documentation says hifiasm does not perform scaffolding and that you need a standalone scaffolder such as SALSA or 3D-DNA to scaffold phased haplotigs, although a self-scaffolding option called --dual-scaf exists.

### Can hifiasm assemble ONT reads?

Yes. Since version 0.21.0 at revision r686, adding the --ont option assembles ONT simplex R10 reads, and that module requires the input reads in FASTQ format. Ultralong ONT reads can also be combined with HiFi and Hi-C using the --ul option.

## Sources

- [chhylp123/hifiasm on GitHub](https://github.com/chhylp123/hifiasm)
- [Issues](https://github.com/chhylp123/hifiasm/issues)
- [License: MIT](https://github.com/chhylp123/hifiasm/blob/master/LICENSE)
- [README](https://github.com/chhylp123/hifiasm/blob/master/README.md)
- [Releases](https://github.com/chhylp123/hifiasm/releases)

---

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