# lormebioai/dcipatho architecture

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

- Interactive diagram: https://gitdiagram.com/lormebioai/dcipatho
- Repository: https://github.com/lormebioai/dcipatho

## Overview

##### Project type and purpose
- DCiPatho is a Python-based machine-learning application (an ML pipeline) for classifying bacterial sequences as pathogenic or non-pathogenic.
- It provides two main workflows:
- Training & evaluation on k-mer frequency features (via DCiPatho_main.py + DCiPatho_trainer.py + DCiPatho_network.py).
- Inference/prediction on raw FASTA reads (via DCiPatho_predict.py + utility modules).

##### File structure
Top-level files:
- DCiPatho_config.py  – central Config class for both training and prediction settings.
- DCiPatho_main.py    – entry point for training/evaluation.
- DCiPatho_trainer.py – orchestrates training loops, early stopping, model checkpointing.
- DCiPatho_network.py – defines the Deep Cross, ResNet, and DeepNet submodules; composes full PyTorch model.
- DCiPatho_predict.py – entry point for inference: combines FASTA, computes k-mer freqs, loads model, generates predictions.
- BaseModel/basemodel.py – abstract base class for models (shared logic).
- Utils/             – helper functions for k-mer calculation (cal_utils.py), file combination (combine_fna.py), training callbacks (pytorchtools.py), general tools (tool.py).
- requirements.txt   – external dependencies (numpy, torch, pandas, scikit-learn).
- temp_data/         – sample precomputed data for quick demos.

##### README for additional insights
- Clearly describes two workflows (training vs. prediction), all configurable hyperparameters, data sources, and evaluation metrics.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Data Ingestion"
        RawCSV[".npy/.csv Files"]:::data
        RawFASTA["Raw FASTA Files"]:::data
        TempData["Sample Data (temp_data/)"]:::data
    end

    subgraph "Preprocessing & Feature Extraction"
        CombineFA["combine_fna.py"]:::processing
        CalcMain["cal.py (cal_main)"]:::processing
        CalcUtils["cal_utils.py"]:::processing
    end

    FeatureArray["Feature Array"]:::processing

    Config["DCiPatho_config.py"]:::config

    subgraph "Training Flow"
        MainEntry["DCiPatho_main.py"]:::processing
        Trainer["DCiPatho_trainer.py"]:::processing
        PyTools["pytorchtools.py"]:::processing
        Checkpoints["Model Checkpoints"]:::storage
    end

    subgraph "Inference Flow"
        PredictEntry["DCiPatho_predict.py"]:::processing
        Results["Prediction Results (CSV)"]:::storage
        Tool["tool.py"]:::processing
    end

    %% Data ingestion to preprocessing
    RawFASTA --> CombineFA
    RawCSV --> CalcMain
    CombineFA --> CalcMain
    CalcMain --> CalcUtils
    CalcUtils --> FeatureArray
    TempData --> FeatureArray

    %% Feature to Config
    FeatureArray --> Config

    %% Training flow
    Config --> MainEntry
    FeatureArray --> MainEntry
    MainEntry --> Trainer
    Trainer --> PyTools
    Trainer --> Network
    Network["DCiPatho_network.py"]:::ml
    Network --> BaseModel
    BaseModel["basemodel.py"]:::ml
    Trainer --> Checkpoints

    %% Inference flow
    Config --> PredictEntry
    FeatureArray --> PredictEntry
    PredictEntry --> Network
    PredictEntry --> Results
    PredictEntry --> Tool

    %% Click events
    click CombineFA "https://github.com/lormebioai/dcipatho/blob/main/Utils/combine_fna.py"
    click CalcMain "https://github.com/lormebioai/dcipatho/blob/main/Utils/cal.py"
    click CalcUtils "https://github.com/lormebioai/dcipatho/blob/main/Utils/cal_utils.py"
    click TempData "https://github.com/lormebioai/dcipatho/tree/main/temp_data/"
    click Config "https://github.com/lormebioai/dcipatho/blob/main/DCiPatho_config.py"
    click BaseModel "https://github.com/lormebioai/dcipatho/blob/main/BaseModel/basemodel.py"
    click Network "https://github.com/lormebioai/dcipatho/blob/main/DCiPatho_network.py"
    click MainEntry "https://github.com/lormebioai/dcipatho/blob/main/DCiPatho_main.py"
    click Trainer "https://github.com/lormebioai/dcipatho/blob/main/DCiPatho_trainer.py"
    click PyTools "https://github.com/lormebioai/dcipatho/blob/main/Utils/pytorchtools.py"
    click PredictEntry "https://github.com/lormebioai/dcipatho/blob/main/DCiPatho_predict.py"
    click Tool "https://github.com/lormebioai/dcipatho/blob/main/Utils/tool.py"

    classDef data fill:#87CEEB,stroke:#000,stroke-width:1px
    classDef processing fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#000,stroke-width:1px
    classDef storage fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef config fill:#DA70D6,stroke:#000,stroke-width:1px
```
