# hypnopump/minifold architecture

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

- Interactive diagram: https://gitdiagram.com/hypnopump/minifold
- Repository: https://github.com/hypnopump/minifold

## Overview

##### Core Components

a) Data Processing Pipeline
- Input Layer: Raw protein sequences and PSSM (Position Specific Scoring Matrix) data
- Preprocessing Module:
- Protein sequence filtering (< 200 amino acids)
- Angle calculation from coordinates
- Data preparation and formatting

b) Model Architecture
- Two parallel neural network branches:
1. Angle Prediction Branch:
- 1D ResNet
- Input: LxN tensor (L≤200, N=42 channels)
- Output: 4 values (sin/cos of Phi/Psi angles)

2. Distance Prediction Branch:
- 2D ResNet
- Input: LxLxN tensor (L≤200, N=41 channels)
- Output: LxLx7 tensor (6 distance classes + 1 padding class)

c) Post-processing Pipeline
- RR Format Conversion
- 3D Structure Modeling Interface

**[Raw Input Data] → [Preprocessing Pipeline]**
- ↓
- ┌────────────────┴───────────────┐
- ↓                                ↓
**[Angle Prediction Branch]        [Distance Prediction Branch]**
- ↓                                ↓
- ┬───────────────┘
- ↓
- [Post-processing Pipeline]
- ↓
- [3D Structure Output]

##### Important Details

a) Input Specifications:
- Protein sequences (< 200 amino acids)
- PSSM matrices
- Van der Waals radius
- Surface accessibility data

b) Model Architecture Details:
- ResNet block structure
- Input/Output dimensions
- Key activation functions (ELU, Softmax)

c) Data Flow Annotations:
- Data transformations
- File formats (RR format)

##### Implementation Notes

- Parallel nature of angle and distance predictions
- Where model weights (*.h5 files) are used
- Evaluation points and metrics collection
- Interfaces with external tools (e.g., Rosetta)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Processing Block]:::process
        L2[(Data Storage)]:::storage
        L3{Decision Point}:::decision
        L4([Neural Network]):::nn
    end

    subgraph "Data Processing Pipeline"
        Input[Raw Input Data]:::input
        SeqFilter["Sequence Filtering (<200aa)"]:::process
        AngleCalc["Angle Calculation"]:::process
        DataPrep["Data Preparation"]:::process
        
        Input --> SeqFilter
        SeqFilter --> AngleCalc
        AngleCalc --> DataPrep
    end

    subgraph "Neural Network Architecture"
        direction TB
        subgraph "Angle Branch"
            AngleNet([1D ResNet]):::nn
            AngleOut["Sin/Cos Phi/Psi\nOutput (Lx4)"]:::output
        end
        
        subgraph "Distance Branch"
            DistNet([2D ResNet]):::nn
            DistOut["Distance Classes\nOutput (LxLx7)"]:::output
        end
    end

    subgraph "Post-processing"
        RRConv["RR Format Conversion"]:::process
        Structure["3D Structure Modeling"]:::output
    end

    DataPrep --> AngleNet
    DataPrep --> DistNet
    AngleNet --> AngleOut
    DistNet --> DistOut
    AngleOut --> RRConv
    DistOut --> RRConv
    RRConv --> Structure

    %% Component Mappings
    click SeqFilter "https://github.com/hypnopump/MiniFold/blob/master/preprocessing/get_proteins_under_200aa.jl"
    click AngleCalc "https://github.com/hypnopump/MiniFold/blob/master/preprocessing/get_angles_from_coords_py.ipynb"
    click DataPrep "https://github.com/hypnopump/MiniFold/blob/master/preprocessing/angle_data_preparation_py.ipynb"
    click AngleNet "https://github.com/hypnopump/MiniFold/blob/master/models/angles/resnet_1d_angles.py"
    click DistNet "https://github.com/hypnopump/MiniFold/blob/master/models/distance_pipeline/elu_resnet_2d_distances.py"
    click RRConv "https://github.com/hypnopump/MiniFold/blob/master/models/distance_pipeline/Tutorials/RR_format.py"

    %% Styles
    classDef process fill:#a8d1ff,stroke:#333,stroke-width:1px
    classDef storage fill:#f9f,stroke:#333,stroke-width:1px
    classDef decision fill:#fffab8,stroke:#333,stroke-width:1px
    classDef input fill:#ffb86c,stroke:#333,stroke-width:1px
    classDef output fill:#98ff98,stroke:#333,stroke-width:1px
    classDef nn fill:#c8a2c8,stroke:#333,stroke-width:1px
```
