How yitaoxu/robep works
Purpose and Entry Points
RoBep predicts residue-level B-cell epitopes from an antigen’s 3D structure using a region-oriented graph neural model. Primary program entry points are main.py for training/evaluation and data_preparation.py for dataset feature generation. Library consumers use AntigenChain.from_pdb() and .predict() in src/bce/antigen/antigen.py; the worked API path is notebooks/example.ipynb.
Input and Structure Preparation
AntigenChain owns inference-time PDB loading, chain extraction, structural feature preparation, and result assembly in src/bce/antigen/antigen.py. It transforms a selected PDB chain into residue embeddings, backbone coordinates, RSA values, and coverage/region data. Spatial neighborhood/point-cloud logic is separated into src/bce/antigen/pc.py. Input may be a local PDB such as data/pdb/5i9q.pdb; obtaining a structure is outside this repository.
Embedding and Dataset Pipeline
Protein-language-model embeddings require a user-supplied ESM-C API token, making ESM-C an external inference dependency and a material boundary. Batch preparation is driven by data_preparation.py, with dataset construction/loading in src/bce/data/data.py and supporting transformations in src/bce/data/utils.py. Training labels and splits originate under data/epitopes/, principally data/epitopes/epitopes.csv and data/epitopes/data_splits.json.
Graph Model and Region Prediction
The core RoBep architecture is src/bce/model/RoBep.py. It consumes residue-level structural and embedding features and produces node/residue predictions plus graph-level antigen-related outputs. Equivariant graph processing is implemented in src/bce/model/EGNN.py; region aggregation/pooling is in src/bce/model/pooling.py. Radius-based local spheres and top-k region selection bridge structural neighborhoods to user-visible predicted regions.
Training and Evaluation Control Flow
main.py selects train or eval mode, loads prepared data and model settings, then delegates optimization/evaluation orchestration to src/bce/utils/trainer.py. Objective definitions reside in src/bce/loss.py; metric computation and output reporting are separated into src/bce/utils/metrics.py and src/bce/utils/results.py. Evaluation can use the bundled checkpoint models/RoBep/20250626_110438/best_mcc_model.bin, with its associated configuration at models/RoBep/20250626_110438/config.json.
Inference Outputs and Boundaries
Inference loads a trained checkpoint, executes the model on a prepared chain, thresholds residue probabilities into epitopes, and ranks top-k spatial regions. AntigenChain.predict() returns residue probability mappings, predicted residue IDs, region centers/coverage, and aggregate antigen/epitope rates. Model loading is centralized in src/bce/utils/loading.py; shared constants and training/runtime helpers live in src/bce/utils/constants.py and src/bce/utils/training_tools.py.
Runtime and Distribution
The project is a Python 3.10 package defined by setup.py with source rooted at src/bce/. Its ML runtime requires PyTorch and PyTorch Geometric extension packages, including CUDA-compatible wheels when GPU execution is desired; dependency declarations are in requirements.txt. A Hugging Face Spaces interface is documented as an externally deployed UI, but no active website/server implementation appears in this tree.
Main entry points: antigen.py AntigenChain · trainer.py Training orchestrator · RoBep.py RoBep · data.py Dataset builder
Components 18
Entry points
- Train / eval CLI · Selects training or evaluation mode.
main.py - Batch preparation
data_preparation.py - API example
notebooks/example.ipynb - AntigenChain · Loads a PDB chain, prepares features, and assembles predictions.
src/bce/antigen/antigen.py
Data preparation
- PDB structure · Structure acquisition is outside the repository.
data/pdb/5i9q.pdb - ESM-C · Requires a user-supplied API token.
- Epitope labels & splits
data/epitopes/epitopes.csv - Dataset builder · Constructs and loads prepared training datasets.
src/bce/data/data.py - Data transforms
src/bce/data/utils.py
RoBep model
- Spatial neighborhoods · Builds point-cloud and local neighborhood features.
src/bce/antigen/pc.py - RoBep · Produces residue and antigen-level predictions.
src/bce/model/RoBep.py - Equivariant graph layers
src/bce/model/EGNN.py - Region pooling · Selects top-k spatial regions from local spheres.
src/bce/model/pooling.py
Training and runtime
- Training orchestrator · Runs optimization and evaluation.
src/bce/utils/trainer.py - Objectives
src/bce/loss.py - Metrics & reports
src/bce/utils/metrics.py - Model loader
src/bce/utils/loading.py - Bundled checkpoint
models/RoBep/20250626_110438/best_mcc_model.bin
Connections 21
- API example → AntigenChain: uses
- PDB structure → AntigenChain: selected chain
- AntigenChain → ESM-C: requests embeddings
- AntigenChain → Spatial neighborhoods: builds geometry
- ESM-C → AntigenChain: residue embeddings
- Spatial neighborhoods → AntigenChain: coordinates & regions
- AntigenChain → RoBep: inference features
- Batch preparation → Dataset builder: drives
- Epitope labels & splits → Dataset builder: labels
- Data transforms → Dataset builder: transforms
- Dataset builder → Training orchestrator: prepared batches
- Train / eval CLI → Training orchestrator: train / eval
- Training orchestrator → RoBep: optimizes / evaluates
- Training orchestrator → Objectives: computes objective
- Training orchestrator → Metrics & reports: reports metrics
- Model loader → Bundled checkpoint: loads
- Model loader → RoBep: restores weights
- AntigenChain → Model loader: loads model
- RoBep → Equivariant graph layers: equivariant processing
- Equivariant graph layers → Region pooling: node features
- Region pooling → RoBep: region outputs