# mms-fcul/pypka architecture

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

- Interactive diagram: https://gitdiagram.com/mms-fcul/pypka
- Repository: https://github.com/mms-fcul/pypka

## Overview

##### Main Components

a) Core Components:
- Input Processing Layer
- Calculation Engine Layer
- Output Processing Layer
- Force Field Libraries (AMBER14SB, CHARMM36m, G54A7)

b) External Dependencies:
- DelPhi (Poisson-Boltzmann Solver)
- Python Scientific Stack

##### Component Relationships

**[Input Layer]**

**[Preprocessing Layer]**

**[Calculation Core]**

**[Post-processing Layer]**

**[Output Layer]**

##### Detailed Component Breakdown

a) Input Layer:
- PDB/GRO File Handlers
- Parameter Configuration
- CLI Interface
- API Interface

b) Preprocessing Layer:
- Structure Cleaning (pypka/clean/)
- Force Field Selection
- Tautomer Generation
- Site Definition

c) Calculation Core:
- DelPhi Integration (pypka/delphi4py/)
- Monte Carlo Engine (pypka/mc/)
- Protonation State Handler
- Energy Calculations

d) Post-processing Layer:
- pKa Calculation
- Titration Curve Generation
- State Analysis

e) Output Layer:
- Structure Output
- pKa Values
- Protonation States
- Analysis Reports

##### Implementation Details

- Modular architecture
- Force field flexibility
- Calculation pipeline
- Data flow between components
- External dependencies
- File I/O operations

- Separation between core functionality and force field implementations
- Clear interfaces between components
- Version control points
- Extension points for future development
- Error handling paths
- Validation checkpoints

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        CLI["CLI Interface"]:::input
        API["API Interface"]:::input
        PDB["PDB/GRO Handler"]:::input
        CONF["Configuration"]:::input
    end

    subgraph Preprocessing
        CLEAN["Structure Cleaning"]:::preprocess
        FF["Force Field Selection"]:::preprocess
        TAUT["Tautomer Generation"]:::preprocess
        SITE["Site Definition"]:::preprocess
    end

    subgraph "Calculation Core"
        DELPHI["DelPhi Integration"]:::core
        MC["Monte Carlo Engine"]:::core
        PROT["Protonation State Handler"]:::core
        ENERGY["Energy Calculations"]:::core
    end

    subgraph "Post Processing"
        PKA["pKa Calculation"]:::postprocess
        CURVE["Titration Curve"]:::postprocess
        ANALYSIS["State Analysis"]:::postprocess
    end

    subgraph Output
        STRUCT["Structure Output"]:::output
        VALUES["pKa Values"]:::output
        STATES["Protonation States"]:::output
        REPORT["Analysis Reports"]:::output
    end

    subgraph "Force Fields"
        AMBER["AMBER14SB"]:::forcefield
        CHARMM["CHARMM36m"]:::forcefield
        G54A7["G54A7"]:::forcefield
    end

    subgraph "Core Components"
        MOL["Molecule Handler"]:::component
        TAUTH["Tautomer Handler"]:::component
        SITH["Titration Site Handler"]:::component
        PARA["Parallel Processing"]:::component
    end

    CLI --> CLEAN
    API --> CLEAN
    PDB --> CLEAN
    CONF --> CLEAN

    CLEAN --> FF
    FF --> |Force Field Selection| AMBER
    FF --> |Force Field Selection| CHARMM
    FF --> |Force Field Selection| G54A7

    FF --> TAUT
    TAUT --> SITE
    SITE --> DELPHI

    DELPHI --> MC
    MC --> PROT
    PROT --> ENERGY

    ENERGY --> PKA
    PKA --> CURVE
    CURVE --> ANALYSIS

    ANALYSIS --> STRUCT
    ANALYSIS --> VALUES
    ANALYSIS --> STATES
    ANALYSIS --> REPORT

    MOL --> DELPHI
    TAUTH --> TAUT
    SITH --> SITE
    PARA --> MC

    %% Click events for component mapping
    click CLI "https://github.com/mms-fcul/PypKa/blob/master/pypka/cli.py"
    click CLEAN "https://github.com/mms-fcul/PypKa/tree/master/pypka/clean/"
    click DELPHI "https://github.com/mms-fcul/PypKa/tree/master/pypka/delphi4py/"
    click MC "https://github.com/mms-fcul/PypKa/tree/master/pypka/mc/"
    click MOL "https://github.com/mms-fcul/PypKa/blob/master/pypka/molecule.py"
    click TAUTH "https://github.com/mms-fcul/PypKa/blob/master/pypka/tautomer.py"
    click SITH "https://github.com/mms-fcul/PypKa/blob/master/pypka/titsite.py"
    click CONF "https://github.com/mms-fcul/PypKa/blob/master/pypka/config.py"
    click PARA "https://github.com/mms-fcul/PypKa/blob/master/pypka/concurrency.py"
    click AMBER "https://github.com/mms-fcul/PypKa/tree/master/pypka/AMBER14SB/"
    click CHARMM "https://github.com/mms-fcul/PypKa/tree/master/pypka/CHARMM36m/"
    click G54A7 "https://github.com/mms-fcul/PypKa/tree/master/pypka/G54A7/"

    %% Styling
    classDef input fill:#90EE90
    classDef preprocess fill:#ADD8E6
    classDef core fill:#4169E1
    classDef postprocess fill:#ADD8E6
    classDef output fill:#90EE90
    classDef forcefield fill:#FFD700
    classDef component fill:#A9A9A9

    %% Legend
    subgraph Legend
        L1["Input/Output"]:::input
        L2["Processing"]:::preprocess
        L3["Core"]:::core
        L4["Force Fields"]:::forcefield
        L5["Components"]:::component
    end
```
