How arontier/akscore2_paper works
Project type and purpose
• This is a command-line Python tool (monolithic application) for predicting protein–ligand binding affinities.
• It ingests ligand files (.mol2/.pdb) and protein structures (.pdb), builds graph representations, runs PyTorch-based graph-neural-network models, and outputs scores.
File structure
• Top-level scripts:
• convert_mol2pdb.py – converts ligand .mol2 → .pdb using OpenBabel/RDKit.
• construct_pyg_graph.py – reads .pdbs and builds PyG graphs.
• akscore2_run.py – orchestrates the full pipeline (graph construction + model inference).
• akscore2_models.py – defines the neural network architectures.
• Supporting directories:
• examples/ – sample inputs for testing.
• model_weights/ – pretrained .pth files for 3 models (NonDock, DockC, DockS).
• Config/dependencies: requirements.txt lists PyTorch, PyG, RDKit, OpenBabel, Meeko, NumPy, pandas.
README
• Confirms a three-stage workflow: (1) convert ligand, (2) construct graph & infer, (3) aggregate ensemble score (+ optional AutoDock).
• Describes CLI usage patterns, model selection flags, output format.
Main components & interactions
a. Components
• Input Module
– CLI parser (argparse in akscore2_run.py)
– File readers (mol2, pdb)
• Preprocessing Module
– convert_mol2pdb.py (OpenBabel/RDKit)
• Graph Construction Module
– construct_pyg_graph.py (PyTorch Geometric)
• Model Inference Module
– akscore2_models.py
– Model loader (loads .pth weights)
– Inference engine (runs forward pass on GPU/CPU)
• Output Module
– result.csv writer (pandas I/O)
• External Services/Libraries
– OpenBabel, RDKit, Meeko
– PyTorch & PyG
– Optional AutoDock executable for ensemble scoring
b. Relationships & data flow
1. User invokes akscore2_run.py → CLI parser reads arguments.
2. If ligand in .mol2, call convert_mol2pdb module → produce .pdb.
3. Feed protein .pdb + ligand .pdb into graph constructor → build graph objects.
4. Load pretrained weights into neural network architectures → run inference.
5. Collect scores (NonDock, DockC/S) and compute final score.
6. Write tabular results to result.csv.
7. (Optional) Call external AutoDock → add scores → update CSV.
c. Architectural patterns & design principles
• Pipeline pattern: clear sequential stages (Convert → Graphify → Infer → Write).
• Modularization: distinct scripts for each stage, shared model definitions.
• Configuration via CLI arguments, enabling model selection and hardware targeting.
d. Key technologies & libraries
• Python 3.x, argparse
• OpenBabel/RDKit (file conversion and chemistry)
• Meeko (ligand preparation)
• PyTorch 1.11 + CUDA/cuDNN
• PyTorch Geometric 2.0.4
• pandas, NumPy