# rhinogradentia/trinotate architecture

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

- Interactive diagram: https://gitdiagram.com/rhinogradentia/trinotate
- Repository: https://github.com/rhinogradentia/trinotate

## Overview

##### Project Overview
- Recognize that Trinotate is a bioinformatics annotation system focused on transcriptome functional annotation. Even though the README now indicates that active development stopped as of March 2024, the project still comprises both a command-line annotation pipeline and a CGI-based web reporting interface.
- Its purpose is to take input data (such as transcript FASTA files and expression matrices) and produce annotated reports, integrating external bioinformatics resources (e.g., GO, Eggnog, PFAM) with a layered utility structure.

##### Analyzing the File Structure
- The top-level directories reveal different aspects of the system:
- PerlLib: Contains core Perl modules (e.g., parsers for FASTA, GFF3, GTF, overlap processing, threading helpers) that are essential for the pipeline’s annotation computations.
- Trinotate: Likely holds main scripts or configuration related to the pipeline itself.
- TrinotateWeb: Contains a CGI-based web application including HTML templates, JavaScript (with CanvasXpress for interactive graphics), and configuration files (e.g., TrinotateWeb.conf), indicating a separate web presentation layer.
- util: A collection of utility scripts (annotation importers, report writers, loaders, and database initializers) that support the annotation process.
- Docker (and associated scripts such as build_docker.sh and push_docker.sh): Provides containerization support for deployment and consistency across environments.
- resources and testing: Storage for reference datasets and sample input data for validating the pipeline’s behavior.
- There is also evidence of a loosely Model-View-Controller (MVC) approach in TrinotateWeb, where the CGI scripts (controllers) interface with the Perl libraries (models) and use HTML/CSS/JS templates (views).

##### Identifying Main Components
- Core Annotation Engine:
- Utilizes PerlLib modules to perform sequence parsing, BLAST-like analysis, gene ontology (GO) mapping, and integration of external data resources.
- Responsible for processing user-provided transcript data.
- Utility and Loader Scripts:
- Found in the "util" directory; these scripts manage various tasks such as importing annotations (e.g., TrinotateSeqLoader), generating reports, and setting up database resources (often using SQLite).
- Web Interface (TrinotateWeb):
- Comprises CGI scripts, supporting Perl libraries under its cgi-bin directory, HTML template files, CSS, and JavaScript assets (including CanvasXpress charts for data visualization).
- Acts as the presentation layer where end users can query and review analysis results.
- Containerization and Deployment:
- The Docker folder and associated scripts indicate support for container-based deployment, ensuring that the environment for running Trinotate is standardized.
- External Resources/Data:
- The "resources" directory hosts external datasets like Eggnog mappings and GO slim files, which feed into the annotation process.
- Testing & Documentation:
- Testing inputs and configuration scripts support the validation of analysis run correctness.
- The various README, Wiki, and Changelog files provide documentation on usage and historical updates.

##### Mapping Relationships and Interactions
- Data Flow:
- Inputs (transcript sequences, expression data) are ingested by the Core Annotation Engine, which processes them using PerlLib functions.
- Utility scripts then ingest results from the core engine, load the data into database structures (e.g., SQLite) and prepare annotation reports.
- The Web Interface accesses these processed results, rendering them interactively for the end-user through CGI scripts.
- Dependencies:
- That the Core Annotation process depends on external datasets (resources) and various parsing libraries.
- The web presentation layer relies on standard web technologies (HTML, CSS, JavaScript along with CanvasXpress for interactive plots), and on other Perl libraries for dynamic content generation.
- Deployment is facilitated through Docker (or Singularity), which encapsulates the environment.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly segregates the annotation computation (via Perl libraries and utility scripts) from reporting (web interface).
- Modularity: Many utility scripts in the "util" directory reveal an intent to decompose tasks (e.g., separate loaders for BLAST, PFAM, and RNAMMER analyses).
- Extensibility: The design implies that new annotation sources or reporting formats could be added with minimal interference due to the modular nature of the codebase.
- Containerization reflects best practices in deployment and environment consistency.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Data Input Module\n(Transcript FASTA, Expression Data)"]:::input
    B["PerlLib: Sequence Parsers & Annotation Tools"]:::core
    C["Trinotate: Main Pipeline Scripts"]:::core
    D["Utility Scripts\n(util: Importers, Report Writers, Loaders)"]:::util
    E["Web Interface\n(TrinotateWeb: CGI, HTML, CSS, JS, Config)"]:::web
    F["Containerization & Deployment\n(Docker, build/push scripts)"]:::deploy
    G["External Resources\n(resources: Eggnog, GO mappings)"]:::resource
    H["Testing & Documentation\n(testing, README, Changelog)"]:::test

    %% Data flow connections
    A -->|"feeds"| B
    B -->|"triggers"| C
    G -->|"supplies"| B
    C -->|"processes for"| D
    D -->|"renders results to"| E
    F -->|"supports"| B
    F -->|"supports"| E
    H -->|"provides test inputs for"| A
    H -->|"validates"| D

    %% Click Events
    click B "https://github.com/rhinogradentia/trinotate/tree/master/PerlLib/"
    click C "https://github.com/rhinogradentia/trinotate/tree/master/Trinotate/"
    click D "https://github.com/rhinogradentia/trinotate/tree/master/util/"
    click E "https://github.com/rhinogradentia/trinotate/tree/master/TrinotateWeb/"
    click F "https://github.com/rhinogradentia/trinotate/tree/master/Docker/"
    click G "https://github.com/rhinogradentia/trinotate/tree/master/resources/"
    click H "https://github.com/rhinogradentia/trinotate/tree/master/testing/"

    %% Class Definitions with Colors
    classDef input fill:#f2d7d5,stroke:#c0392b,stroke-width:2px;
    classDef core fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef util fill:#d6eaf8,stroke:#2980b9,stroke-width:2px;
    classDef web fill:#fcf3cf,stroke:#f39c12,stroke-width:2px;
    classDef deploy fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef resource fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef test fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
```
