P2PXML
Model Introduction
P2PXML is a deep geometric learning framework for predicting antibody-antigen binding affinity. The model jointly uses protein sequence information and three-dimensional PDB structural information from the antibody and antigen to predict binding affinity in terms of IC50.
Paper: Deep geometric framework to predict antibody–antigen binding affinity
Model Description
The P2PXML combined model consists of two parallel branches:
- Structural branch: Constructs antibody and antigen graphs from PDB atomic coordinates and extracts structural representations using GCN, GAT, and graph pooling;
- Sequence branch: Extracts amino acid sequences from PDB files, performs one-hot encoding, and uses attention, Transformer, and cross-attention modules to model sequence-level and interaction representations;
- Fusion output: Combines the regression outputs of the structural and sequence branches to predict antibody-antigen binding affinity.
The model takes one antibody PDB file and one antigen PDB file as input.
The maximum sequence lengths supported by the official demonstration model are:
- Antibody: 669 amino acids;
- Antigen: 3102 amino acids.
Use Cases
| Use Case | Description |
|---|---|
| Antibody-antigen binding affinity prediction | Predict IC50 from antibody and antigen PDB structures. |
| Antibody candidate screening | Compare the predicted affinity trends of multiple antibody-antigen structure pairs. |
| Model compatibility validation | Validate PyTorch Geometric inference and training in the SCNet DCU environment. |
| P2PXML method reproduction | Perform training or evaluation using the official P2PXML_Structure dataset. |
Usage
1. OneCode
You can use the OneCode online environment for an intelligent one-click AI4S programming experience:
Try OneCode for AI4S Programming
2. Manual Installation
Hardware Requirements
- The model supports CPU as well as CUDA-, ROCm-, and DTK-compatible accelerator devices supported by PyTorch;
- GPU or DCU is recommended for inference and training;
- CPU can be used for functional validation, but PDB graph construction and model computation are significantly slower;
- The model and graph features use
float64, so actual device-memory and host-memory requirements depend on the number of atoms in the antibody and antigen structures and on the training batch size; - Full-dataset training generates graph caches and checkpoints and therefore requires substantially more disk space than single-sample inference.
Download the Model Package
Install the Hugging Face command-line tool and download the model package containing the adapted code, pretrained weights, and example data:
python -m pip install -U huggingface_hub
hf download OneScience-Group/P2PXML --local-dir ./P2PXML
cd P2PXML
All commands below should be executed from the repository root unless otherwise specified.
Install the Runtime Environment
DCU Environment
# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[bio-dcu] \
-i http://mirrors.onescience.ai:3141/pypi/simple/ \
--trusted-host mirrors.onescience.ai
GPU Environment
# Activate Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
python -m pip install "onescience[bio-gpu]" \
-i http://mirrors.onescience.ai:3141/pypi/simple/ \
--trusted-host mirrors.onescience.ai
Install the additional dependencies required by P2PXML:
python -m pip install -r requirements.txt
If an independent Jupyter kernel is required, register one with:
python -m ipykernel install \
--user \
--name evo_bio \
--display-name "Python (onescience311)"
Weights and Data Preparation
The main assets included in the Hugging Face model package are:
| Asset | Location | Purpose |
|---|---|---|
| Official combined-model weights | weight/model_weights.pth |
Antibody-antigen binding affinity inference |
| Official antibody example | conf/data/10-1074.pdb |
Quick-inference antibody input |
| Official antigen example | conf/data/0013095_2_11.pdb |
Quick-inference antigen input |
| SCNet inference notebook | scripts/smoke/P2PXML_Demonstration_SCNet.ipynb |
Local-weight and PDB inference |
| Structural training data | conf/P2PXML_Structure/ |
Real-data subset or full-dataset training |
The complete official dataset is available from Zenodo:
https://zenodo.org/records/11531319
The current local P2PXML_structure.csv contains:
- 8,475 antibody-antigen records;
- 655 antibody PDB structures;
- 469 antigen PDB structures.
Basic DCU/PyG Validation
Use the following script to verify PyTorch, PyTorch Geometric, GCN, GAT, and accelerator execution:
python - <<'PY'
import torch
import torch_geometric
from torch_geometric.nn import GATConv, GCNConv
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
x = torch.randn(
4,
4,
dtype=torch.float64,
device=device,
)
edge_index = torch.tensor(
[[0, 1, 2, 3, 0, 2], [1, 0, 3, 2, 2, 0]],
dtype=torch.long,
device=device,
)
gcn = GCNConv(4, 8).to(device).double()
gat = GATConv(4, 8, heads=2).to(device).double()
print("torch:", torch.__version__)
print("torch_geometric:", torch_geometric.__version__)
print("device:", device)
print("GCN:", gcn(x, edge_index).shape)
print("GAT:", gat(x, edge_index).shape)
PY
Quick Inference
Run the inference notebook on a DCU compute node with the complete DTK dynamic-library environment loaded:
export P2PXML_ROOT=$PWD
cd scripts/smoke
P2PXML_ROOT="$P2PXML_ROOT" \
jupyter nbconvert \
--to notebook \
--execute P2PXML_Demonstration_SCNet.ipynb \
--output P2PXML_Demonstration_SCNet_output.ipynb \
--ExecutePreprocessor.kernel_name=evo_bio \
--ExecutePreprocessor.timeout=-1
After successful execution, the resulting notebook is saved as:
scripts/smoke/P2PXML_Demonstration_SCNet_output.ipynb
The warning:
IProgress not found
only affects notebook progress-bar display and does not affect the inference results.
Real-Data Subset Training
The script:
model/integrated_model_v1_dataset_smoke.py
supports selecting the number of training samples, number of epochs, output directory, and initialization checkpoint through environment variables.
The following example trains on 50 real structural records for one epoch:
cd "$P2PXML_ROOT"
P2PXML_DATA_LIMIT=50 \
P2PXML_EPOCHS=1 \
P2PXML_RUN_DIR=./scripts/training_runs/n50 \
P2PXML_INIT_CHECKPOINT=./weight/model_weights.pth \
python model/integrated_model_v1_dataset_smoke.py
The current upstream Dataset implementation recursively switches to the next sample when graph construction fails.
As a result, this training workflow can complete even when individual samples fail, but some effective training samples may be repeated.
Therefore, this run should only be interpreted as validation that the real-data training pipeline is executable.
It should not be treated as:
- A strict training-performance benchmark;
- A complete data-integrity validation;
- A final accuracy result.
Full-Dataset Single-Epoch Training
To run one epoch on the complete structural dataset:
cd "$P2PXML_ROOT"
P2PXML_DATA_LIMIT=0 \
P2PXML_EPOCHS=1 \
P2PXML_RUN_DIR=./scripts/training_runs/full_epoch1 \
P2PXML_INIT_CHECKPOINT=./weight/model_weights.pth \
python model/integrated_model_v1_dataset_smoke.py
Before running full-dataset training, verify that every Ab and Ag identifier in the CSV file has a corresponding PDB structure and handle any missing or invalid structures.
Initial graph construction computes pairwise distances between PDB atoms, with computational complexity approaching:
O(N²)
The generated graph data is cached under:
conf/P2PXML_Structure/graph_data/
Therefore, the first complete training run has substantially higher runtime and disk-space requirements than subsequent epochs.
It is recommended to retain the graph cache and gradually scale validation from:
50 samples
→ 500 samples
→ full dataset
before running complete training.
OneScience Official Resources
| Platform | OneScience Main Repository | Skills Repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
- Paper: Deep geometric framework to predict antibody–antigen binding affinity
- Official implementation: https://github.com/Drug-Discovery-ENTC/p2pxml
- Official dataset: P2PXML Dataset
The upstream P2PXML source code is distributed under the MIT License.
The official P2PXML notebook states that the dataset is distributed under the CC BY-NC-SA 4.0 license. Users must comply with the corresponding attribution, non-commercial-use, and share-alike requirements when using or redistributing the dataset.
This Hugging Face model package provides runtime adaptation and directory organization based on the official implementation. It does not modify or extend the original copyright status, licenses, or terms of use of the paper, source code, model weights, datasets, or other third-party resources.