# moshi4/fastdtlmapper architecture

> Architecture diagram of the GitHub repository moshi4/fastdtlmapper, 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/moshi4/fastdtlmapper
- Repository: https://github.com/moshi4/fastdtlmapper

## Overview

FastDTLmapper is a genome-wide gene gain/loss mapper: it takes protein CDS files and a rooted species tree, infers ortholog groups and gene trees, reconciles those trees for DTL events, then aggregates and maps events onto the species tree. The README documents this stage order and optional gain/loss plotting and GO enrichment analysis. The main workflow implementation was not sampled, so the graph shows documented sequencing without attributing unverified calls to particular internal functions.

Main entry points: [`src/fastdtlmapper/scripts/FastDTLmapper.py`](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/FastDTLmapper.py) (Workflow CLI), [`src/fastdtlmapper/input_check.py`](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/input_check.py) (Input validation), [`src/fastdtlmapper/bin/OrthoFinder/scripts_of/__main__.py`](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/OrthoFinder/scripts_of/__main__.py) (Orthogroup inference), [`src/fastdtlmapper/bin/AnGST_wrapper.py`](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/AnGST_wrapper.py) (AnGST wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Main workflow"]
  node_cli["Workflow CLI<br/>[FastDTLmapper.py]"]
  node_validation["Input validation<br/>[input_check.py]"]
end

subgraph group_inference["Gene tree inference"]
  node_orthofinder["Orthogroup inference<br/>[__main__.py]"]
  node_mafft["Sequence alignment"]
  node_trimal["Alignment trimming"]
  node_iqtree["Gene tree reconstruction"]
  node_treerecs["Tree correction"]
end

subgraph group_reconciliation["DTL mapping"]
  node_angst_wrapper["AnGST wrapper<br/>[AnGST_wrapper.py]"]
  node_angst["DTL reconciliation<br/>[reconcile.py]"]
  node_event_map["Event aggregation<br/>[event_map.py]"]
  node_tree_output["Mapped tree output<br/>[tree.py]"]
end

subgraph group_analysis["Further analysis"]
  node_plotter["Gain/loss plotting"]
  node_goea_cli["GOEA command<br/>[FastDTLgoea.py]"]
  node_goea["GO enrichment<br/>[goea.py]"]
  node_go_associations["Orthogroup GO associations"]
end

node_researcher(("Researcher"))
node_inputs["Genome and tree inputs"]

node_researcher -->|"provides"| node_inputs
node_inputs -->|"supplies"| node_cli
node_cli -->|"checks inputs"| node_validation
node_validation -->|"starts analysis"| node_orthofinder
node_orthofinder -->|"orthogroups"| node_mafft
node_mafft -->|"alignments"| node_trimal
node_trimal -->|"trimmed alignments"| node_iqtree
node_iqtree -->|"gene trees"| node_treerecs
node_treerecs -->|"corrected trees"| node_angst_wrapper
node_angst_wrapper -->|"runs reconciliation"| node_angst
node_angst -->|"event results"| node_event_map
node_event_map -->|"writes mapped events"| node_tree_output
node_tree_output -.->|"mapped tree"| node_plotter
node_researcher -.->|"requests enrichment"| node_goea_cli
node_goea_cli -.->|"runs analysis"| node_goea
node_go_associations -.->|"association data"| node_goea

click node_cli "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/FastDTLmapper.py"
click node_validation "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/input_check.py"
click node_orthofinder "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/OrthoFinder/scripts_of/__main__.py"
click node_angst_wrapper "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/AnGST_wrapper.py"
click node_angst "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/angst/angst_lib/reconcile.py"
click node_event_map "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/angst/event_map.py"
click node_tree_output "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/util/tree.py"
click node_plotter "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/plot_gain_loss_map.py"
click node_goea_cli "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/FastDTLgoea.py"
click node_goea "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/goea/goea.py"
click node_go_associations "https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/goea/og_go_association.py"

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_validation toneBlue
class node_orthofinder,node_mafft,node_trimal,node_iqtree,node_treerecs toneAmber
class node_angst_wrapper,node_angst,node_event_map,node_tree_output toneMint
class node_plotter,node_goea_cli,node_goea,node_go_associations toneRose
class node_researcher,node_inputs toneIndigo
```

## Components

### Main workflow

- [Workflow CLI](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/FastDTLmapper.py): `src/fastdtlmapper/scripts/FastDTLmapper.py`
- [Input validation](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/input_check.py): `src/fastdtlmapper/input_check.py`

### Gene tree inference

- [Orthogroup inference](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/OrthoFinder/scripts_of/__main__.py): `src/fastdtlmapper/bin/OrthoFinder/scripts_of/__main__.py`
- **Sequence alignment**
- **Alignment trimming**
- **Gene tree reconstruction**
- **Tree correction**

### DTL mapping

- [AnGST wrapper](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/AnGST_wrapper.py): `src/fastdtlmapper/bin/AnGST_wrapper.py`
- [DTL reconciliation](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/bin/angst/angst_lib/reconcile.py): `src/fastdtlmapper/bin/angst/angst_lib/reconcile.py`
- [Event aggregation](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/angst/event_map.py): `src/fastdtlmapper/angst/event_map.py`
- [Mapped tree output](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/util/tree.py): `src/fastdtlmapper/util/tree.py`

### Further analysis

- [Gain/loss plotting](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/plot_gain_loss_map.py): `src/fastdtlmapper/scripts/plot_gain_loss_map.py`
- [GOEA command](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/scripts/FastDTLgoea.py): `src/fastdtlmapper/scripts/FastDTLgoea.py`
- [GO enrichment](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/goea/goea.py): `src/fastdtlmapper/goea/goea.py`
- [Orthogroup GO associations](https://github.com/moshi4/fastdtlmapper/blob/main/src/fastdtlmapper/goea/og_go_association.py): `src/fastdtlmapper/goea/og_go_association.py`

### Other components

- **Researcher**
- **Genome and tree inputs**

## Connections

- Researcher → Genome and tree inputs: provides
- Genome and tree inputs → Workflow CLI: supplies
- Workflow CLI → Input validation: checks inputs
- Input validation → Orthogroup inference: starts analysis
- Orthogroup inference → Sequence alignment: orthogroups
- Sequence alignment → Alignment trimming: alignments
- Alignment trimming → Gene tree reconstruction: trimmed alignments
- Gene tree reconstruction → Tree correction: gene trees
- Tree correction → AnGST wrapper: corrected trees
- AnGST wrapper → DTL reconciliation: runs reconciliation
- DTL reconciliation → Event aggregation: event results
- Event aggregation → Mapped tree output: writes mapped events
- Mapped tree output → Gain/loss plotting: mapped tree
- Researcher → GOEA command: requests enrichment
- GOEA command → GO enrichment: runs analysis
- Orthogroup GO associations → GO enrichment: association data
