# deepomicslab/spechla architecture

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

- Interactive diagram: https://gitdiagram.com/deepomicslab/spechla
- Repository: https://github.com/deepomicslab/spechla

## Overview

SpecHLA is a sequencing-based HLA typing and loss-of-heterozygosity (LOH) product. Its documented user workflow accepts paired-end reads, optionally combined with long, Hi-C, or 10X data, and produces diploid HLA typing; related documented modes include read extraction, assembly-based typing, and LOH detection. The sampled C++ executable provides a visible phasing entry point and supporting data components. Most high-level workflows are documented in the README but their driver scripts are absent from this file tree, so those links are documentation-based rather than inferred calls.

Main entry points: [`script`](https://github.com/deepomicslab/spechla/tree/master/script) (Typing modes), [`bin/SpecHap/phaser.h`](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/phaser.h) (Phaser), [`bin/SpecHap/results.h`](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/results.h) (Typing results), [`bin/SpecHap/main.cpp`](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/main.cpp) (SpecHap entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Typing workflows"]
  node_typing["Typing modes"]
  node_assembly["Assembly typing"]
end

subgraph group_phase["Phasing core"]
  node_cli["SpecHap entry<br/>[main.cpp]"]
  node_phaser["Phaser<br/>[phaser.h]"]
  node_fragments["Fragment I/O<br/>[frag_io.cpp]"]
  node_spectral["Spectral method<br/>[spectral.cpp]"]
  node_graph["Phasing graph<br/>[graph.cpp]"]
  node_types["HLA type model<br/>[type.h]"]
end

subgraph group_reads["Read processing"]
  node_extract["HLA read extraction"]
  node_haplotypes["HLA fragment extraction<br/>[hapfragments.c]"]
  node_bamreader["BAM reader<br/>[BAMReader.h]"]
  node_barcode["Barcode extraction<br/>[worker.cpp]"]
  node_hic["Hi-C support<br/>[hic_util.cpp]"]
  node_tenx["10X support<br/>[tenx_util.cpp]"]
end

subgraph group_outputs["Typing outputs"]
  node_results["Typing results<br/>[results.h]"]
  node_loh["LOH detection"]
  node_diploid["Diploid HLA sequences"]
end

node_user(("Sequencing user"))
node_sequence["Read inputs"]
node_bam["BAM/CRAM inputs"]

node_user -->|"runs mode"| node_typing
node_user -->|"provides assembly"| node_assembly
node_sequence -->|"supplies reads"| node_typing
node_bam -->|"provides alignments"| node_extract
node_extract -.->|"extracts reads"| node_haplotypes
node_typing -.->|"invokes phasing"| node_cli
node_cli -->|"constructs"| node_phaser
node_phaser -.->|"uses fragments"| node_fragments
node_phaser -.->|"phases variants"| node_spectral
node_phaser -.->|"uses graph"| node_graph
node_phaser -.->|"uses type model"| node_types
node_bamreader -->|"supports extraction"| node_barcode
node_typing -->|"accepts Hi-C"| node_hic
node_typing -->|"accepts 10X"| node_tenx
node_typing -->|"produces typing"| node_results
node_results -->|"reports sequences"| node_diploid
node_results -->|"supplies typing results"| node_loh

click node_typing "https://github.com/deepomicslab/spechla/tree/master/script"
click node_assembly "https://github.com/deepomicslab/spechla/tree/master/script"
click node_extract "https://github.com/deepomicslab/spechla/tree/master/bin/extractHairs"
click node_haplotypes "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/hairs-src/hapfragments.c"
click node_bamreader "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/barcode_extractor/BAMReader.h"
click node_barcode "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/barcode_extractor/worker.cpp"
click node_hic "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/hic_util.cpp"
click node_tenx "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/tenx_util.cpp"
click node_cli "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/main.cpp"
click node_phaser "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/phaser.h"
click node_fragments "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/frag_io.cpp"
click node_spectral "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/spectral.cpp"
click node_graph "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/graph.cpp"
click node_types "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/type.h"
click node_results "https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/results.h"
click node_loh "https://github.com/deepomicslab/spechla/tree/master/script"

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_typing,node_assembly,node_user toneBlue
class node_cli,node_phaser,node_fragments,node_spectral,node_graph,node_types toneAmber
class node_extract,node_haplotypes,node_bamreader,node_barcode,node_hic,node_tenx toneMint
class node_results,node_loh,node_diploid toneRose
class node_sequence,node_bam toneIndigo
```

## Components

### Typing workflows

- [Typing modes](https://github.com/deepomicslab/spechla/tree/master/script): `script`
- [Assembly typing](https://github.com/deepomicslab/spechla/tree/master/script): `script`

### Phasing core

- [SpecHap entry](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/main.cpp): `bin/SpecHap/main.cpp`
- [Phaser](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/phaser.h): `bin/SpecHap/phaser.h`
- [Fragment I/O](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/frag_io.cpp): `bin/SpecHap/frag_io.cpp`
- [Spectral method](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/spectral.cpp): `bin/SpecHap/spectral.cpp`
- [Phasing graph](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/graph.cpp): `bin/SpecHap/graph.cpp`
- [HLA type model](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/type.h): `bin/SpecHap/type.h`

### Read processing

- [HLA read extraction](https://github.com/deepomicslab/spechla/tree/master/bin/extractHairs): `bin/extractHairs`
- [HLA fragment extraction](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/hairs-src/hapfragments.c): `bin/SpecHap/hairs-src/hapfragments.c`
- [BAM reader](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/barcode_extractor/BAMReader.h): `bin/SpecHap/barcode_extractor/BAMReader.h`
- [Barcode extraction](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/barcode_extractor/worker.cpp): `bin/SpecHap/barcode_extractor/worker.cpp`
- [Hi-C support](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/hic_util.cpp): `bin/SpecHap/hic_util.cpp`
- [10X support](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/tenx_util.cpp): `bin/SpecHap/tenx_util.cpp`

### Typing outputs

- [Typing results](https://github.com/deepomicslab/spechla/blob/master/bin/SpecHap/results.h): `bin/SpecHap/results.h`
- [LOH detection](https://github.com/deepomicslab/spechla/tree/master/script): `script`
- **Diploid HLA sequences**

### Other components

- **Sequencing user**
- **Read inputs**
- **BAM/CRAM inputs**

## Connections

- Sequencing user → Typing modes: runs mode
- Sequencing user → Assembly typing: provides assembly
- Read inputs → Typing modes: supplies reads
- BAM/CRAM inputs → HLA read extraction: provides alignments
- HLA read extraction → HLA fragment extraction: extracts reads
- Typing modes → SpecHap entry: invokes phasing
- SpecHap entry → Phaser: constructs (evidence: `bin/SpecHap/main.cpp`)
- Phaser → Fragment I/O: uses fragments
- Phaser → Spectral method: phases variants
- Phaser → Phasing graph: uses graph
- Phaser → HLA type model: uses type model (evidence: `bin/SpecHap/phaser.h`)
- BAM reader → Barcode extraction: supports extraction
- Typing modes → Hi-C support: accepts Hi-C
- Typing modes → 10X support: accepts 10X
- Typing modes → Typing results: produces typing
- Typing results → Diploid HLA sequences: reports sequences
- Typing results → LOH detection: supplies typing results
