# duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation architecture

> Architecture diagram of the GitHub repository duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation
- Repository: https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation

## Overview

Enhanced abCAN predicts antibody–antigen binding-affinity changes from a wild-type PDB, chain identifiers, and mutations. The main workflow accepts those inputs through the CLI or web API, prepares structure and mutation features, runs the pretrained abCAN model with an optional residual enhancement, and returns ΔΔG. Separate project capabilities cover dataset preparation, residual-model training, and target-grouped benchmark evaluation. The source excerpts show key inference and modeling relationships; links for broader preprocessing and training stages are included only where the README or source index supports them.

Main entry points: [`scripts/predict_utils.py`](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/predict_utils.py) (Prediction Utilities), [`scripts/process_input.py`](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/process_input.py) (Structure and Mutation Parsing), [`scripts/model.py`](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/model.py) (abCAN Decoder), [`scripts/train_egn_pipeline.py`](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/train_egn_pipeline.py) (EGN Training Pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI Predictor<br/>[predict.py]"]
  node_web["FastAPI Dashboard<br/>[backend.py]"]
  node_streamlit["Streamlit Interface<br/>[app.py]"]
end

subgraph group_inference["Prediction Runtime"]
  node_inference["Prediction Utilities<br/>[predict_utils.py]"]
  node_structure["Structure and Mutation Parsing<br/>[process_input.py]"]
  node_decoder["abCAN Decoder<br/>[model.py]"]
  node_residual["Residual Correction Heads<br/>[model.py]"]
  node_checkpoints["Model Checkpoints"]
end

subgraph group_data["Data Preparation"]
  node_corpus[("Structures and Affinity Data")]
  node_preprocessing["Dataset Preprocessing"]
  node_abbind["AB-Bind Integration"]
  node_featurecache["Feature Cache Builder"]
end

subgraph group_modeling["Training and Evaluation"]
  node_training["EGN Training Pipeline"]
  node_nestedcv["Nested Grouped CV<br/>[nested_abcan_cv.py]"]
  node_balancedcv["Balanced Nested CV"]
  node_finalfit["Final Head Fitting"]
  node_benchcv["Target-Level CV Benchmark"]
  node_benchfull["Full-Data CV Benchmark"]
  node_bench["Residual Benchmark<br/>[benchmark_eval.py]"]
end

node_user(("Researcher"))

node_user -->|"submits inputs"| node_cli
node_user -->|"uploads inputs"| node_web
node_user -->|"submits inputs"| node_streamlit
node_cli -->|"calls"| node_inference
node_web -->|"calls"| node_inference
node_inference -->|"parses inputs"| node_structure
node_inference -->|"runs inference"| node_decoder
node_inference -->|"applies enhancement"| node_residual
node_inference -->|"loads weights"| node_checkpoints
node_structure -->|"reads structures"| node_corpus
node_preprocessing -.->|"processes datasets"| node_corpus
node_abbind -->|"reads training data"| node_corpus
node_featurecache -->|"uses model"| node_decoder
node_featurecache -->|"uses parser"| node_structure
node_training -->|"trains against"| node_decoder
node_nestedcv -->|"uses training pipeline"| node_training
node_balancedcv -->|"uses training pipeline"| node_training
node_finalfit -->|"selects candidates"| node_balancedcv
node_training -.->|"writes checkpoints"| node_checkpoints
node_benchcv -->|"evaluates baseline"| node_decoder
node_benchcv -->|"prepares samples"| node_structure
node_benchfull -->|"evaluates baseline"| node_decoder
node_benchfull -->|"prepares samples"| node_structure
node_bench -->|"maps samples"| node_structure
node_bench -->|"saves model"| node_checkpoints

click node_cli "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/predict.py"
click node_web "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/backend.py"
click node_streamlit "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/app.py"
click node_inference "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/predict_utils.py"
click node_structure "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/process_input.py"
click node_decoder "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/model.py"
click node_residual "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/model.py"
click node_checkpoints "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/tree/main/ckpt"
click node_corpus "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/tree/main/data"
click node_preprocessing "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/abcan_preprocessing_pipeline.py"
click node_abbind "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/merge_abbind_training.py"
click node_featurecache "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/build_feature_cache.py"
click node_training "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/train_egn_pipeline.py"
click node_nestedcv "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/nested_abcan_cv.py"
click node_balancedcv "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/nested_abcan_cv_balanced.py"
click node_finalfit "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/train_full_data_balanced.py"
click node_benchcv "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/benchmark_cv_eval.py"
click node_benchfull "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/benchmark_full308_cv_eval.py"
click node_bench "https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/benchmark_eval.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_web,node_streamlit toneBlue
class node_inference,node_structure,node_decoder,node_residual,node_checkpoints toneAmber
class node_corpus,node_preprocessing,node_abbind,node_featurecache toneMint
class node_training,node_nestedcv,node_balancedcv,node_finalfit,node_benchcv,node_benchfull,node_bench toneRose
class node_user toneIndigo
```

## Components

### User Interfaces

- [CLI Predictor](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/predict.py): `predict.py`
- [FastAPI Dashboard](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/backend.py): `backend.py`
- [Streamlit Interface](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/app.py): `app.py`

### Prediction Runtime

- [Prediction Utilities](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/predict_utils.py): `scripts/predict_utils.py`
- [Structure and Mutation Parsing](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/process_input.py): `scripts/process_input.py`
- [abCAN Decoder](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/model.py): `scripts/model.py`
- [Residual Correction Heads](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/model.py): `scripts/model.py`
- [Model Checkpoints](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/tree/main/ckpt): `ckpt`

### Data Preparation

- [Structures and Affinity Data](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/tree/main/data): `data`
- [Dataset Preprocessing](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/abcan_preprocessing_pipeline.py): `scripts/abcan_preprocessing_pipeline.py`
- [AB-Bind Integration](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/merge_abbind_training.py): `scripts/merge_abbind_training.py`
- [Feature Cache Builder](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/build_feature_cache.py): `scripts/build_feature_cache.py`

### Training and Evaluation

- [EGN Training Pipeline](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/train_egn_pipeline.py): `scripts/train_egn_pipeline.py`
- [Nested Grouped CV](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/nested_abcan_cv.py): `scripts/nested_abcan_cv.py`
- [Balanced Nested CV](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/nested_abcan_cv_balanced.py): `scripts/nested_abcan_cv_balanced.py`
- [Final Head Fitting](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/scripts/train_full_data_balanced.py): `scripts/train_full_data_balanced.py`
- [Target-Level CV Benchmark](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/benchmark_cv_eval.py): `benchmark_cv_eval.py`
- [Full-Data CV Benchmark](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/benchmark_full308_cv_eval.py): `benchmark_full308_cv_eval.py`
- [Residual Benchmark](https://github.com/duo311/-pre-rained-antibody-antigen-binding-affinity-g-prediction-under-nested-complex-level-validation/blob/main/benchmark_eval.py): `benchmark_eval.py`

### Other components

- **Researcher**

## Connections

- Researcher → CLI Predictor: submits inputs (evidence: `README.md`)
- Researcher → FastAPI Dashboard: uploads inputs (evidence: `README.md`)
- Researcher → Streamlit Interface: submits inputs (evidence: `README.md`)
- CLI Predictor → Prediction Utilities: calls (evidence: `predict.py`)
- FastAPI Dashboard → Prediction Utilities: calls (evidence: `backend.py`)
- Prediction Utilities → Structure and Mutation Parsing: parses inputs (evidence: `scripts/predict_utils.py`)
- Prediction Utilities → abCAN Decoder: runs inference (evidence: `scripts/predict_utils.py`)
- Prediction Utilities → Residual Correction Heads: applies enhancement (evidence: `scripts/predict_utils.py`)
- Prediction Utilities → Model Checkpoints: loads weights (evidence: `scripts/predict_utils.py`)
- Structure and Mutation Parsing → Structures and Affinity Data: reads structures (evidence: `scripts/process_input.py`)
- Dataset Preprocessing → Structures and Affinity Data: processes datasets (evidence: `README.md`)
- AB-Bind Integration → Structures and Affinity Data: reads training data (evidence: `scripts/merge_abbind_training.py`)
- Feature Cache Builder → abCAN Decoder: uses model (evidence: `scripts/build_feature_cache.py`)
- Feature Cache Builder → Structure and Mutation Parsing: uses parser (evidence: `scripts/build_feature_cache.py`)
- EGN Training Pipeline → abCAN Decoder: trains against (evidence: `scripts/train_egn_pipeline.py`)
- Nested Grouped CV → EGN Training Pipeline: uses training pipeline (evidence: `scripts/nested_abcan_cv.py`)
- Balanced Nested CV → EGN Training Pipeline: uses training pipeline (evidence: `scripts/nested_abcan_cv_balanced.py`)
- Final Head Fitting → Balanced Nested CV: selects candidates (evidence: `scripts/train_full_data_balanced.py`)
- EGN Training Pipeline → Model Checkpoints: writes checkpoints
- Target-Level CV Benchmark → abCAN Decoder: evaluates baseline (evidence: `benchmark_cv_eval.py`)
- Target-Level CV Benchmark → Structure and Mutation Parsing: prepares samples (evidence: `benchmark_cv_eval.py`)
- Full-Data CV Benchmark → abCAN Decoder: evaluates baseline (evidence: `benchmark_full308_cv_eval.py`)
- Full-Data CV Benchmark → Structure and Mutation Parsing: prepares samples (evidence: `benchmark_full308_cv_eval.py`)
- Residual Benchmark → Structure and Mutation Parsing: maps samples (evidence: `benchmark_eval.py`)
- Residual Benchmark → Model Checkpoints: saves model (evidence: `benchmark_eval.py`)
