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.
@@ -0,0 +1,153 @@
1
+ # ---------------------------------------------------------------
2
+ # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3
+ # ---------------------------------------------------------------
4
+
5
+ """
6
+ Boltz-2 Python Client
7
+
8
+ A comprehensive Python client for NVIDIA's Boltz-2 molecular structure prediction service.
9
+ Supports both local deployments and NVIDIA hosted endpoints with full API coverage.
10
+
11
+ Example:
12
+ >>> from boltz2_client import Boltz2Client, EndpointType
13
+ >>>
14
+ >>> # Local endpoint
15
+ >>> client = Boltz2Client("http://localhost:8000")
16
+ >>>
17
+ >>> # NVIDIA hosted endpoint
18
+ >>> client = Boltz2Client(
19
+ ... base_url="https://health.api.nvidia.com",
20
+ ... api_key="your_api_key",
21
+ ... endpoint_type=EndpointType.NVIDIA_HOSTED
22
+ ... )
23
+ >>>
24
+ >>> # Simple protein prediction
25
+ >>> result = await client.predict_protein_structure("MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLAGG")
26
+ >>> print(f"Confidence: {result.confidence_scores[0]:.3f}")
27
+ """
28
+
29
+ __version__ = "0.2"
30
+ __author__ = "NVIDIA Corporation"
31
+
32
+ from .client import Boltz2Client, Boltz2SyncClient, EndpointType
33
+ from .models import (
34
+ PredictionRequest,
35
+ PredictionResponse,
36
+ Polymer,
37
+ Ligand,
38
+ PocketConstraint,
39
+ BondConstraint,
40
+ Atom,
41
+ AlignmentFileRecord,
42
+ HealthStatus,
43
+ ServiceMetadata,
44
+ )
45
+ from .models_affinity import AffinityPrediction
46
+ from .exceptions import (
47
+ Boltz2Error,
48
+ Boltz2ClientError,
49
+ Boltz2APIError,
50
+ Boltz2TimeoutError,
51
+ Boltz2ConnectionError,
52
+ Boltz2ValidationError,
53
+ )
54
+ from .virtual_screening import (
55
+ VirtualScreening,
56
+ CompoundLibrary,
57
+ VirtualScreeningResult,
58
+ quick_screen,
59
+ )
60
+
61
+ # Optional imports for visualization
62
+ try:
63
+ from .visualization import (
64
+ StructureVisualizer,
65
+ visualize_structure,
66
+ create_multi_view,
67
+ )
68
+ _HAS_VISUALIZATION = True
69
+ except ImportError:
70
+ _HAS_VISUALIZATION = False
71
+
72
+ # Optional imports for analysis
73
+ try:
74
+ from .analysis import (
75
+ StructureAnalyzer,
76
+ calculate_rmsd,
77
+ analyze_contacts,
78
+ )
79
+ _HAS_ANALYSIS = True
80
+ except ImportError:
81
+ _HAS_ANALYSIS = False
82
+
83
+ __all__ = [
84
+ # Core client classes
85
+ "Boltz2Client",
86
+ "Boltz2SyncClient",
87
+ "EndpointType",
88
+
89
+ # Data models
90
+ "PredictionRequest",
91
+ "PredictionResponse",
92
+ "Polymer",
93
+ "Ligand",
94
+ "PocketConstraint",
95
+ "BondConstraint",
96
+ "Atom",
97
+ "AlignmentFileRecord",
98
+ "HealthStatus",
99
+ "ServiceMetadata",
100
+ "AffinityPrediction",
101
+
102
+ # Exceptions
103
+ "Boltz2Error",
104
+ "Boltz2ClientError",
105
+ "Boltz2APIError",
106
+ "Boltz2TimeoutError",
107
+ "Boltz2ConnectionError",
108
+ "Boltz2ValidationError",
109
+
110
+ # Virtual screening
111
+ "VirtualScreening",
112
+ "CompoundLibrary",
113
+ "VirtualScreeningResult",
114
+ "quick_screen",
115
+ ]
116
+
117
+ # Add visualization exports if available
118
+ if _HAS_VISUALIZATION:
119
+ __all__.extend([
120
+ "StructureVisualizer",
121
+ "visualize_structure",
122
+ "create_multi_view",
123
+ ])
124
+
125
+ # Add analysis exports if available
126
+ if _HAS_ANALYSIS:
127
+ __all__.extend([
128
+ "StructureAnalyzer",
129
+ "calculate_rmsd",
130
+ "analyze_contacts",
131
+ ])
132
+
133
+ def get_version() -> str:
134
+ """Get the current version of the package."""
135
+ return __version__
136
+
137
+ def check_health(base_url: str = "http://localhost:8000", endpoint_type: str = "local") -> bool:
138
+ """
139
+ Quick health check for a Boltz-2 service.
140
+
141
+ Args:
142
+ base_url: Base URL of the Boltz-2 service
143
+ endpoint_type: Type of endpoint ("local" or "nvidia_hosted")
144
+
145
+ Returns:
146
+ True if service is healthy, False otherwise
147
+ """
148
+ try:
149
+ client = Boltz2SyncClient(base_url=base_url, endpoint_type=endpoint_type)
150
+ health = client.health_check()
151
+ return health.status == "healthy"
152
+ except Exception:
153
+ return False