dataset Module
The dataset module provides tools for orchestrating the large-scale generation of synthetic protein datasets for AI model training.
Overview
Generating diverse, balanced datasets is critical for training robust deep learning models like AlphaFold or RosettaFold. The dataset module automates the production of thousands of (Structure, Sequence, Constraint) triplets.
Main Classes
DatasetGenerator
Orchestrates the generation of large-scale synthetic protein datasets for AI model training.
EDUCATIONAL NOTE - The Balanced Dataset Problem:
When training an AI model (like AlphaFold or a Forcefield predictor), the quality and BALANCE of the data are often more important than the quantity.
- The Alpha-Helix Trap: If you only generate structures using the 'alpha' preset, your AI will learn that all biology looks like a helix. This leads to "Halls of Mirrors" where the model fails on Beta sheets or intrinsically disordered regions (IDRs).
- Mixed Conformations: This generator encourages specifying a mix of 'alpha', 'beta', and 'random' conformations. A dataset that "covers" the Ramachandran plot uniformly ensures the AI learns both the rules and the exceptions of protein geometry.
- Structural Diversity: By varying 'length' and 'conformation', we minimize "Selection Bias", making the resulting AI model more robust and generalizable.
Data Factory Overview:
AI models for protein folding (like AlphaFold, RoseTTAFold) require massive datasets of (Structure, Sequence) pairs to learn the patterns of protein physics. Real PDB data is limited (~200k structures). Synthetic data allows us to: 1. Augment training data with unlimited diversity. 2. Balance the dataset (e.g., more examples of rare secondary structures). 3. Create "uncurated" datasets to test model robustness.
This generator produces: - PDB files (coordinates) - Contact Maps (distance constraints) - Metadata Manifest (CSV)
Source code in synth_pdb/dataset.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
Functions
__init__(output_dir, num_samples=100, min_length=10, max_length=50, train_ratio=0.8, seed=None, max_workers=None, dataset_format='pdb')
Source code in synth_pdb/dataset.py
generate()
Run the generation loop using multiprocessing.
Source code in synth_pdb/dataset.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
prepare_directories()
Create the directory structure for the dataset.
Source code in synth_pdb/dataset.py
Main Functions
_generate_single_sample_task(args)
Helper function to generate a single sample. Arguments are passed as a tuple to be compatible with map/submit if needed, but we'll use unpacking for clarity.
_generate_single_sample_npz_task(args)
Generate a single sample in NPZ format (AI-Ready). Does NOT write intermediate PDB files.
Usage Examples
Bulk Dataset Generation
Generate a balanced dataset of 1,000 structures with varied secondary structures and lengths.
from synth_pdb.dataset import DatasetGenerator
generator = DatasetGenerator(
output_dir="./synthetic_dataset",
num_samples=1000,
min_length=30,
max_length=150,
train_ratio=0.8,
max_workers=8
)
generator.generate()
The resulting directory will contain:
- train/: PDB and CASP (contact map) files for training.
- test/: PDB and CASP files for testing.
- dataset_manifest.csv: A manifest mapping IDs to file paths and metadata.
AI-Ready NPZ Export
For deep learning frameworks, it is often more efficient to store data in compressed NumPy format.
generator = DatasetGenerator(
output_dir="./ai_dataset",
dataset_format="npz"
)
generator.generate()
Educational Notes
The Balanced Dataset Problem
When training AI models, the quality and balance of the data are often more important than the quantity. 1. The Alpha-Helix Trap: If a dataset only contains helices, the AI will fail to generalize to beta-sheets or disordered regions. 2. Mixed Conformations: This module encourages a mix of 'alpha', 'beta', and 'random' conformations to ensure the model learns the full breadth of protein geometry. 3. Structural Diversity: Varying lengths and sequences minimizes "Selection Bias," leading to more robust models.
Why Distance Matrices instead of Binary Contact Maps?
Binary contact maps (0/1) indicate whether atoms are within a threshold (usually 8.0 Å). While common, they discard detailed geometric information. Modern models (like AlphaFold) use Distograms (weighted distance bins) or raw distances to learn a continuous representation of the energy landscape. The dataset module can export exact ground-truth distances to support these advanced training objectives.
See Also
- batch_generator Module - Vectorized structure generation
- generator Module - Serial structure generation
- Scientific Background: Energy Minimization