How fmoonlights/nabp-bert works
Project Type and Purpose
• From the README and file tree, NABP‑BERT is an Open‑Source ML Pipeline for Nanobody‑Antigen Binding Prediction.
• It is not a classic web front‑end/back‑end app, but a batch‑style data‑processing and model‑training system built in Python/TensorFlow and orchestrated by shell scripts.
• Components cover:
• Data ingestion & cleaning (nanobody‑antigen sequences and PPI data)
• Dataset construction (TSV, TFRecord)
• Self‑supervised pre‑training (PROT‑BERT)
• Supervised fine‑tuning (PPI‑PROT‑BERT, NABP‑BERT)
• Evaluation & inference
File Structure
• Top‑level Python scripts map to pipeline stages:
• Data‑prep: CleanNbAgSeqs.py, CleanHINTdatabase.py, ConstructNbAgTrainValTestDatasets.py, ExtractingProteinSeqsFromTrembleDatabase.py, PrepearPPIDatasetSequences.py, Remove_Homology.py, ConstructPPINegativeSamples.py
• Format conversion: createTSV.py, tsv2record.py
• Pre‑train data prep: Prepear_PreTrain_Dataset.py, create_data.sh
• Model code: modeling.py, optimization.py, tokenization.py, bert_config_3.json, vocab/*
• Training & entry points: run_pretraining.py + pre_train.sh, run_fine_tune.sh, run_classifier.py / run_classifier_fatma.py, run_test.sh
• Utility: saveAsFASTA.py, createDatabase.py, get_unmappedKeysInSwissPortDatabase.py, createTSV.py
• Data directory (data/) holds raw and intermediate CSV/TSV.
• Shell scripts sequence the pipeline: create_data.sh → pre_train.sh → run_fine_tune.sh → run_test.sh.
README for Architecture Insights
• Four high‑level stages (A–D) of data prep
• Pre‑training stage using TFRecord + bert_config
• Fine‑tuning and evaluation stage
• Dependencies: UniProt Trembl/Sprot, HINT PPI data, Google Drive model downloads
Main Components & Their Interactions
a. Data Sources (External)
• HINT PPI binary files
• UniProt FASTA (Trembl, Swiss‑Prot)
• Nanobody‑Antigen CSV (in repo)
b. Data Preparation Module
• Sequence extraction, cleaning, homology removal
• Negative sample construction for PPI
• Output: cleaned FASTA, CSV
c. Dataset Builder
• createTSV.py → raw CSV/FASTA → TSV files
• tsv2record.py → TSV → TFRecord for TensorFlow input
d. Vocabulary & Tokenization
• vocab_3kmer.txt + tokenization.py break sequences into k‑mers
e. Model Definition
• bert_config_3.json defines model layers
• modeling.py + optimization.py implement PROT‑BERT and task heads
f. Pre‑training Pipeline
• run_pretraining.py invoked via pre_train.sh
• Consumes TFRecord, outputs PROT‑BERT checkpoints
g. Fine‑tuning Pipeline
• run_fine_tune.sh → run_classifier.py (PPI/PPI‑PROT or NB‑Ag)
• Produces task‑specific checkpoints & evaluation results
h. Testing & Inference
• run_test.sh → run_classifier_test_fatma.py → metrics, saved models
Architectural Patterns & Design Principles
• Modular pipeline: each stage produces artifacts consumed by the next
• Reusable model core (PROT‑BERT) with plug‑in heads for different tasks (PPI, NABP)
• Shell scripts as orchestration layer for reproducible experiments
• TFRecord as standard data interchange format for performance