# illumina/expansionhunter architecture

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

- Interactive diagram: https://gitdiagram.com/illumina/expansionhunter
- Repository: https://github.com/illumina/expansionhunter

## Overview

Expansion Hunter estimates repeat sizes and analyzes variation at targeted genomic loci from BAM/CRAM reads. Its principal workflow loads run parameters, a reference and locus catalog; constructs locus specifications and sequence graphs; analyzes reads and genotypes repeat or small-variant findings; then writes result files. The README documents read evidence spanning, flanking, or contained within repeats. Some sample-analysis and genotyping connections are only partially visible in the supplied excerpts, so those links are marked unverified rather than asserted as direct calls.

Main entry points: [`ehunter/locus/LocusAnalyzer.cpp`](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/LocusAnalyzer.cpp) (Locus analyzer), [`ehunter/locus/VariantFindings.cpp`](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/VariantFindings.cpp) (Variant findings), [`ehunter/sample`](https://github.com/illumina/expansionhunter/tree/master/ehunter/sample) (Sample analysis), [`ehunter/locus/LocusAligner.cpp`](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/LocusAligner.cpp) (Locus alignment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Inputs and setup"]
  node_parameters["Parameter loading"]
  node_catalog["Locus catalog<br/>[CatalogLoading.cpp]"]
  node_locusdecode["Locus decoding"]
  node_graphblueprint["Graph blueprint<br/>[GraphBlueprint.cpp]"]
end

subgraph group_analysis["Locus analysis"]
  node_sampleanalysis["Sample analysis"]
  node_locusanalyzer["Locus analyzer<br/>[LocusAnalyzer.cpp]"]
  node_locusaligner["Locus alignment<br/>[LocusAligner.cpp]"]
  node_alignmentops["Alignment operations"]
  node_intersector["Alignment intersection"]
end

subgraph group_inference["Findings and inference"]
  node_repeatanalysis["Repeat analysis<br/>[RepeatAnalyzer.cpp]"]
  node_smallvariant["Small-variant analysis"]
  node_stralign["STR alignment<br/>[StrAlign.cpp]"]
  node_strgenotype["STR genotyping<br/>[StrGenotyper.cpp]"]
  node_smallgenotype["Small-variant genotyping"]
  node_rfc1["RFC1 motif analysis"]
  node_findings["Variant findings"]
end

subgraph group_outputs["Result outputs"]
  node_bamlet["Alignment output<br/>[BamletWriter.cpp]"]
  node_vcf["VCF output<br/>[VcfWriter.cpp]"]
  node_json["JSON output<br/>[JsonWriter.cpp]"]
end

node_operator(("Analyst"))
node_bamcram["BAM / CRAM"]
node_reference["Reference genome"]

node_operator -->|"supplies options"| node_parameters
node_operator -.->|"provides reads"| node_bamcram
node_reference -->|"provides sequence"| node_locusdecode
node_parameters -->|"configures run"| node_sampleanalysis
node_catalog -.->|"supplies loci"| node_locusdecode
node_locusdecode -->|"uses graph blueprint"| node_graphblueprint
node_sampleanalysis -.->|"analyzes loci"| node_locusanalyzer
node_sampleanalysis -.->|"searches reads"| node_bamcram
node_locusanalyzer -->|"constructs aligner"| node_locusaligner
node_locusanalyzer -->|"creates analyzer"| node_repeatanalysis
node_locusanalyzer -->|"creates analyzer"| node_smallvariant
node_locusanalyzer -->|"runs analysis"| node_rfc1
node_locusaligner -.->|"uses operations"| node_alignmentops
node_alignmentops -->|"uses intersection"| node_intersector
node_repeatanalysis -.->|"estimates genotype"| node_strgenotype
node_strgenotype -.->|"uses STR alignments"| node_stralign
node_smallvariant -.->|"estimates genotype"| node_smallgenotype
node_locusanalyzer -.->|"produces findings"| node_findings
node_rfc1 -->|"updates findings"| node_findings
node_findings -->|"formats results"| node_vcf
node_findings -->|"writes results"| node_json
node_locusaligner -.->|"writes alignments"| node_bamlet
node_operator -.->|"requests analysis"| node_vcf

click node_parameters "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/ParameterLoading.cpp"
click node_catalog "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/CatalogLoading.cpp"
click node_locusdecode "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/LocusSpecDecoding.cpp"
click node_graphblueprint "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/GraphBlueprint.cpp"
click node_sampleanalysis "https://github.com/illumina/expansionhunter/tree/master/ehunter/sample"
click node_locusanalyzer "https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/LocusAnalyzer.cpp"
click node_locusaligner "https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/LocusAligner.cpp"
click node_alignmentops "https://github.com/illumina/expansionhunter/blob/master/ehunter/alignment/OperationsOnAlignments.cpp"
click node_intersector "https://github.com/illumina/expansionhunter/blob/master/ehunter/alignment/GreedyAlignmentIntersector.cpp"
click node_repeatanalysis "https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/RepeatAnalyzer.cpp"
click node_smallvariant "https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/SmallVariantAnalyzer.cpp"
click node_stralign "https://github.com/illumina/expansionhunter/blob/master/ehunter/genotyping/StrAlign.cpp"
click node_strgenotype "https://github.com/illumina/expansionhunter/blob/master/ehunter/genotyping/StrGenotyper.cpp"
click node_smallgenotype "https://github.com/illumina/expansionhunter/blob/master/ehunter/genotyping/SmallVariantGenotyper.cpp"
click node_rfc1 "https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/RFC1MotifAnalysis.cpp"
click node_findings "https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/VariantFindings.cpp"
click node_bamlet "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/BamletWriter.cpp"
click node_vcf "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/VcfWriter.cpp"
click node_json "https://github.com/illumina/expansionhunter/blob/master/ehunter/io/JsonWriter.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_parameters,node_catalog,node_locusdecode,node_graphblueprint toneBlue
class node_sampleanalysis,node_locusanalyzer,node_locusaligner,node_alignmentops,node_intersector toneAmber
class node_repeatanalysis,node_smallvariant,node_stralign,node_strgenotype,node_smallgenotype,node_rfc1,node_findings toneMint
class node_bamlet,node_vcf,node_json toneRose
class node_operator,node_bamcram,node_reference toneIndigo
```

## Components

### Inputs and setup

- [Parameter loading](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/ParameterLoading.cpp): `ehunter/io/ParameterLoading.cpp`
- [Locus catalog](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/CatalogLoading.cpp): `ehunter/io/CatalogLoading.cpp`
- [Locus decoding](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/LocusSpecDecoding.cpp): `ehunter/io/LocusSpecDecoding.cpp`
- [Graph blueprint](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/GraphBlueprint.cpp): `ehunter/io/GraphBlueprint.cpp`

### Locus analysis

- [Sample analysis](https://github.com/illumina/expansionhunter/tree/master/ehunter/sample): `ehunter/sample`
- [Locus analyzer](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/LocusAnalyzer.cpp): `ehunter/locus/LocusAnalyzer.cpp`
- [Locus alignment](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/LocusAligner.cpp): `ehunter/locus/LocusAligner.cpp`
- [Alignment operations](https://github.com/illumina/expansionhunter/blob/master/ehunter/alignment/OperationsOnAlignments.cpp): `ehunter/alignment/OperationsOnAlignments.cpp`
- [Alignment intersection](https://github.com/illumina/expansionhunter/blob/master/ehunter/alignment/GreedyAlignmentIntersector.cpp): `ehunter/alignment/GreedyAlignmentIntersector.cpp`

### Findings and inference

- [Repeat analysis](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/RepeatAnalyzer.cpp): `ehunter/locus/RepeatAnalyzer.cpp`
- [Small-variant analysis](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/SmallVariantAnalyzer.cpp): `ehunter/locus/SmallVariantAnalyzer.cpp`
- [STR alignment](https://github.com/illumina/expansionhunter/blob/master/ehunter/genotyping/StrAlign.cpp): `ehunter/genotyping/StrAlign.cpp`
- [STR genotyping](https://github.com/illumina/expansionhunter/blob/master/ehunter/genotyping/StrGenotyper.cpp): `ehunter/genotyping/StrGenotyper.cpp`
- [Small-variant genotyping](https://github.com/illumina/expansionhunter/blob/master/ehunter/genotyping/SmallVariantGenotyper.cpp): `ehunter/genotyping/SmallVariantGenotyper.cpp`
- [RFC1 motif analysis](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/RFC1MotifAnalysis.cpp): `ehunter/locus/RFC1MotifAnalysis.cpp`
- [Variant findings](https://github.com/illumina/expansionhunter/blob/master/ehunter/locus/VariantFindings.cpp): `ehunter/locus/VariantFindings.cpp`

### Result outputs

- [Alignment output](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/BamletWriter.cpp): `ehunter/io/BamletWriter.cpp`
- [VCF output](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/VcfWriter.cpp): `ehunter/io/VcfWriter.cpp`
- [JSON output](https://github.com/illumina/expansionhunter/blob/master/ehunter/io/JsonWriter.cpp): `ehunter/io/JsonWriter.cpp`

### Other components

- **Analyst**
- **BAM / CRAM**
- **Reference genome**

## Connections

- Analyst → Parameter loading: supplies options
- Analyst → BAM / CRAM: provides reads
- Reference genome → Locus decoding: provides sequence (evidence: `ehunter/io/LocusSpecDecoding.cpp`)
- Parameter loading → Sample analysis: configures run
- Locus catalog → Locus decoding: supplies loci
- Locus decoding → Graph blueprint: uses graph blueprint (evidence: `ehunter/io/LocusSpecDecoding.cpp`)
- Sample analysis → Locus analyzer: analyzes loci
- Sample analysis → BAM / CRAM: searches reads
- Locus analyzer → Locus alignment: constructs aligner (evidence: `ehunter/locus/LocusAnalyzer.cpp`)
- Locus analyzer → Repeat analysis: creates analyzer (evidence: `ehunter/locus/LocusAnalyzer.cpp`)
- Locus analyzer → Small-variant analysis: creates analyzer (evidence: `ehunter/locus/LocusAnalyzer.cpp`)
- Locus analyzer → RFC1 motif analysis: runs analysis (evidence: `ehunter/locus/LocusAnalyzer.cpp`)
- Locus alignment → Alignment operations: uses operations
- Alignment operations → Alignment intersection: uses intersection (evidence: `ehunter/alignment/OperationsOnAlignments.cpp`)
- Repeat analysis → STR genotyping: estimates genotype
- STR genotyping → STR alignment: uses STR alignments
- Small-variant analysis → Small-variant genotyping: estimates genotype
- Locus analyzer → Variant findings: produces findings
- RFC1 motif analysis → Variant findings: updates findings (evidence: `ehunter/locus/RFC1MotifAnalysis.cpp`)
- Variant findings → VCF output: formats results
- Variant findings → JSON output: writes results
- Locus alignment → Alignment output: writes alignments
- Analyst → VCF output: requests analysis
