# iqtree/iqtree2 architecture

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

- Interactive diagram: https://gitdiagram.com/iqtree/iqtree2
- Repository: https://github.com/iqtree/iqtree2

## Overview

IQ-TREE is maximum-likelihood phylogenetic inference software. Its principal workflow accepts sequence alignments, represents sequence patterns and evolutionary models, searches for a likely tree, and reports the tree and analysis. The README also documents model selection, branch and topology tests, ultrafast bootstrap, partition and mixture models, and AliSim simulation. Paths for several feature branches are supported by the tree and README, but their detailed runtime connections were not sampled; those links are marked unverified rather than asserted.

Main entry points: [`main/main.cpp`](https://github.com/iqtree/iqtree2/blob/master/main/main.cpp) (Command-line app), [`model/modelmixture.cpp`](https://github.com/iqtree/iqtree2/blob/master/model/modelmixture.cpp) (Evolution models), [`tree/phylotree.cpp`](https://github.com/iqtree/iqtree2/blob/master/tree/phylotree.cpp) (Likelihood tree), [`nclextra/myreader.h`](https://github.com/iqtree/iqtree2/blob/master/nclextra/myreader.h) (NEXUS reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input data"]
  node_nexus["NEXUS reader<br/>[myreader.h]"]
  node_alignment["Alignment data<br/>[alignment.cpp]"]
  node_patterns["Pattern summary<br/>[alignmentsummary.h]"]
end

subgraph group_inference["Inference engine"]
  node_model["Evolution models<br/>[modelmixture.cpp]"]
  node_rates["Rate variation"]
  node_tree["Likelihood tree<br/>[phylotree.cpp]"]
  node_tree_search["Tree search<br/>[searchAlgo.c]"]
  node_tree_output["Tree results<br/>[mtreeset.h]"]
  node_partitions["Partition models<br/>[partitionmodel.cpp]"]
  node_mixtures["Mixture models<br/>[modelmixture.cpp]"]
  node_pomo["PoMo models<br/>[modelpomo.cpp]"]
end

subgraph group_analysis["Analysis features"]
  node_model_selection["ModelFinder<br/>[phyloanalysis.cpp]"]
  node_bootstrap["Ultrafast bootstrap<br/>[phyloanalysis.cpp]"]
  node_branch_tests["Branch tests<br/>[phylotesting.cpp]"]
  node_topology_tests["Topology tests<br/>[treetesting.cpp]"]
end

subgraph group_simulation["Simulation"]
  node_sim_command["AliSim command<br/>[alisim.cpp]"]
  node_simulator["Alignment simulator<br/>[alisimulator.cpp]"]
  node_sim_output["Simulated alignment<br/>[alignment.cpp]"]
end

node_user(("Researcher"))
node_cli["Command-line app<br/>[main.cpp]"]

node_user -->|"runs analysis"| node_cli
node_cli -.->|"loads input"| node_nexus
node_nexus -.->|"parses alignment"| node_alignment
node_alignment -.->|"summarizes sites"| node_patterns
node_cli -.->|"starts inference"| node_tree
node_tree -.->|"evaluates likelihood"| node_model
node_model -.->|"models rate variation"| node_rates
node_tree -.->|"optimizes topology"| node_tree_search
node_cli -->|"writes results"| node_tree_output
node_cli -->|"selects models"| node_model_selection
node_cli -->|"assesses support"| node_bootstrap
node_cli -->|"tests branches"| node_branch_tests
node_cli -->|"tests topologies"| node_topology_tests
node_model -->|"supports partitions"| node_partitions
node_model -->|"supports mixtures"| node_mixtures
node_model -->|"supports PoMo"| node_pomo
node_user -->|"requests simulation"| node_sim_command
node_sim_command -.->|"runs simulator"| node_simulator
node_simulator -->|"generates alignment"| node_sim_output

click node_cli "https://github.com/iqtree/iqtree2/blob/master/main/main.cpp"
click node_nexus "https://github.com/iqtree/iqtree2/blob/master/nclextra/myreader.h"
click node_alignment "https://github.com/iqtree/iqtree2/blob/master/alignment/alignment.cpp"
click node_patterns "https://github.com/iqtree/iqtree2/blob/master/alignment/alignmentsummary.h"
click node_model "https://github.com/iqtree/iqtree2/blob/master/model/modelmixture.cpp"
click node_rates "https://github.com/iqtree/iqtree2/blob/master/model/rateheterogeneity.h"
click node_tree "https://github.com/iqtree/iqtree2/blob/master/tree/phylotree.cpp"
click node_tree_search "https://github.com/iqtree/iqtree2/blob/master/pll/searchAlgo.c"
click node_tree_output "https://github.com/iqtree/iqtree2/blob/master/tree/mtreeset.h"
click node_model_selection "https://github.com/iqtree/iqtree2/blob/master/main/phyloanalysis.cpp"
click node_bootstrap "https://github.com/iqtree/iqtree2/blob/master/main/phyloanalysis.cpp"
click node_branch_tests "https://github.com/iqtree/iqtree2/blob/master/main/phylotesting.cpp"
click node_topology_tests "https://github.com/iqtree/iqtree2/blob/master/main/treetesting.cpp"
click node_partitions "https://github.com/iqtree/iqtree2/blob/master/model/partitionmodel.cpp"
click node_mixtures "https://github.com/iqtree/iqtree2/blob/master/model/modelmixture.cpp"
click node_pomo "https://github.com/iqtree/iqtree2/blob/master/model/modelpomo.cpp"
click node_sim_command "https://github.com/iqtree/iqtree2/blob/master/main/alisim.cpp"
click node_simulator "https://github.com/iqtree/iqtree2/blob/master/simulator/alisimulator.cpp"
click node_sim_output "https://github.com/iqtree/iqtree2/blob/master/alignment/alignment.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_nexus,node_alignment,node_patterns toneBlue
class node_model,node_rates,node_tree,node_tree_search,node_tree_output,node_partitions,node_mixtures,node_pomo toneAmber
class node_model_selection,node_bootstrap,node_branch_tests,node_topology_tests toneMint
class node_sim_command,node_simulator,node_sim_output toneRose
class node_user toneIndigo
class node_cli toneTeal
```

## Components

### Input data

- [NEXUS reader](https://github.com/iqtree/iqtree2/blob/master/nclextra/myreader.h): `nclextra/myreader.h`
- [Alignment data](https://github.com/iqtree/iqtree2/blob/master/alignment/alignment.cpp): `alignment/alignment.cpp`
- [Pattern summary](https://github.com/iqtree/iqtree2/blob/master/alignment/alignmentsummary.h): `alignment/alignmentsummary.h`

### Inference engine

- [Evolution models](https://github.com/iqtree/iqtree2/blob/master/model/modelmixture.cpp): `model/modelmixture.cpp`
- [Rate variation](https://github.com/iqtree/iqtree2/blob/master/model/rateheterogeneity.h): `model/rateheterogeneity.h`
- [Likelihood tree](https://github.com/iqtree/iqtree2/blob/master/tree/phylotree.cpp): `tree/phylotree.cpp`
- [Tree search](https://github.com/iqtree/iqtree2/blob/master/pll/searchAlgo.c): `pll/searchAlgo.c`
- [Tree results](https://github.com/iqtree/iqtree2/blob/master/tree/mtreeset.h): `tree/mtreeset.h`
- [Partition models](https://github.com/iqtree/iqtree2/blob/master/model/partitionmodel.cpp): `model/partitionmodel.cpp`
- [Mixture models](https://github.com/iqtree/iqtree2/blob/master/model/modelmixture.cpp): `model/modelmixture.cpp`
- [PoMo models](https://github.com/iqtree/iqtree2/blob/master/model/modelpomo.cpp): `model/modelpomo.cpp`

### Analysis features

- [ModelFinder](https://github.com/iqtree/iqtree2/blob/master/main/phyloanalysis.cpp): `main/phyloanalysis.cpp`
- [Ultrafast bootstrap](https://github.com/iqtree/iqtree2/blob/master/main/phyloanalysis.cpp): `main/phyloanalysis.cpp`
- [Branch tests](https://github.com/iqtree/iqtree2/blob/master/main/phylotesting.cpp): `main/phylotesting.cpp`
- [Topology tests](https://github.com/iqtree/iqtree2/blob/master/main/treetesting.cpp): `main/treetesting.cpp`

### Simulation

- [AliSim command](https://github.com/iqtree/iqtree2/blob/master/main/alisim.cpp): `main/alisim.cpp`
- [Alignment simulator](https://github.com/iqtree/iqtree2/blob/master/simulator/alisimulator.cpp): `simulator/alisimulator.cpp`
- [Simulated alignment](https://github.com/iqtree/iqtree2/blob/master/alignment/alignment.cpp): `alignment/alignment.cpp`

### Other components

- **Researcher**
- [Command-line app](https://github.com/iqtree/iqtree2/blob/master/main/main.cpp): `main/main.cpp`

## Connections

- Researcher → Command-line app: runs analysis
- Command-line app → NEXUS reader: loads input (evidence: `main/main.cpp`)
- NEXUS reader → Alignment data: parses alignment (evidence: `alignment/alignment.cpp`)
- Alignment data → Pattern summary: summarizes sites (evidence: `alignment/alignment.cpp`)
- Command-line app → Likelihood tree: starts inference
- Likelihood tree → Evolution models: evaluates likelihood
- Evolution models → Rate variation: models rate variation
- Likelihood tree → Tree search: optimizes topology
- Command-line app → Tree results: writes results (evidence: `main/main.cpp`)
- Command-line app → ModelFinder: selects models
- Command-line app → Ultrafast bootstrap: assesses support
- Command-line app → Branch tests: tests branches
- Command-line app → Topology tests: tests topologies
- Evolution models → Partition models: supports partitions
- Evolution models → Mixture models: supports mixtures (evidence: `model/modelmixture.cpp`)
- Evolution models → PoMo models: supports PoMo
- Researcher → AliSim command: requests simulation
- AliSim command → Alignment simulator: runs simulator
- Alignment simulator → Simulated alignment: generates alignment
