# nf-core/reportho architecture

> Architecture diagram of the GitHub repository nf-core/reportho, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nf-core/reportho
- Repository: https://github.com/nf-core/reportho

## Overview

##### Project Type and Purpose
- nf-core/reportho is a bioinformatics pipeline built with Nextflow DSL2.
- Its purpose is to compare and summarize orthology predictions for query proteins. It integrates various analytical steps – from fetching query information, obtaining orthologs from public databases, calculating prediction agreement, to optional modules for fetching sequences, retrieving protein structures, performing multiple sequence alignments (MSA), and phylogenetic reconstruction, followed by generating a detailed human-readable report.
- The project is designed to be modular, with separate tasks (or processes) that can be run in parallel or conditionally (e.g., skipping downstream analysis via a command-line flag).

##### Breakdown of the File Structure (Key Indicators
- Top-Level Files/Folders:
– README.md, LICENSE, CHANGELOG.md, etc. (general project metadata)
– nextflow.config and main.nf that control the pipeline’s execution.
- Directories:
– bin: Contains runnable Python and R scripts that provide utility functions for data conversion, plotting, and other auxiliary tasks.
– conf: Contains configuration files that define various parameters and module setups.
– modules (including modules/local and modules/nf-core): Houses the implementation of the individual pipeline tasks (e.g., converting fasta, fetching orthologs, aligning sequences). Each module represents a self-contained component of the overall workflow.
– subworkflows: Contains more complex or nested workflows that aggregate several processing steps, for reusability.
– workflows: Contains the main report generation workflow stage.
– assets: Holds template files for reports and configuration used across the pipeline (like adaptivecard JSON, email templates, etc.).

##### Architectural Components
- Input Component:
– Samplesheet (CSV file) that provides inputs (either UniProt IDs or FASTA sequences).
- Core Pipeline Stages:
a. Query Information Retrieval – identification of Uniprot ID/taxon id.
b. Fetch Ortholog Predictions – this stage communicates with external public databases, either by API or local snapshots.
c. Comparison and Consensus Building – calculation of agreement statistics between different prediction sources and selection of consensus orthologs.
- Downstream Optional Processes:
d. Fetch Sequences – retrieval of protein sequences from UniProt.
e. Fetch Structures – retrieval of protein structure data from resources like the AlphaFold Database (conditional on provided flags).
f. Multiple Sequence Alignment – using 3D-COFFEE (with structures) or T-COFFEE for a standard alignment.
g. Phylogenetic Reconstruction – using tools like IQ-TREE or FastME.
h. Report Generation – creation of a human-readable HTML report (potentially also generating report images).
- Utility/Integration Components:
– Auxiliary scripts (bin): conversion, plotting (R scripts), and formatting.
– Configuration and parameters (in conf directory) that are injected into the process executions.
– Use of container technologies (Docker, Singularity, Conda) as seen in the README badges and Nextflow profiles, indicating that the processes run inside well-defined environments.

##### Relationships and Interactions
- Separate processes (represented as blocks) for Query, Fetch Orthologs, Comparison/Consensus, and then for each optional downstream step.

##### Architectural Patterns and Design Principles
- The pipeline is modular and separated into independent modules (each implemented as a self-contained Nextflow process).
- Separation between control (main.nf, config files) and processing modules (modules, subworkflows) is critical.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Pre-processing/Input
    subgraph "Pre-processing/Input"
        A["Samplesheet CSV"]:::input
        B["Samplesheet FASTA"]:::input
    end

    %% Pipeline Control
    subgraph "Pipeline Control"
        C["Nextflow Controller (main.nf)"]:::control
        D["Configuration (conf/)"]:::config
    end

    %% Core Analysis
    subgraph "Core Analysis"
        E["Query Identification"]:::core
        subgraph "Fetch Ortholog Predictions"
            E1["OMA Local"]:::core
            E2["OMA Online"]:::core
            E3["Panther Local"]:::core
            E4["Panther Online"]:::core
        end
        subgraph "Comparison and Consensus Building"
            F1["Hits Table"]:::core
            F2["Score Table"]:::core
            F3["Statistics"]:::core
        end
        F_agg["Comparison & Consensus"]:::core
    end

    %% Downstream Optional Analysis
    subgraph "Downstream Optional Analysis"
        subgraph "Sequence and Structure Retrieval"
            G["Fetch Sequences (modules & script)"]:::optional
            H["Fetch Structures (modules & script)"]:::optional
        end
        I["Multiple Sequence Alignment"]:::optional
        subgraph "Phylogenetic Reconstruction"
            J["FastME"]:::optional
            K["IQTree"]:::optional
        end
        L["Report Generation"]:::optional
    end

    %% External Integrations
    subgraph "External Integrations"
        M["UniProt API"]:::external
        N["AlphaFold API"]:::external
    end

    %% Utility
    subgraph "Utility"
        O["Auxiliary Scripts (bin/)"]:::utility
    end

    %% Connections
    A --> C
    B --> C
    D --> C
    C --> E
    E -->|"calls"| M
    E --> E1
    E --> E2
    E --> E3
    E --> E4
    E1 --> F1
    E2 --> F1
    E3 --> F1
    E4 --> F1
    F1 --> F2
    F2 --> F3
    F3 --> F_agg
    F_agg --> G
    F_agg --> H
    G --> I
    H --> I
    I --> J
    I --> K
    J --> L
    K --> L
    N --> H
    O --> G
    O --> H

    %% Click Events
    click A "https://github.com/nf-core/reportho/blob/master/assets/samplesheet.csv"
    click B "https://github.com/nf-core/reportho/blob/master/assets/samplesheet_fasta.csv"
    click C "https://github.com/nf-core/reportho/blob/master/main.nf"
    click D "https://github.com/nf-core/reportho/tree/master/conf/"
    click E "https://github.com/nf-core/reportho/blob/master/modules/local/identify_seq_online.nf"
    click E1 "https://github.com/nf-core/reportho/blob/master/modules/local/fetch_oma_group_local.nf"
    click E2 "https://github.com/nf-core/reportho/blob/master/modules/local/fetch_oma_group_online.nf"
    click E3 "https://github.com/nf-core/reportho/blob/master/modules/local/fetch_panther_group_local.nf"
    click E4 "https://github.com/nf-core/reportho/blob/master/modules/local/fetch_panther_group_online.nf"
    click F1 "https://github.com/nf-core/reportho/blob/master/modules/local/make_hits_table.nf"
    click F2 "https://github.com/nf-core/reportho/blob/master/modules/local/make_score_table.nf"
    click F3 "https://github.com/nf-core/reportho/blob/master/modules/local/make_stats.nf"
    click G "https://github.com/nf-core/reportho/blob/master/modules/local/fetch_sequences_online.nf"
    click H "https://github.com/nf-core/reportho/blob/master/modules/local/fetch_afdb_structures.nf"
    click I "https://github.com/nf-core/reportho/blob/master/modules/nf-core/tcoffee/align/main.nf"
    click J "https://github.com/nf-core/reportho/blob/master/modules/nf-core/fastme/main.nf"
    click K "https://github.com/nf-core/reportho/blob/master/modules/nf-core/iqtree/main.nf"
    click L "https://github.com/nf-core/reportho/blob/master/modules/local/make_report.nf"
    click O "https://github.com/nf-core/reportho/tree/master/bin/"

    %% Styles
    classDef input fill:#AEDFF7,stroke:#333,stroke-width:1px;
    classDef control fill:#C1FFC1,stroke:#333,stroke-width:1px;
    classDef core fill:#D0E1FF,stroke:#333,stroke-width:1px;
    classDef optional fill:#FFF79A,stroke:#333,stroke-width:1px;
    classDef external fill:#F9C0C0,stroke:#333,stroke-width:1px;
    classDef config fill:#F0E68C,stroke:#333,stroke-width:1px;
    classDef utility fill:#E6E6FA,stroke:#333,stroke-width:1px;
```
