# yukiteruono/pbsim3 architecture

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

- Interactive diagram: https://gitdiagram.com/yukiteruono/pbsim3
- Repository: https://github.com/yukiteruono/pbsim3

## Overview

PBSIM is a command-line long-read sequencing simulator. The documented workflow selects a sequencing strategy and simulation method, reads reference or user-provided sequence data and applicable model/profile data, simulates reads and errors, then emits reads and alignments. The implementation is concentrated in `src/pbsim.cpp`; the README documents several modes beyond the sampled code excerpts, so their internal wiring is represented only where supported. Multi-pass output can be passed to external CCS software to generate HiFi reads.

Main entry points: [`src/pbsim.cpp`](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp) (CLI and dispatch), [`data/QSHMM-RSII.model`](https://github.com/yukiteruono/pbsim3/blob/master/data/QSHMM-RSII.model) (QSHMM models), [`data/ERRHMM-RSII.model`](https://github.com/yukiteruono/pbsim3/blob/master/data/ERRHMM-RSII.model) (ERRHMM models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Run orchestration"]
  node_main["CLI and dispatch<br/>[pbsim.cpp]"]
end

subgraph group_modes["Simulation modes"]
  node_wgs["WGS simulation<br/>[pbsim.cpp]"]
  node_trans["Transcript simulation<br/>[pbsim.cpp]"]
  node_templ["Template simulation<br/>[pbsim.cpp]"]
end

subgraph group_models["Models and sampling"]
  node_qshmm["Quality model<br/>[pbsim.cpp]"]
  node_errhmm["Error model<br/>[pbsim.cpp]"]
  node_sample["Read sampling<br/>[pbsim.cpp]"]
  node_qshmmfiles["QSHMM models<br/>[QSHMM-RSII.model]"]
  node_errhmmfiles["ERRHMM models<br/>[ERRHMM-RSII.model]"]
  node_profile["Sample profiles"]
end

subgraph group_output["Output and integration"]
  node_output["Read and alignment files"]
end

node_user(("PBSIM user"))
node_genome["Reference genome"]
node_transcriptdata["Transcript inputs"]
node_templatedata["Template inputs"]
node_sampledata["Real read data"]
node_gzip["gzip"]
node_ccs["CCS software"]

node_user -->|"configures"| node_main
node_main -->|"dispatches"| node_wgs
node_main -->|"dispatches"| node_trans
node_main -->|"dispatches"| node_templ
node_wgs -->|"reads"| node_genome
node_trans -->|"reads"| node_transcriptdata
node_templ -->|"reads"| node_templatedata
node_wgs -->|"uses"| node_qshmm
node_wgs -->|"uses"| node_errhmm
node_wgs -->|"uses"| node_sample
node_trans -->|"uses"| node_qshmm
node_trans -->|"uses"| node_errhmm
node_templ -->|"uses"| node_qshmm
node_templ -->|"uses"| node_errhmm
node_qshmm -->|"loads"| node_qshmmfiles
node_errhmm -->|"loads"| node_errhmmfiles
node_sample -->|"reads"| node_sampledata
node_sample -->|"stores or reuses"| node_profile
node_wgs -->|"writes"| node_output
node_trans -->|"writes"| node_output
node_templ -->|"writes"| node_output
node_main -->|"compresses MAF"| node_gzip
node_main -.->|"provides multi-pass BAM"| node_ccs

click node_main "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_wgs "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_trans "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_templ "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_qshmm "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_errhmm "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_sample "https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp"
click node_qshmmfiles "https://github.com/yukiteruono/pbsim3/blob/master/data/QSHMM-RSII.model"
click node_errhmmfiles "https://github.com/yukiteruono/pbsim3/blob/master/data/ERRHMM-RSII.model"

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_main,node_user toneBlue
class node_wgs,node_trans,node_templ toneAmber
class node_qshmm,node_errhmm,node_sample,node_qshmmfiles,node_errhmmfiles,node_profile toneMint
class node_output toneRose
class node_genome,node_transcriptdata,node_templatedata,node_sampledata,node_gzip,node_ccs toneIndigo
```

## Components

### Run orchestration

- [CLI and dispatch](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`

### Simulation modes

- [WGS simulation](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`
- [Transcript simulation](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`
- [Template simulation](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`

### Models and sampling

- [Quality model](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`
- [Error model](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`
- [Read sampling](https://github.com/yukiteruono/pbsim3/blob/master/src/pbsim.cpp): `src/pbsim.cpp`
- [QSHMM models](https://github.com/yukiteruono/pbsim3/blob/master/data/QSHMM-RSII.model): `data/QSHMM-RSII.model`
- [ERRHMM models](https://github.com/yukiteruono/pbsim3/blob/master/data/ERRHMM-RSII.model): `data/ERRHMM-RSII.model`
- **Sample profiles**

### Output and integration

- **Read and alignment files**

### Other components

- **PBSIM user**
- **Reference genome**
- **Transcript inputs**
- **Template inputs**
- **Real read data**
- **gzip**
- **CCS software**

## Connections

- PBSIM user → CLI and dispatch: configures
- CLI and dispatch → WGS simulation: dispatches
- CLI and dispatch → Transcript simulation: dispatches
- CLI and dispatch → Template simulation: dispatches
- WGS simulation → Reference genome: reads
- Transcript simulation → Transcript inputs: reads
- Template simulation → Template inputs: reads
- WGS simulation → Quality model: uses
- WGS simulation → Error model: uses
- WGS simulation → Read sampling: uses
- Transcript simulation → Quality model: uses
- Transcript simulation → Error model: uses
- Template simulation → Quality model: uses
- Template simulation → Error model: uses
- Quality model → QSHMM models: loads
- Error model → ERRHMM models: loads
- Read sampling → Real read data: reads
- Read sampling → Sample profiles: stores or reuses
- WGS simulation → Read and alignment files: writes
- Transcript simulation → Read and alignment files: writes
- Template simulation → Read and alignment files: writes
- CLI and dispatch → gzip: compresses MAF
- CLI and dispatch → CCS software: provides multi-pass BAM
