# chhylp123/hifiasm architecture

> Architecture diagram of the GitHub repository chhylp123/hifiasm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chhylp123/hifiasm
- Repository: https://github.com/chhylp123/hifiasm

## Overview

Hifiasm is a command-line, haplotype-resolved de novo genome assembler. Its principal workflow accepts sequencing reads and options, prepares/corrects reads and overlaps, builds and refines assembly graphs, then emits contigs; optional modes add trio binning, Hi-C phasing, ONT, or ultra-long-read integration. The source index supports the main entry point and several core calls, while some README-described capabilities are represented at their documented subsystem level. Edges without sampled call-site evidence are omitted; README-backed mode links are marked with README evidence.

Main entry points: [`Assembly.cpp`](https://github.com/chhylp123/hifiasm/blob/master/Assembly.cpp) (Assembly orchestration), [`CommandLines.cpp`](https://github.com/chhylp123/hifiasm/blob/master/CommandLines.cpp) (Options and input parsing), [`Trio.cpp`](https://github.com/chhylp123/hifiasm/blob/master/Trio.cpp) (Trio binning), [`main.cpp`](https://github.com/chhylp123/hifiasm/blob/master/main.cpp) (Program entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Inputs and preparation"]
  node_cli["Options and input parsing<br/>[CommandLines.cpp]"]
  node_readprep["Read preparation<br/>[Process_Read.cpp]"]
  node_trio["Trio binning<br/>[Trio.cpp]"]
end

subgraph group_assembly["Assembly construction"]
  node_entry["Program entry<br/>[main.cpp]"]
  node_orchestrator["Assembly orchestration<br/>[Assembly.cpp]"]
  node_kmer["K-mer indexing<br/>[htab.cpp]"]
  node_overlap["Overlap discovery<br/>[ecovlp.cpp]"]
  node_graph["Overlap and assembly graphs<br/>[Overlaps.h]"]
  node_correction["Read correction<br/>[Correct.h]"]
  node_ultra["Ultra-long integration<br/>[tovlp.cpp]"]
end

subgraph group_phasing["Phasing and refinement"]
  node_hicphase["Hi-C phasing<br/>[horder.cpp]"]
  node_purging["Haplotig purging<br/>[Purge_Dups.cpp]"]
  node_refinement["Graph refinement<br/>[rcut.cpp]"]
end

subgraph group_results["Assembly results"]
  node_output["Contig and graph output<br/>[Output.cpp]"]
  node_gfa["GFA assemblies"]
end

node_user(("Sequencing user"))
node_reads["Sequencing reads"]
node_yak["Yak k-mer files"]
node_hicreads["Hi-C reads"]

node_user -->|"sets options"| node_cli
node_reads -->|"provides reads"| node_cli
node_cli -->|"configures"| node_entry
node_entry -->|"starts"| node_orchestrator
node_orchestrator -->|"uses"| node_readprep
node_orchestrator -->|"uses"| node_correction
node_orchestrator -->|"uses"| node_kmer
node_orchestrator -->|"uses"| node_overlap
node_orchestrator -->|"uses"| node_graph
node_yak -->|"supplies k-mers"| node_trio
node_trio -->|"enables binning"| node_orchestrator
node_hicreads -->|"supplies pairs"| node_hicphase
node_orchestrator -->|"supports Hi-C mode"| node_hicphase
node_reads -->|"supplies ultra-long reads"| node_ultra
node_orchestrator -->|"supports ultra-long mode"| node_ultra
node_orchestrator -->|"supports purging"| node_purging
node_orchestrator -->|"uses"| node_refinement
node_orchestrator -.->|"emits assemblies"| node_output
node_output -->|"writes"| node_gfa

click node_cli "https://github.com/chhylp123/hifiasm/blob/master/CommandLines.cpp"
click node_readprep "https://github.com/chhylp123/hifiasm/blob/master/Process_Read.cpp"
click node_trio "https://github.com/chhylp123/hifiasm/blob/master/Trio.cpp"
click node_entry "https://github.com/chhylp123/hifiasm/blob/master/main.cpp"
click node_orchestrator "https://github.com/chhylp123/hifiasm/blob/master/Assembly.cpp"
click node_kmer "https://github.com/chhylp123/hifiasm/blob/master/htab.cpp"
click node_overlap "https://github.com/chhylp123/hifiasm/blob/master/ecovlp.cpp"
click node_graph "https://github.com/chhylp123/hifiasm/blob/master/Overlaps.h"
click node_correction "https://github.com/chhylp123/hifiasm/blob/master/Correct.h"
click node_ultra "https://github.com/chhylp123/hifiasm/blob/master/tovlp.cpp"
click node_hicphase "https://github.com/chhylp123/hifiasm/blob/master/horder.cpp"
click node_purging "https://github.com/chhylp123/hifiasm/blob/master/Purge_Dups.cpp"
click node_refinement "https://github.com/chhylp123/hifiasm/blob/master/rcut.cpp"
click node_output "https://github.com/chhylp123/hifiasm/blob/master/Output.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_readprep,node_trio,node_user toneBlue
class node_entry,node_orchestrator,node_kmer,node_overlap,node_graph,node_correction,node_ultra toneAmber
class node_hicphase,node_purging,node_refinement toneMint
class node_output,node_gfa toneRose
class node_reads,node_yak,node_hicreads toneIndigo
```

## Components

### Inputs and preparation

- [Options and input parsing](https://github.com/chhylp123/hifiasm/blob/master/CommandLines.cpp): `CommandLines.cpp`
- [Read preparation](https://github.com/chhylp123/hifiasm/blob/master/Process_Read.cpp): `Process_Read.cpp`
- [Trio binning](https://github.com/chhylp123/hifiasm/blob/master/Trio.cpp): `Trio.cpp`

### Assembly construction

- [Program entry](https://github.com/chhylp123/hifiasm/blob/master/main.cpp): `main.cpp`
- [Assembly orchestration](https://github.com/chhylp123/hifiasm/blob/master/Assembly.cpp): `Assembly.cpp`
- [K-mer indexing](https://github.com/chhylp123/hifiasm/blob/master/htab.cpp): `htab.cpp`
- [Overlap discovery](https://github.com/chhylp123/hifiasm/blob/master/ecovlp.cpp): `ecovlp.cpp`
- [Overlap and assembly graphs](https://github.com/chhylp123/hifiasm/blob/master/Overlaps.h): `Overlaps.h`
- [Read correction](https://github.com/chhylp123/hifiasm/blob/master/Correct.h): `Correct.h`
- [Ultra-long integration](https://github.com/chhylp123/hifiasm/blob/master/tovlp.cpp): `tovlp.cpp`

### Phasing and refinement

- [Hi-C phasing](https://github.com/chhylp123/hifiasm/blob/master/horder.cpp): `horder.cpp`
- [Haplotig purging](https://github.com/chhylp123/hifiasm/blob/master/Purge_Dups.cpp): `Purge_Dups.cpp`
- [Graph refinement](https://github.com/chhylp123/hifiasm/blob/master/rcut.cpp): `rcut.cpp`

### Assembly results

- [Contig and graph output](https://github.com/chhylp123/hifiasm/blob/master/Output.cpp): `Output.cpp`
- **GFA assemblies**

### Other components

- **Sequencing user**
- **Sequencing reads**
- **Yak k-mer files**
- **Hi-C reads**

## Connections

- Sequencing user → Options and input parsing: sets options
- Sequencing reads → Options and input parsing: provides reads
- Options and input parsing → Program entry: configures (evidence: `main.cpp`)
- Program entry → Assembly orchestration: starts (evidence: `main.cpp`)
- Assembly orchestration → Read preparation: uses (evidence: `Assembly.cpp`)
- Assembly orchestration → Read correction: uses (evidence: `Assembly.cpp`)
- Assembly orchestration → K-mer indexing: uses (evidence: `Assembly.cpp`)
- Assembly orchestration → Overlap discovery: uses (evidence: `Assembly.cpp`)
- Assembly orchestration → Overlap and assembly graphs: uses (evidence: `Assembly.cpp`)
- Yak k-mer files → Trio binning: supplies k-mers
- Trio binning → Assembly orchestration: enables binning
- Hi-C reads → Hi-C phasing: supplies pairs
- Assembly orchestration → Hi-C phasing: supports Hi-C mode
- Sequencing reads → Ultra-long integration: supplies ultra-long reads
- Assembly orchestration → Ultra-long integration: supports ultra-long mode
- Assembly orchestration → Haplotig purging: supports purging
- Assembly orchestration → Graph refinement: uses (evidence: `Assembly.cpp`)
- Assembly orchestration → Contig and graph output: emits assemblies
- Contig and graph output → GFA assemblies: writes
