boltz2-python-client 0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boltz2_client/__init__.py +153 -0
- boltz2_client/cli.py +1213 -0
- boltz2_client/client.py +986 -0
- boltz2_client/exceptions.py +213 -0
- boltz2_client/models.py +466 -0
- boltz2_client/models_affinity.py +46 -0
- boltz2_client/utils.py +455 -0
- boltz2_client/virtual_screening.py +608 -0
- boltz2_python_client-0.2.dist-info/METADATA +533 -0
- boltz2_python_client-0.2.dist-info/RECORD +14 -0
- boltz2_python_client-0.2.dist-info/WHEEL +5 -0
- boltz2_python_client-0.2.dist-info/entry_points.txt +2 -0
- boltz2_python_client-0.2.dist-info/licenses/LICENSE +21 -0
- boltz2_python_client-0.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: boltz2-python-client
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: Python client for Boltz-2 protein structure prediction API with covalent complex support
|
|
5
|
+
Author: NVIDIA Corporation
|
|
6
|
+
Maintainer: NVIDIA Corporation
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/NVIDIA/bionemo-examples/tree/add-boltz2-python-client/examples/nims/boltz-2
|
|
9
|
+
Project-URL: Repository, https://github.com/NVIDIA/bionemo-examples/tree/add-boltz2-python-client/examples/nims/boltz-2
|
|
10
|
+
Keywords: protein,structure,prediction,AI,machine learning,bioinformatics,covalent,complex,boltz2
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: httpx>=0.24.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
30
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
31
|
+
Requires-Dist: rich>=13.0.0
|
|
32
|
+
Requires-Dist: click>=8.0.0
|
|
33
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
34
|
+
Requires-Dist: py3Dmol>=2.0.0
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Boltz-2 NIM
|
|
38
|
+
|
|
39
|
+
Boltz-2 NIM is a next-generation structural biology foundation model that shows strong performance for both structure and affinity prediction. Boltz-2 is the first deep learning model to approach the accuracy of free energy perturbation (FEP) methods in predicting binding affinities of small molecules and proteinsβachieving strong correlations on benchmarks while being nearly 1000Γ more computationally efficient.
|
|
40
|
+
|
|
41
|
+
Boltz-2 NIM can be acceseed at [build.nvidia.com](https://docs.api.nvidia.com/nim/reference/mit-boltz2).
|
|
42
|
+
|
|
43
|
+
Example notebooks on how to use Boltz-2 NIM endpoint:
|
|
44
|
+
- [Predicting protein-liagnd covalent complex](./examples/boltz2_nim_protein_ligand_covalent_complex_molstar_visualization.ipynb)
|
|
45
|
+
- [Predicting protein-DNA complex](./examples/boltz2_nim_DNA_Protein_Complex_example_py3Dmol.ipynb)
|
|
46
|
+
|
|
47
|
+
However, there's an easier way to access Boltz-2 NIM functionalities using the Boltz-2 client:
|
|
48
|
+
- [Boltz-2 client demo](./examples/boltz2_demo.ipynb)
|
|
49
|
+
|
|
50
|
+
Below is the description of the Boltz-2 client. Enjoy!
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Boltz-2 Python Client
|
|
54
|
+
|
|
55
|
+
Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
|
|
56
|
+
|
|
57
|
+
[](https://badge.fury.io/py/boltz2-python-client)
|
|
58
|
+
[](https://www.python.org/downloads/)
|
|
59
|
+
[](https://opensource.org/licenses/MIT)
|
|
60
|
+
|
|
61
|
+
A comprehensive Python client for NVIDIA's Boltz-2 biomolecular structure prediction service. This package provides both synchronous and asynchronous interfaces, a rich CLI, and built-in 3D visualization capabilities.
|
|
62
|
+
|
|
63
|
+
## π **Features**
|
|
64
|
+
|
|
65
|
+
- β
**Full API Coverage** - Complete Boltz-2 API support
|
|
66
|
+
- β
**Async & Sync Clients** - Choose your preferred programming style
|
|
67
|
+
- β
**Rich CLI Interface** - Beautiful command-line tools with progress bars
|
|
68
|
+
- β
**3D Visualization** - Built-in py3Dmol integration for structure viewing
|
|
69
|
+
- β
**Flexible Endpoints** - Support for both local and NVIDIA hosted services
|
|
70
|
+
- β
**Type Safety** - Full Pydantic model validation
|
|
71
|
+
- β
**YAML Configuration** - Official Boltz format support
|
|
72
|
+
- β
**Affinity Prediction** - Predict binding affinity (IC50) for protein-ligand complexes
|
|
73
|
+
- β
**Virtual Screening** - High-level API for drug discovery campaigns
|
|
74
|
+
- β
**Comprehensive Examples** - Ready-to-use code samples
|
|
75
|
+
|
|
76
|
+
## π¦ **Installation**
|
|
77
|
+
|
|
78
|
+
### From PyPI (Recommended)
|
|
79
|
+
```bash
|
|
80
|
+
pip install boltz2-python-client
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### From TestPyPI (Latest Development)
|
|
84
|
+
```bash
|
|
85
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ boltz2-python-client
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### From Source
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/NVIDIA/boltz2-python-client.git
|
|
91
|
+
cd boltz2-python-client
|
|
92
|
+
pip install -e .
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## π― **Quick Start**
|
|
96
|
+
|
|
97
|
+
### Python API
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import asyncio
|
|
101
|
+
from boltz2_client import Boltz2Client
|
|
102
|
+
|
|
103
|
+
async def quick_prediction():
|
|
104
|
+
client = Boltz2Client(base_url="http://localhost:8000")
|
|
105
|
+
seq = "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLAGG"
|
|
106
|
+
|
|
107
|
+
# --- BASIC (no MSA) --------------------------------------------
|
|
108
|
+
basic = await client.predict_protein_structure(sequence=seq)
|
|
109
|
+
print("basic confidence", basic.confidence_scores[0])
|
|
110
|
+
|
|
111
|
+
# --- MSA-GUIDED --------------------------------------------------
|
|
112
|
+
msa_path = "msa-kras-g12c_combined.a3m" # any *.a3m/*.sto/*.fasta file
|
|
113
|
+
msa = [(msa_path, "a3m")]
|
|
114
|
+
|
|
115
|
+
msa_res = await client.predict_protein_structure(
|
|
116
|
+
sequence=seq,
|
|
117
|
+
msa_files=msa, # NEW helper will auto-convert β nested-dict
|
|
118
|
+
sampling_steps=50,
|
|
119
|
+
recycling_steps=3,
|
|
120
|
+
)
|
|
121
|
+
print("msa confidence", msa_res.confidence_scores[0])
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
asyncio.run(quick_prediction())
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### CLI Usage
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Health check
|
|
132
|
+
boltz2 health
|
|
133
|
+
|
|
134
|
+
# Protein structure prediction
|
|
135
|
+
boltz2 protein "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLAGG"
|
|
136
|
+
|
|
137
|
+
# Protein-ligand complex
|
|
138
|
+
boltz2 ligand "PROTEIN_SEQUENCE" --smiles "CC(=O)OC1=CC=CC=C1C(=O)O"
|
|
139
|
+
|
|
140
|
+
# Protein-ligand with affinity prediction
|
|
141
|
+
boltz2 ligand "PROTEIN_SEQUENCE" --smiles "CC(=O)OC1=CC=CC=C1C(=O)O" --predict-affinity
|
|
142
|
+
|
|
143
|
+
# Covalent complex with bond constraints
|
|
144
|
+
boltz2 covalent "SEQUENCE" --ccd U4U --bond A:11:SG:L:C22
|
|
145
|
+
|
|
146
|
+
# Virtual screening campaign
|
|
147
|
+
boltz2 screen "TARGET_SEQUENCE" compounds.csv -o screening_results/
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Affinity Prediction
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from boltz2_client import Boltz2Client, Polymer, Ligand, PredictionRequest
|
|
154
|
+
|
|
155
|
+
client = Boltz2Client()
|
|
156
|
+
|
|
157
|
+
# Create protein and ligand with affinity prediction
|
|
158
|
+
protein = Polymer(id="A", molecule_type="protein", sequence="YOUR_SEQUENCE")
|
|
159
|
+
ligand = Ligand(id="LIG", smiles="CC(=O)OC1=CC=CC=C1C(=O)O", predict_affinity=True)
|
|
160
|
+
|
|
161
|
+
request = PredictionRequest(
|
|
162
|
+
polymers=[protein],
|
|
163
|
+
ligands=[ligand],
|
|
164
|
+
sampling_steps_affinity=200, # Affinity-specific parameters
|
|
165
|
+
diffusion_samples_affinity=5
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
result = await client.predict(request)
|
|
169
|
+
|
|
170
|
+
# Access affinity results
|
|
171
|
+
if result.affinities and "LIG" in result.affinities:
|
|
172
|
+
affinity = result.affinities["LIG"]
|
|
173
|
+
print(f"pIC50: {affinity.affinity_pic50[0]:.2f}")
|
|
174
|
+
print(f"IC50: {10**(-affinity.affinity_pic50[0])*1e9:.1f} nM")
|
|
175
|
+
print(f"Binding probability: {affinity.affinity_probability_binary[0]:.1%}")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Virtual Screening
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from boltz2_client import quick_screen
|
|
182
|
+
|
|
183
|
+
# Minimal virtual screening
|
|
184
|
+
compounds = [
|
|
185
|
+
{"name": "Aspirin", "smiles": "CC(=O)OC1=CC=CC=C1C(=O)O"},
|
|
186
|
+
{"name": "Ibuprofen", "smiles": "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O"}
|
|
187
|
+
]
|
|
188
|
+
|
|
189
|
+
result = quick_screen(
|
|
190
|
+
target_sequence="YOUR_PROTEIN_SEQUENCE",
|
|
191
|
+
compounds=compounds,
|
|
192
|
+
target_name="My Target",
|
|
193
|
+
output_dir="screening_results"
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
# Show top hits
|
|
197
|
+
print(result.get_top_hits(n=5))
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 3D Visualization
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
import py3Dmol
|
|
204
|
+
from boltz2_client import Boltz2Client
|
|
205
|
+
|
|
206
|
+
client = Boltz2Client()
|
|
207
|
+
result = await client.predict_protein_structure(sequence="YOUR_SEQUENCE", recycling_steps=6, sampling_steps=50 )
|
|
208
|
+
|
|
209
|
+
# Create 3D visualization
|
|
210
|
+
view = py3Dmol.view(width=800, height=600)
|
|
211
|
+
view.addModel(result.structures[0].structure, 'cif')
|
|
212
|
+
view.setStyle({'cartoon': {'color': 'spectrum'}})
|
|
213
|
+
view.zoomTo()
|
|
214
|
+
view.show()
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## π§ **Configuration**
|
|
218
|
+
|
|
219
|
+
### Local Endpoint (Default)
|
|
220
|
+
```python
|
|
221
|
+
client = Boltz2Client(base_url="http://localhost:8000")
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### NVIDIA Hosted Endpoint
|
|
225
|
+
```python
|
|
226
|
+
client = Boltz2Client(
|
|
227
|
+
base_url="https://health.api.nvidia.com",
|
|
228
|
+
api_key="your_api_key",
|
|
229
|
+
endpoint_type="nvidia_hosted"
|
|
230
|
+
)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Environment Variables
|
|
234
|
+
```bash
|
|
235
|
+
export NVIDIA_API_KEY="your_api_key"
|
|
236
|
+
export BOLTZ2_BASE_URL="http://localhost:8000"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## π³ **Local Deployment Setup**
|
|
240
|
+
|
|
241
|
+
To run Boltz-2 locally using NVIDIA's NIM (NVIDIA Inference Microservice) container, follow these steps:
|
|
242
|
+
|
|
243
|
+
### Prerequisites
|
|
244
|
+
- **NVIDIA GPU** with sufficient VRAM (recommended: 24GB+)
|
|
245
|
+
- **Docker** with NVIDIA Container Runtime
|
|
246
|
+
- **NGC Account** with API key
|
|
247
|
+
|
|
248
|
+
### Step 1: Generate NGC API Key
|
|
249
|
+
1. Go to [NGC (NVIDIA GPU Cloud)](https://ngc.nvidia.com/)
|
|
250
|
+
2. Sign in or create an account
|
|
251
|
+
3. Navigate to **Setup β Generate API Key**
|
|
252
|
+
4. Copy your personal API key
|
|
253
|
+
|
|
254
|
+
### Step 2: Docker Login
|
|
255
|
+
```bash
|
|
256
|
+
# Login to NVIDIA Container Registry
|
|
257
|
+
docker login nvcr.io
|
|
258
|
+
Username: $oauthtoken
|
|
259
|
+
Password: <PASTE_API_KEY_HERE>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Step 3: Set Up Environment
|
|
263
|
+
```bash
|
|
264
|
+
# Export your NGC API key
|
|
265
|
+
export NGC_API_KEY=<your_personal_NGC_key>
|
|
266
|
+
|
|
267
|
+
# Create local cache directory (recommended for model reuse)
|
|
268
|
+
export LOCAL_NIM_CACHE=~/.cache/nim
|
|
269
|
+
mkdir -p $LOCAL_NIM_CACHE
|
|
270
|
+
chmod -R 777 $LOCAL_NIM_CACHE
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Step 4: Run Boltz-2 NIM Container
|
|
274
|
+
|
|
275
|
+
#### Option A: Use All Available GPUs (Default)
|
|
276
|
+
```bash
|
|
277
|
+
docker run -it \
|
|
278
|
+
--runtime=nvidia \
|
|
279
|
+
-p 8000:8000 \
|
|
280
|
+
-e NGC_API_KEY \
|
|
281
|
+
-v "$LOCAL_NIM_CACHE":/opt/nim/.cache \
|
|
282
|
+
nvcr.io/nim/mit/boltz2:1.1.0
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
#### Option B: Use Specific GPU (e.g., GPU 0)
|
|
286
|
+
```bash
|
|
287
|
+
docker run -it \
|
|
288
|
+
--runtime=nvidia \
|
|
289
|
+
--gpus='"device=0"' \
|
|
290
|
+
-p 8000:8000 \
|
|
291
|
+
-e NGC_API_KEY \
|
|
292
|
+
-v "$LOCAL_NIM_CACHE":/opt/nim/.cache \
|
|
293
|
+
nvcr.io/nim/mit/boltz2:1.1.0
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Step 5: Verify Installation
|
|
297
|
+
Once the container is running, test the service:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Health check
|
|
301
|
+
curl http://localhost:8000/v1/health/live
|
|
302
|
+
|
|
303
|
+
# Or using the Python client
|
|
304
|
+
python -c "
|
|
305
|
+
import asyncio
|
|
306
|
+
from boltz2_client import Boltz2Client
|
|
307
|
+
|
|
308
|
+
async def test():
|
|
309
|
+
client = Boltz2Client(base_url='http://localhost:8000')
|
|
310
|
+
health = await client.health_check()
|
|
311
|
+
print(f'Service status: {health.status}')
|
|
312
|
+
|
|
313
|
+
asyncio.run(test())
|
|
314
|
+
"
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### π¨ **Important Notes**
|
|
318
|
+
|
|
319
|
+
- **First Run**: The container will automatically download models (~several GB), which may take time
|
|
320
|
+
- **Cache Directory**: Using `LOCAL_NIM_CACHE` saves bandwidth and time for subsequent runs
|
|
321
|
+
- **GPU Memory**: Ensure sufficient GPU memory for your prediction workloads
|
|
322
|
+
- **Port 8000**: Make sure port 8000 is available and not blocked by firewall
|
|
323
|
+
- **Network**: Container needs internet access for initial model downloads
|
|
324
|
+
|
|
325
|
+
### π§ **Troubleshooting**
|
|
326
|
+
|
|
327
|
+
**Container fails to start:**
|
|
328
|
+
```bash
|
|
329
|
+
# Check GPU availability
|
|
330
|
+
nvidia-smi
|
|
331
|
+
|
|
332
|
+
# Check Docker NVIDIA runtime
|
|
333
|
+
docker run --rm --runtime=nvidia nvidia/cuda:11.0-base nvidia-smi
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Permission issues:**
|
|
337
|
+
```bash
|
|
338
|
+
# Fix cache directory permissions
|
|
339
|
+
sudo chown -R $USER:$USER $LOCAL_NIM_CACHE
|
|
340
|
+
chmod -R 755 $LOCAL_NIM_CACHE
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Memory issues:**
|
|
344
|
+
```bash
|
|
345
|
+
# Monitor GPU memory usage
|
|
346
|
+
watch -n 1 nvidia-smi
|
|
347
|
+
|
|
348
|
+
# Use specific GPU with more memory
|
|
349
|
+
docker run --gpus='"device=1"' ... # Use GPU 1 instead
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## π **Examples**
|
|
353
|
+
|
|
354
|
+
The `examples/` directory contains comprehensive examples:
|
|
355
|
+
|
|
356
|
+
- **01_basic_protein_folding.py** - Simple protein structure prediction
|
|
357
|
+
- **02_protein_structure_prediction_with_msa.py** - MSA-guided predictions with comparison
|
|
358
|
+
- **03_protein_ligand_complex.py** - Protein-ligand complexes
|
|
359
|
+
- **04_covalent_bonding.py** - Covalent bond constraints
|
|
360
|
+
- **05_dna_protein_complex.py** - DNA-protein interactions
|
|
361
|
+
- **06_yaml_configurations.py** - YAML config files
|
|
362
|
+
- **07_advanced_parameters.py** - Advanced API parameters
|
|
363
|
+
- **08_affinity_prediction.py** - Binding affinity prediction (IC50/pIC50)
|
|
364
|
+
|
|
365
|
+
## π§ͺ **Supported Prediction Types**
|
|
366
|
+
|
|
367
|
+
| Type | Description | CLI Command | Python Method |
|
|
368
|
+
|------|-------------|-------------|---------------|
|
|
369
|
+
| **Protein** | Single protein folding | `protein` | `predict_protein_structure()` |
|
|
370
|
+
| **Ligand Complex** | Protein-ligand binding | `ligand` | `predict_protein_ligand_complex()` |
|
|
371
|
+
| **Covalent Complex** | Covalent bonds | `covalent` | `predict_covalent_complex()` |
|
|
372
|
+
| **DNA-Protein** | Nucleic acid complexes | `dna-protein` | `predict_dna_protein_complex()` |
|
|
373
|
+
| **Advanced** | Custom parameters | `advanced` | `predict_with_advanced_parameters()` |
|
|
374
|
+
| **YAML** | Configuration files | `yaml` | `predict_from_yaml_config()` |
|
|
375
|
+
|
|
376
|
+
## π¬ **Advanced Features**
|
|
377
|
+
|
|
378
|
+
### Batch Processing
|
|
379
|
+
```python
|
|
380
|
+
from boltz2_client import Boltz2Client
|
|
381
|
+
import asyncio
|
|
382
|
+
|
|
383
|
+
async def batch_predictions():
|
|
384
|
+
client = Boltz2Client()
|
|
385
|
+
sequences = ["SEQ1", "SEQ2", "SEQ3"]
|
|
386
|
+
|
|
387
|
+
# Process multiple sequences concurrently
|
|
388
|
+
tasks = [client.predict_protein_structure(seq) for seq in sequences]
|
|
389
|
+
results = await asyncio.gather(*tasks)
|
|
390
|
+
|
|
391
|
+
for i, result in enumerate(results):
|
|
392
|
+
print(f"Sequence {i+1}: Confidence {result.confidence:.3f}")
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### MSA-Guided Predictions
|
|
396
|
+
```python
|
|
397
|
+
# With MSA file
|
|
398
|
+
result = await client.predict_protein_structure(
|
|
399
|
+
sequence="YOUR_SEQUENCE",
|
|
400
|
+
msa_file="path/to/alignment.a3m"
|
|
401
|
+
)
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Custom Parameters
|
|
405
|
+
```python
|
|
406
|
+
result = await client.predict_with_advanced_parameters(
|
|
407
|
+
polymers=[{"id": "A", "sequence": "SEQUENCE"}],
|
|
408
|
+
recycling_steps=3,
|
|
409
|
+
sampling_steps=200,
|
|
410
|
+
diffusion_samples=1
|
|
411
|
+
)
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### π Affinity Prediction
|
|
415
|
+
Predict binding affinity (IC50/pIC50) for protein-ligand complexes:
|
|
416
|
+
|
|
417
|
+
```python
|
|
418
|
+
from boltz2_client import Boltz2Client, Polymer, Ligand, PredictionRequest
|
|
419
|
+
|
|
420
|
+
# Create protein and ligand
|
|
421
|
+
protein = Polymer(id="A", molecule_type="protein", sequence="YOUR_SEQUENCE")
|
|
422
|
+
ligand = Ligand(id="LIG", smiles="CC(=O)OC1=CC=CC=C1C(=O)O", predict_affinity=True)
|
|
423
|
+
|
|
424
|
+
# Create request with affinity parameters
|
|
425
|
+
request = PredictionRequest(
|
|
426
|
+
polymers=[protein],
|
|
427
|
+
ligands=[ligand],
|
|
428
|
+
sampling_steps_affinity=200, # Default: 200
|
|
429
|
+
diffusion_samples_affinity=5, # Default: 5
|
|
430
|
+
affinity_mw_correction=False # Default: False
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
# Predict structure and affinity
|
|
434
|
+
result = await client.predict(request)
|
|
435
|
+
|
|
436
|
+
# Access affinity results
|
|
437
|
+
if result.affinities and "LIG" in result.affinities:
|
|
438
|
+
affinity = result.affinities["LIG"]
|
|
439
|
+
print(f"pIC50: {affinity.affinity_pic50[0]:.3f}")
|
|
440
|
+
print(f"Binding probability: {affinity.affinity_probability_binary[0]:.3f}")
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### CLI Usage
|
|
444
|
+
```bash
|
|
445
|
+
# Basic affinity prediction
|
|
446
|
+
boltz2 ligand "PROTEIN_SEQUENCE" --smiles "LIGAND_SMILES" --predict-affinity
|
|
447
|
+
|
|
448
|
+
# With custom parameters
|
|
449
|
+
boltz2 ligand "PROTEIN_SEQUENCE" --ccd Y7W \
|
|
450
|
+
--predict-affinity \
|
|
451
|
+
--sampling-steps-affinity 100 \
|
|
452
|
+
--diffusion-samples-affinity 3 \
|
|
453
|
+
--affinity-mw-correction
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
**Note:** Only ONE ligand per request can have affinity prediction enabled.
|
|
457
|
+
|
|
458
|
+
## π **Development**
|
|
459
|
+
|
|
460
|
+
### Setup Development Environment
|
|
461
|
+
```bash
|
|
462
|
+
git clone https://github.com/NVIDIA/boltz2-python-client.git
|
|
463
|
+
cd boltz2-python-client
|
|
464
|
+
pip install -e ".[dev]"
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Run Tests
|
|
468
|
+
```bash
|
|
469
|
+
pytest tests/
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Code Formatting
|
|
473
|
+
```bash
|
|
474
|
+
black boltz2_client/
|
|
475
|
+
isort boltz2_client/
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Type Checking
|
|
479
|
+
```bash
|
|
480
|
+
mypy boltz2_client/
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
## π **Requirements**
|
|
484
|
+
|
|
485
|
+
- **Python**: 3.8+
|
|
486
|
+
- **Dependencies**:
|
|
487
|
+
- `httpx>=0.24.0` - HTTP client
|
|
488
|
+
- `pydantic>=2.0.0` - Data validation
|
|
489
|
+
- `rich>=13.0.0` - CLI formatting
|
|
490
|
+
- `aiofiles>=23.0.0` - Async file operations
|
|
491
|
+
- `click>=8.0.0` - CLI framework
|
|
492
|
+
- `PyYAML>=6.0.0` - YAML support
|
|
493
|
+
- `py3Dmol>=2.0.0` - 3D visualization
|
|
494
|
+
|
|
495
|
+
## π€ **Contributing**
|
|
496
|
+
|
|
497
|
+
1. Fork the repository
|
|
498
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
499
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
500
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
501
|
+
5. Open a Merge Request
|
|
502
|
+
|
|
503
|
+
## π **License**
|
|
504
|
+
|
|
505
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
506
|
+
|
|
507
|
+
Third-party dependencies are licensed under their respective licenses - see the [licenses/](licenses/) directory for details.
|
|
508
|
+
|
|
509
|
+
## π **Documentation**
|
|
510
|
+
|
|
511
|
+
### Guides
|
|
512
|
+
- **[Affinity Prediction Guide](AFFINITY_PREDICTION_GUIDE.md)** - Comprehensive guide for binding affinity prediction
|
|
513
|
+
- **[YAML Configuration Guide](YAML_GUIDE.md)** - Working with YAML configuration files
|
|
514
|
+
- **[Async Programming Guide](ASYNC_GUIDE.md)** - Best practices for async operations
|
|
515
|
+
- **[Covalent Complex Guide](COVALENT_COMPLEX_GUIDE.md)** - Predicting covalent bonds
|
|
516
|
+
- **[Parameters Guide](PARAMETERS.md)** - Detailed parameter documentation
|
|
517
|
+
|
|
518
|
+
## π **Links**
|
|
519
|
+
|
|
520
|
+
- **TestPyPI**: https://test.pypi.org/project/boltz2-python-client/
|
|
521
|
+
- **NVIDIA BioNeMo**: https://www.nvidia.com/en-us/clara/bionemo/
|
|
522
|
+
- **Boltz-2 Paper**: [Link to Boltz-2 paper](https://cdn.prod.website-files.com/68404fd075dba49e58331ad9/6842ee1285b9af247ac5a122_boltz2.pdf)
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
## π **Acknowledgments**
|
|
526
|
+
|
|
527
|
+
- NVIDIA BioNeMo Team for the Boltz-2 service
|
|
528
|
+
- Contributors and testers
|
|
529
|
+
- Open source community
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
**Made with β€οΈ for the computational biology community**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
boltz2_client/__init__.py,sha256=6VL2tN0X9L-espiB61WCB37mfJgwpW1auM1xDNelyco,3856
|
|
2
|
+
boltz2_client/cli.py,sha256=jSSd2lMDdIMcHyxqcwL4dQ3HG2WgtnBp7YDXT0T6Vto,52289
|
|
3
|
+
boltz2_client/client.py,sha256=SPXQQMKEkaRbru89vsXhoNz3z7Pj230y4rAyQMpSb1E,36464
|
|
4
|
+
boltz2_client/exceptions.py,sha256=x-5MvZfsN1sLVJjiy8DMNfdmzJDxTosl2QGYKnrhz5k,6725
|
|
5
|
+
boltz2_client/models.py,sha256=e5EEerIJhAzRl8WPln-gi-5FmvxzMVE-TBZ8bwUFipQ,20098
|
|
6
|
+
boltz2_client/models_affinity.py,sha256=cfWUeCazO_5WYwGnXp9iNwXs2KdAdBu1xQtmanYSQKI,1511
|
|
7
|
+
boltz2_client/utils.py,sha256=myk4O1ZiJmUvQ-1gQfj_SiDqh3wBINAsLFxH5P5X-cQ,12193
|
|
8
|
+
boltz2_client/virtual_screening.py,sha256=lTubnyTtw5wHurpSuipWgq84J0qjS5xuU1xslvBeBBo,23363
|
|
9
|
+
boltz2_python_client-0.2.dist-info/licenses/LICENSE,sha256=7sYV_pvGtWzybTdOcFXLDPRZL2VolpIl6nt8akVEO94,1111
|
|
10
|
+
boltz2_python_client-0.2.dist-info/METADATA,sha256=QZDGzXgt9aMJA9ikx6VJTlgY-G2iFGrzWsDY5yD6jT4,16802
|
|
11
|
+
boltz2_python_client-0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
+
boltz2_python_client-0.2.dist-info/entry_points.txt,sha256=3whjBtXqltfepvt46DSJNpeUGCZGLRFYnccMEVXMCes,49
|
|
13
|
+
boltz2_python_client-0.2.dist-info/top_level.txt,sha256=INM1MYyL_h2nQkTFjZE7AmrgX4ZePTr4uw4n7Sag3ao,14
|
|
14
|
+
boltz2_python_client-0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
boltz2_client
|