# rdk/p2rank architecture

> Architecture diagram of the GitHub repository rdk/p2rank, 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/rdk/p2rank
- Repository: https://github.com/rdk/p2rank

## Overview

##### Key Interactions and Data Flow

- Data flow from input files through processing stages
- Configuration parameters affecting each component
- Model loading and application paths
- Output generation flows

##### Detailed Component Breakdown

a) Feature Extraction Engine:
- Surface Point Generation
- Chemical Feature Calculators
- Conservation Feature Processors
- Structural Feature Analyzers

b) ML Prediction Engine:
- Model Loading/Application
- Score Transformation
- Probability Calibration

c) Output Generation:
- CSV Results Generator
- Visualization Script Generator
- SAS Points Calculator

##### External Dependencies (show as separate connected components)
- Java Runtime (17-23)
- PyMOL/ChimeraX Integration
- FastRandomForest
- BioJava
- CDK (Chemistry Development Kit)

##### Specific elements

a) File Formats (input):
- PDB (.pdb)
- mmCIF (.cif)
- BinaryCIF (.bcif)
- Compressed formats (.gz, .zst)

b) File Formats (output):
- Predictions CSV
- Residues CSV
- Visualization scripts (.pml, .cxc)
- SAS points data

##### Special Features
- Parallel Processing Capabilities
- Rescoring Pipeline
- Model Configuration System
- Dataset Processing Framework

Use the following visual conventions:
- Rectangles: Main processing components
- Hexagons: External systems/dependencies
- Clear labels for all components

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core ["Core Processing Pipeline"]
        direction TB
        Input["Input Processor"]
        FeatExt["Feature Extraction Engine"]
        MLPred["ML Prediction Engine"]
        OutGen["Output Generator"]
        
        Input --> FeatExt
        FeatExt --> MLPred
        MLPred --> OutGen
    end

    subgraph Support ["Supporting Systems"]
        direction TB
        Config["Configuration Management"]
        Parallel["Parallel Processing Framework"]
        Viz["Visualization Engine"]
        Model["Model Management"]
        Dataset["Dataset Handling"]
    end

    subgraph FeatExtComp ["Feature Extraction Components"]
        direction TB
        Surface["Surface Point Generation"]
        ChemFeat["Chemical Feature Calculators"]
        ConsFeat["Conservation Feature Processors"]
        StructFeat["Structural Feature Analyzers"]
    end

    subgraph MLComp ["ML Prediction Components"]
        direction TB
        ModelApp["Model Loading/Application"]
        Score["Score Transformation"]
        Prob["Probability Calibration"]
    end

    subgraph External ["External Dependencies"]
        direction TB
        Java["Java Runtime (17-23)"]
        PyMOL["PyMOL/ChimeraX"]
        Forest["FastRandomForest"]
        Bio["BioJava"]
        CDK["Chemistry Development Kit"]
    end

    %% Input formats
    PDB[".pdb files"]
    CIF[".cif files"]
    BCIF[".bcif files"]
    Compressed[".gz/.zst files"]

    %% Output formats
    PredCSV["Predictions CSV"]
    ResCSV["Residues CSV"]
    VizScripts["Visualization Scripts"]
    SASData["SAS Points Data"]

    %% Connections
    PDB --> Input
    CIF --> Input
    BCIF --> Input
    Compressed --> Input

    Config -.-> Core
    Parallel -.-> Core
    Dataset -.-> Core
    Model -.-> MLPred

    FeatExt --> FeatExtComp
    MLPred --> MLComp
    OutGen --> PredCSV
    OutGen --> ResCSV
    OutGen --> VizScripts
    OutGen --> SASData

    Viz --> VizScripts
    VizScripts --> PyMOL

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef support fill:#bbf,stroke:#333
    classDef feat fill:#bfb,stroke:#333
    classDef ml fill:#fbf,stroke:#333
    classDef external fill:#fbb,stroke:#333
    classDef io fill:#ddd,stroke:#333

    class Input,FeatExt,MLPred,OutGen core
    class Config,Parallel,Viz,Model,Dataset support
    class Surface,ChemFeat,ConsFeat,StructFeat feat
    class ModelApp,Score,Prob ml
    class Java,PyMOL,Forest,Bio,CDK external
    class PDB,CIF,BCIF,Compressed,PredCSV,ResCSV,VizScripts,SASData io

    %% Click events
    click Input "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/domain/loaders/"
    click FeatExt "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/features/"
    click MLPred "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/prediction/"
    click Config "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/program/params/"
    click Model "https://github.com/rdk/p2rank/tree/develop/distro/models/"
    click Viz "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/program/visualization/"
    click Dataset "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/domain/"
    click Parallel "https://github.com/rdk/p2rank/blob/develop/src/main/groovy/cz/siret/prank/program/ThreadPoolFactory.groovy"
    click OutGen "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/export/"
    click ChemFeat "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/features/implementation/chem/"
    click ConsFeat "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/features/implementation/conservation/"
    click Score "https://github.com/rdk/p2rank/tree/develop/src/main/groovy/cz/siret/prank/prediction/transformation/"
```
