# ericbretz/treeforge architecture

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

- Interactive diagram: https://gitdiagram.com/ericbretz/treeforge
- Repository: https://github.com/ericbretz/treeforge

## Overview

Treeforge takes genomic or transcriptomic FASTA files and automates a phylogenomic workflow to produce and refine trees. The README documents sequence alignment, clustering, tree building, and refinement; the source index identifies the pipeline coordinator and additional stages for BUSCO, BLAST, gene clustering, pruning, and final processing. Sampled code confirms some orchestration and tree-refinement calls, but not the full stage order, so undocumented links are omitted or shown as unverified. The graph focuses on runtime components, not build or test machinery.

Main entry points: [`core/datahub.py`](https://github.com/ericbretz/treeforge/blob/main/core/datahub.py) (Pipeline coordinator), [`core/stages/mafft.py`](https://github.com/ericbretz/treeforge/blob/main/core/stages/mafft.py) (MAFFT alignment), [`core/stages/tree.py`](https://github.com/ericbretz/treeforge/blob/main/core/stages/tree.py) (Tree construction), [`core/utils/fasta_io.py`](https://github.com/ericbretz/treeforge/blob/main/core/utils/fasta_io.py) (FASTA I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Pipeline Control"]
  node_treeforge["CLI entry<br/>[treeforge.py]"]
  node_datahub["Pipeline coordinator<br/>[datahub.py]"]
end

subgraph group_analysis["Sequence Analysis"]
  node_blast["BLAST search<br/>[blast.py]"]
  node_busco["BUSCO assessment<br/>[busco.py]"]
  node_genecluster["Gene clustering<br/>[genecluster.py]"]
  node_hcluster["Hierarchical clustering<br/>[hcluster.py]"]
  node_mcl["MCL clustering<br/>[mcl.py]"]
  node_mafft["MAFFT alignment<br/>[mafft.py]"]
  node_prank["PRANK refinement<br/>[prank.py]"]
  node_prune["Ortholog pruning<br/>[prune.py]"]
  node_final["Final processing<br/>[final.py]"]
end

subgraph group_trees["Tree Processing"]
  node_tree["Tree construction<br/>[tree.py]"]
  node_trimtips["Tip trimming<br/>[trimtips.py]"]
  node_masktips["Tip masking<br/>[masktips.py]"]
  node_cutbranches["Branch cutting<br/>[cutbranches.py]"]
  node_newick["Newick parsing<br/>[newick.py]"]
  node_phylo["Phylogeny model<br/>[phylo.py]"]
end

subgraph group_support["Shared Services"]
  node_base["Stage base<br/>[base_stage.py]"]
  node_concat["Sequence concatenation<br/>[concat.py]"]
  node_metrics["Run summaries<br/>[summary.py]"]
  node_parsers["Tree result parsers<br/>[iqtree_parser.py]"]
  node_astral["ASTRAL parser<br/>[astral_parser.py]"]
  node_fasta["FASTA I/O<br/>[fasta_io.py]"]
  node_logging["Subprocess logging<br/>[sublogger.py]"]
end

node_user(("FASTA provider"))

node_user -->|"provides FASTA"| node_treeforge
node_treeforge -->|"starts pipeline"| node_datahub
node_datahub -->|"runs alignment"| node_mafft
node_datahub -->|"runs assessment"| node_busco
node_datahub -.->|"dispatches stage"| node_blast
node_datahub -.->|"dispatches stage"| node_genecluster
node_datahub -.->|"runs clustering"| node_hcluster
node_datahub -.->|"dispatches stage"| node_mcl
node_datahub -.->|"dispatches stage"| node_prank
node_datahub -.->|"dispatches stage"| node_prune
node_datahub -.->|"dispatches stage"| node_tree
node_datahub -.->|"dispatches stage"| node_final
node_busco -->|"uses clustering"| node_hcluster
node_tree -->|"runs trimming"| node_trimtips
node_tree -->|"runs masking"| node_masktips
node_tree -->|"cuts branches"| node_cutbranches
node_masktips -->|"parses trees"| node_newick
node_masktips -->|"uses nodes"| node_phylo
node_trimtips -->|"parses trees"| node_newick
node_prune -->|"uses trimming"| node_trimtips
node_newick -->|"creates nodes"| node_phylo
node_final -->|"concatenates sequences"| node_concat
node_final -.->|"uses FASTA I/O"| node_fasta
node_mafft -.->|"uses FASTA I/O"| node_fasta
node_mcl -.->|"uses FASTA I/O"| node_fasta
node_blast -.->|"uses FASTA I/O"| node_fasta
node_mafft -->|"inherits stage"| node_base
node_datahub -->|"builds summaries"| node_metrics
node_metrics -->|"uses parser"| node_parsers
node_metrics -->|"uses parser"| node_astral
node_mafft -.->|"runs logged commands"| node_logging
node_busco -->|"runs logged commands"| node_logging
node_prank -->|"runs logged commands"| node_logging

click node_treeforge "https://github.com/ericbretz/treeforge/blob/main/treeforge.py"
click node_datahub "https://github.com/ericbretz/treeforge/blob/main/core/datahub.py"
click node_base "https://github.com/ericbretz/treeforge/blob/main/core/stages/base_stage.py"
click node_blast "https://github.com/ericbretz/treeforge/blob/main/core/stages/blast.py"
click node_busco "https://github.com/ericbretz/treeforge/blob/main/core/stages/busco.py"
click node_genecluster "https://github.com/ericbretz/treeforge/blob/main/core/stages/genecluster.py"
click node_hcluster "https://github.com/ericbretz/treeforge/blob/main/core/stages/hcluster.py"
click node_mcl "https://github.com/ericbretz/treeforge/blob/main/core/stages/mcl.py"
click node_mafft "https://github.com/ericbretz/treeforge/blob/main/core/stages/mafft.py"
click node_prank "https://github.com/ericbretz/treeforge/blob/main/core/stages/prank.py"
click node_prune "https://github.com/ericbretz/treeforge/blob/main/core/stages/prune.py"
click node_tree "https://github.com/ericbretz/treeforge/blob/main/core/stages/tree.py"
click node_trimtips "https://github.com/ericbretz/treeforge/blob/main/core/treeutils/trimtips.py"
click node_masktips "https://github.com/ericbretz/treeforge/blob/main/core/treeutils/masktips.py"
click node_cutbranches "https://github.com/ericbretz/treeforge/blob/main/core/treeutils/cutbranches.py"
click node_newick "https://github.com/ericbretz/treeforge/blob/main/core/treeutils/newick.py"
click node_phylo "https://github.com/ericbretz/treeforge/blob/main/core/treeutils/phylo.py"
click node_final "https://github.com/ericbretz/treeforge/blob/main/core/stages/final.py"
click node_concat "https://github.com/ericbretz/treeforge/blob/main/core/utils/concat.py"
click node_metrics "https://github.com/ericbretz/treeforge/blob/main/core/utils/summary.py"
click node_parsers "https://github.com/ericbretz/treeforge/blob/main/core/utils/iqtree_parser.py"
click node_astral "https://github.com/ericbretz/treeforge/blob/main/core/utils/astral_parser.py"
click node_fasta "https://github.com/ericbretz/treeforge/blob/main/core/utils/fasta_io.py"
click node_logging "https://github.com/ericbretz/treeforge/blob/main/core/utils/sublogger.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_treeforge,node_datahub toneBlue
class node_blast,node_busco,node_genecluster,node_hcluster,node_mcl,node_mafft,node_prank,node_prune,node_final toneAmber
class node_tree,node_trimtips,node_masktips,node_cutbranches,node_newick,node_phylo toneMint
class node_base,node_concat,node_metrics,node_parsers,node_astral,node_fasta,node_logging toneRose
class node_user toneIndigo
```

## Components

### Pipeline Control

- [CLI entry](https://github.com/ericbretz/treeforge/blob/main/treeforge.py): `treeforge.py`
- [Pipeline coordinator](https://github.com/ericbretz/treeforge/blob/main/core/datahub.py): `core/datahub.py`

### Sequence Analysis

- [BLAST search](https://github.com/ericbretz/treeforge/blob/main/core/stages/blast.py): `core/stages/blast.py`
- [BUSCO assessment](https://github.com/ericbretz/treeforge/blob/main/core/stages/busco.py): `core/stages/busco.py`
- [Gene clustering](https://github.com/ericbretz/treeforge/blob/main/core/stages/genecluster.py): `core/stages/genecluster.py`
- [Hierarchical clustering](https://github.com/ericbretz/treeforge/blob/main/core/stages/hcluster.py): `core/stages/hcluster.py`
- [MCL clustering](https://github.com/ericbretz/treeforge/blob/main/core/stages/mcl.py): `core/stages/mcl.py`
- [MAFFT alignment](https://github.com/ericbretz/treeforge/blob/main/core/stages/mafft.py): `core/stages/mafft.py`
- [PRANK refinement](https://github.com/ericbretz/treeforge/blob/main/core/stages/prank.py): `core/stages/prank.py`
- [Ortholog pruning](https://github.com/ericbretz/treeforge/blob/main/core/stages/prune.py): `core/stages/prune.py`
- [Final processing](https://github.com/ericbretz/treeforge/blob/main/core/stages/final.py): `core/stages/final.py`

### Tree Processing

- [Tree construction](https://github.com/ericbretz/treeforge/blob/main/core/stages/tree.py): `core/stages/tree.py`
- [Tip trimming](https://github.com/ericbretz/treeforge/blob/main/core/treeutils/trimtips.py): `core/treeutils/trimtips.py`
- [Tip masking](https://github.com/ericbretz/treeforge/blob/main/core/treeutils/masktips.py): `core/treeutils/masktips.py`
- [Branch cutting](https://github.com/ericbretz/treeforge/blob/main/core/treeutils/cutbranches.py): `core/treeutils/cutbranches.py`
- [Newick parsing](https://github.com/ericbretz/treeforge/blob/main/core/treeutils/newick.py): `core/treeutils/newick.py`
- [Phylogeny model](https://github.com/ericbretz/treeforge/blob/main/core/treeutils/phylo.py): `core/treeutils/phylo.py`

### Shared Services

- [Stage base](https://github.com/ericbretz/treeforge/blob/main/core/stages/base_stage.py): `core/stages/base_stage.py`
- [Sequence concatenation](https://github.com/ericbretz/treeforge/blob/main/core/utils/concat.py): `core/utils/concat.py`
- [Run summaries](https://github.com/ericbretz/treeforge/blob/main/core/utils/summary.py): `core/utils/summary.py`
- [Tree result parsers](https://github.com/ericbretz/treeforge/blob/main/core/utils/iqtree_parser.py): `core/utils/iqtree_parser.py`
- [ASTRAL parser](https://github.com/ericbretz/treeforge/blob/main/core/utils/astral_parser.py): `core/utils/astral_parser.py`
- [FASTA I/O](https://github.com/ericbretz/treeforge/blob/main/core/utils/fasta_io.py): `core/utils/fasta_io.py`
- [Subprocess logging](https://github.com/ericbretz/treeforge/blob/main/core/utils/sublogger.py): `core/utils/sublogger.py`

### Other components

- **FASTA provider**

## Connections

- FASTA provider → CLI entry: provides FASTA (evidence: `README.md`)
- CLI entry → Pipeline coordinator: starts pipeline (evidence: `treeforge.py`)
- Pipeline coordinator → MAFFT alignment: runs alignment (evidence: `core/datahub.py`)
- Pipeline coordinator → BUSCO assessment: runs assessment (evidence: `core/datahub.py`)
- Pipeline coordinator → BLAST search: dispatches stage (evidence: `core/datahub.py`)
- Pipeline coordinator → Gene clustering: dispatches stage (evidence: `core/datahub.py`)
- Pipeline coordinator → Hierarchical clustering: runs clustering (evidence: `core/datahub.py`)
- Pipeline coordinator → MCL clustering: dispatches stage (evidence: `core/datahub.py`)
- Pipeline coordinator → PRANK refinement: dispatches stage (evidence: `core/datahub.py`)
- Pipeline coordinator → Ortholog pruning: dispatches stage (evidence: `core/datahub.py`)
- Pipeline coordinator → Tree construction: dispatches stage (evidence: `core/datahub.py`)
- Pipeline coordinator → Final processing: dispatches stage (evidence: `core/datahub.py`)
- BUSCO assessment → Hierarchical clustering: uses clustering (evidence: `core/stages/busco.py`)
- Tree construction → Tip trimming: runs trimming (evidence: `core/stages/tree.py`)
- Tree construction → Tip masking: runs masking (evidence: `core/stages/tree.py`)
- Tree construction → Branch cutting: cuts branches (evidence: `core/stages/tree.py`)
- Tip masking → Newick parsing: parses trees (evidence: `core/treeutils/masktips.py`)
- Tip masking → Phylogeny model: uses nodes (evidence: `core/treeutils/masktips.py`)
- Tip trimming → Newick parsing: parses trees (evidence: `core/treeutils/trimtips.py`)
- Ortholog pruning → Tip trimming: uses trimming (evidence: `core/stages/prune.py`)
- Newick parsing → Phylogeny model: creates nodes (evidence: `core/treeutils/newick.py`)
- Final processing → Sequence concatenation: concatenates sequences (evidence: `core/stages/final.py`)
- Final processing → FASTA I/O: uses FASTA I/O
- MAFFT alignment → FASTA I/O: uses FASTA I/O
- MCL clustering → FASTA I/O: uses FASTA I/O (evidence: `core/stages/mcl.py`)
- BLAST search → FASTA I/O: uses FASTA I/O (evidence: `core/stages/blast.py`)
- MAFFT alignment → Stage base: inherits stage (evidence: `core/stages/base_stage.py`)
- Pipeline coordinator → Run summaries: builds summaries (evidence: `core/datahub.py`)
- Run summaries → Tree result parsers: uses parser (evidence: `core/utils/summary.py`)
- Run summaries → ASTRAL parser: uses parser (evidence: `core/utils/summary.py`)
- MAFFT alignment → Subprocess logging: runs logged commands (evidence: `core/stages/mafft.py`)
- BUSCO assessment → Subprocess logging: runs logged commands (evidence: `core/stages/busco.py`)
- PRANK refinement → Subprocess logging: runs logged commands (evidence: `core/stages/prank.py`)
