openprotein-python 0.6.2__tar.gz → 0.7.0__tar.gz
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.
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/.gitignore +2 -1
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/PKG-INFO +6 -4
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/__init__.py +11 -0
- openprotein_python-0.7.0/openprotein/align/__init__.py +2 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/align.py +131 -152
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/embedding.py +66 -22
- openprotein_python-0.7.0/openprotein/api/error.py +5 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/fold.py +5 -3
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/predictor.py +11 -0
- openprotein_python-0.7.0/openprotein/api/prompt.py +464 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/svd.py +11 -4
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/umap.py +11 -4
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/__init__.py +1 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/__init__.py +3 -1
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/align/__init__.py +0 -1
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/align/msa.py +21 -20
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/deprecated/__init__.py +0 -3
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/__init__.py +1 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/future.py +1 -1
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/poet.py +73 -181
- openprotein_python-0.7.0/openprotein/app/models/embeddings/poet2.py +385 -0
- openprotein_python-0.7.0/openprotein/app/models/fold/boltz.py +57 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/fold/esmfold.py +7 -3
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/futures.py +1 -1
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/predictor/predictor.py +31 -9
- openprotein_python-0.7.0/openprotein/app/models/prompt.py +141 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/__init__.py +1 -0
- openprotein_python-0.7.0/openprotein/app/services/align.py +356 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/embeddings.py +4 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/predictor.py +26 -2
- openprotein_python-0.7.0/openprotein/app/services/prompt.py +133 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/base.py +8 -10
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/embeddings/__init__.py +1 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/errors.py +8 -0
- openprotein_python-0.7.0/openprotein/protein.py +555 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/__init__.py +13 -1
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/align.py +12 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/predictor.py +17 -2
- openprotein_python-0.7.0/openprotein/schemas/prompt.py +28 -0
- openprotein_python-0.7.0/openprotein/utils/uuid.py +29 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/pyproject.toml +56 -5
- openprotein_python-0.6.2/openprotein/align/__init__.py +0 -2
- openprotein_python-0.6.2/openprotein/api/deprecated/poet.py +0 -308
- openprotein_python-0.6.2/openprotein/app/models/align/prompt.py +0 -78
- openprotein_python-0.6.2/openprotein/app/models/deprecated/poet.py +0 -204
- openprotein_python-0.6.2/openprotein/app/services/align.py +0 -145
- openprotein_python-0.6.2/openprotein/schemas/deprecated/poet.py +0 -70
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/LICENSE.txt +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/README.md +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/_version.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/assaydata.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/deprecated/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/deprecated/design.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/deprecated/predict.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/deprecated/train.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/designer.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/api/job.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/deprecated.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/align/base.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/assaydata.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/deprecated/design.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/deprecated/predict.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/deprecated/train.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/designer.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/base.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/esm.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/openprotein.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/embeddings/test.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/fold/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/fold/alphafold2.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/fold/base.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/fold/future.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/predictor/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/predictor/predict.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/predictor/validate.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/svd.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/models/umap.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/assaydata.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/deprecated/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/deprecated/design.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/deprecated/predict.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/deprecated/train.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/designer.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/fold.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/job.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/svd.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/app/services/umap.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/config.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/csv.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/design/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/fasta.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/fold/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/jobs/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/predictor/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/assaydata.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/deprecated/__init__.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/deprecated/design.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/deprecated/predict.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/deprecated/train.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/design.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/designer.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/embeddings.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/features.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/fold.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/job.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/svd.py +0 -0
- {openprotein_python-0.6.2 → openprotein_python-0.7.0}/openprotein/schemas/umap.py +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: openprotein_python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: OpenProtein Python interface.
|
|
5
|
-
Author-email: Mark Gee <markgee@ne47.bio>
|
|
6
|
-
License: MIT
|
|
5
|
+
Author-email: Mark Gee <markgee@ne47.bio>, "Timothy Truong Jr." <ttruong@ne47.bio>, Tristan Bepler <tbepler@ne47.bio>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE.txt
|
|
7
8
|
Classifier: Development Status :: 4 - Beta
|
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
|
9
10
|
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: gemmi<0.8,>=0.7.0
|
|
10
12
|
Requires-Dist: numpy<3,>=1.9
|
|
11
13
|
Requires-Dist: pandas<3,>=2.2.2
|
|
12
14
|
Requires-Dist: pydantic<3,>=2.5
|
|
@@ -14,6 +14,7 @@ from openprotein.app import (
|
|
|
14
14
|
DataAPI,
|
|
15
15
|
JobsAPI,
|
|
16
16
|
AlignAPI,
|
|
17
|
+
PromptAPI,
|
|
17
18
|
EmbeddingsAPI,
|
|
18
19
|
FoldAPI,
|
|
19
20
|
SVDAPI,
|
|
@@ -36,6 +37,7 @@ class OpenProtein(APISession):
|
|
|
36
37
|
_data = None
|
|
37
38
|
_jobs = None
|
|
38
39
|
_align = None
|
|
40
|
+
_prompt = None
|
|
39
41
|
_embeddings = None
|
|
40
42
|
_svd = None
|
|
41
43
|
_umap = None
|
|
@@ -85,6 +87,15 @@ class OpenProtein(APISession):
|
|
|
85
87
|
self._align = AlignAPI(self)
|
|
86
88
|
return self._align
|
|
87
89
|
|
|
90
|
+
@property
|
|
91
|
+
def prompt(self) -> PromptAPI:
|
|
92
|
+
"""
|
|
93
|
+
The Align submodule gives access to the sequence alignment capabilities by building MSAs and prompts that can be used with PoET.
|
|
94
|
+
"""
|
|
95
|
+
if self._prompt is None:
|
|
96
|
+
self._prompt = PromptAPI(self)
|
|
97
|
+
return self._prompt
|
|
98
|
+
|
|
88
99
|
@property
|
|
89
100
|
def embedding(self) -> EmbeddingsAPI:
|
|
90
101
|
"""
|
|
@@ -2,8 +2,9 @@ import io
|
|
|
2
2
|
import random
|
|
3
3
|
from typing import BinaryIO, Iterator
|
|
4
4
|
|
|
5
|
-
import openprotein.config as config
|
|
6
5
|
import requests
|
|
6
|
+
|
|
7
|
+
import openprotein.config as config
|
|
7
8
|
from openprotein.base import APISession
|
|
8
9
|
from openprotein.csv import csv_stream
|
|
9
10
|
from openprotein.errors import APIError, InvalidParameterError, MissingParameterError
|
|
@@ -81,34 +82,6 @@ def get_input(
|
|
|
81
82
|
return csv_stream(response)
|
|
82
83
|
|
|
83
84
|
|
|
84
|
-
def get_prompt(
|
|
85
|
-
session: APISession, job: Job, prompt_index: int | None = None
|
|
86
|
-
) -> Iterator[list[str]]:
|
|
87
|
-
"""
|
|
88
|
-
Get the prompt for a given job.
|
|
89
|
-
|
|
90
|
-
Parameters
|
|
91
|
-
----------
|
|
92
|
-
session : APISession
|
|
93
|
-
The API session.
|
|
94
|
-
job : Job
|
|
95
|
-
The job for which to retrieve the prompt.
|
|
96
|
-
prompt_index : Optional[int], default=None
|
|
97
|
-
The index of the prompt. If None, it returns all.
|
|
98
|
-
|
|
99
|
-
Returns
|
|
100
|
-
-------
|
|
101
|
-
Iterator[list[str]]
|
|
102
|
-
A CSV reader for the prompt data.
|
|
103
|
-
"""
|
|
104
|
-
return get_input(
|
|
105
|
-
session=session,
|
|
106
|
-
job=job,
|
|
107
|
-
input_type=AlignType.PROMPT,
|
|
108
|
-
prompt_index=prompt_index,
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
|
|
112
85
|
def get_seed(session: APISession, job: Job) -> Iterator[list[str]]:
|
|
113
86
|
"""
|
|
114
87
|
Get the seed for a given MSA job.
|
|
@@ -197,6 +170,135 @@ def msa_post(
|
|
|
197
170
|
return Job.model_validate(response.json())
|
|
198
171
|
|
|
199
172
|
|
|
173
|
+
# TODO - document the `ep` and `op` parameters
|
|
174
|
+
def mafft_post(
|
|
175
|
+
session: APISession,
|
|
176
|
+
sequence_file: BinaryIO,
|
|
177
|
+
auto: bool = True,
|
|
178
|
+
ep: float | None = None,
|
|
179
|
+
op: float | None = None,
|
|
180
|
+
) -> Job:
|
|
181
|
+
"""
|
|
182
|
+
Align sequences using the `mafft` algorithm. Sequences can be provided as `fasta` or `csv` formats. If `csv`, the file must be headerless with either a single sequence column or name, sequence columns.
|
|
183
|
+
|
|
184
|
+
Set auto to True to automatically attempt the best params. Leave a parameter as None to use system defaults.
|
|
185
|
+
|
|
186
|
+
Parameters
|
|
187
|
+
----------
|
|
188
|
+
session : APISession
|
|
189
|
+
sequence_file : BinaryIO
|
|
190
|
+
Sequences to align in fasta or csv format.
|
|
191
|
+
auto : bool = True, optional
|
|
192
|
+
Set to true to automatically set algorithm parameters.
|
|
193
|
+
ep : float, optional
|
|
194
|
+
mafft parameter
|
|
195
|
+
op : float, optional
|
|
196
|
+
mafft parameter
|
|
197
|
+
|
|
198
|
+
Returns
|
|
199
|
+
-------
|
|
200
|
+
Job
|
|
201
|
+
Job details.
|
|
202
|
+
"""
|
|
203
|
+
endpoint = "v1/align/mafft"
|
|
204
|
+
|
|
205
|
+
files = {"file": sequence_file}
|
|
206
|
+
params: dict = {"auto": auto}
|
|
207
|
+
if ep is not None:
|
|
208
|
+
params["ep"] = ep
|
|
209
|
+
if op is not None:
|
|
210
|
+
params["op"] = op
|
|
211
|
+
|
|
212
|
+
response = session.post(endpoint, files=files, params=params)
|
|
213
|
+
return Job.model_validate(response.json())
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# TODO - document the `clustersize` and `iterations` parameters
|
|
217
|
+
def clustalo_post(
|
|
218
|
+
session: APISession,
|
|
219
|
+
sequence_file: BinaryIO,
|
|
220
|
+
clustersize: int | None = None,
|
|
221
|
+
iterations: int | None = None,
|
|
222
|
+
) -> Job:
|
|
223
|
+
"""
|
|
224
|
+
Align sequences using the `clustal omega` algorithm. Sequences can be provided as `fasta` or `csv` formats. If `csv`, the file must be headerless with either a single sequence column or name, sequence columns.
|
|
225
|
+
|
|
226
|
+
Leave a parameter as None to use system defaults.
|
|
227
|
+
|
|
228
|
+
Parameters
|
|
229
|
+
----------
|
|
230
|
+
session : APISession
|
|
231
|
+
sequence_file : BinaryIO
|
|
232
|
+
Sequences to align in fasta or csv format.
|
|
233
|
+
clustersize : int, optional
|
|
234
|
+
clustal omega parameter
|
|
235
|
+
iterations : int, optional
|
|
236
|
+
clustal omega parameter
|
|
237
|
+
|
|
238
|
+
Returns
|
|
239
|
+
-------
|
|
240
|
+
Job
|
|
241
|
+
Job details.
|
|
242
|
+
"""
|
|
243
|
+
endpoint = "v1/align/clustalo"
|
|
244
|
+
|
|
245
|
+
files = {"file": sequence_file}
|
|
246
|
+
params = {}
|
|
247
|
+
if clustersize is not None:
|
|
248
|
+
params["clustersize"] = clustersize
|
|
249
|
+
if iterations is not None:
|
|
250
|
+
params["iterations"] = iterations
|
|
251
|
+
|
|
252
|
+
response = session.post(endpoint, files=files, params=params)
|
|
253
|
+
return Job.model_validate(response.json())
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def abnumber_post(
|
|
257
|
+
session: APISession,
|
|
258
|
+
sequence_file: BinaryIO,
|
|
259
|
+
scheme: str = "imgt",
|
|
260
|
+
) -> Job:
|
|
261
|
+
"""
|
|
262
|
+
Align antibody using `AbNumber`. Sequences can be provided as `fasta` or `csv` formats. If `csv`, the file must be headerless with either a single sequence column or name, sequence columns.
|
|
263
|
+
|
|
264
|
+
The antibody numbering scheme can be specified from `imgt` (default), `chothia`, `kabat`, or `aho`.
|
|
265
|
+
|
|
266
|
+
Parameters
|
|
267
|
+
----------
|
|
268
|
+
session : APISession
|
|
269
|
+
sequence_file : BinaryIO
|
|
270
|
+
Sequences to align in fasta or csv format.
|
|
271
|
+
scheme : str = 'imgt'
|
|
272
|
+
Antibody numbering scheme. Can be one of 'imgt', 'chothia', 'kabat', or 'aho'
|
|
273
|
+
|
|
274
|
+
Returns
|
|
275
|
+
-------
|
|
276
|
+
Job
|
|
277
|
+
Job details.
|
|
278
|
+
"""
|
|
279
|
+
endpoint = "v1/align/abnumber"
|
|
280
|
+
|
|
281
|
+
valid_schemes = ["imgt", "chothia", "kabat", "aho"]
|
|
282
|
+
if scheme not in valid_schemes:
|
|
283
|
+
raise Exception(
|
|
284
|
+
f"Antibody numbering {scheme} not recognized. Must be one of {valid_schemes}."
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
files = {"file": sequence_file}
|
|
288
|
+
params = {"scheme": scheme}
|
|
289
|
+
|
|
290
|
+
response = session.post(endpoint, files=files, params=params)
|
|
291
|
+
return Job.model_validate(response.json())
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
# TODO - implement support for getting the antibody numbering from an `AbNumber` job
|
|
295
|
+
def antibody_schema_get(session: APISession, job_id: str):
|
|
296
|
+
"""
|
|
297
|
+
Return the antibody numbering for an `AbNumber` job.
|
|
298
|
+
"""
|
|
299
|
+
raise NotImplementedError()
|
|
300
|
+
|
|
301
|
+
|
|
200
302
|
def prompt_post(
|
|
201
303
|
session: APISession,
|
|
202
304
|
msa_id: str,
|
|
@@ -296,126 +398,3 @@ def prompt_post(
|
|
|
296
398
|
|
|
297
399
|
response = session.post(endpoint, params=params)
|
|
298
400
|
return Job.model_validate(response.json())
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
def upload_prompt_post(
|
|
302
|
-
session: APISession,
|
|
303
|
-
prompt_file: BinaryIO,
|
|
304
|
-
):
|
|
305
|
-
"""
|
|
306
|
-
Directly upload a prompt.
|
|
307
|
-
|
|
308
|
-
Bypass post_msa and prompt_post steps entirely. In this case PoET will use the prompt as is.
|
|
309
|
-
You can specify multiple prompts (one per replicate) with an `<END_PROMPT>\n` between CSVs.
|
|
310
|
-
|
|
311
|
-
Parameters
|
|
312
|
-
----------
|
|
313
|
-
session : APISession
|
|
314
|
-
An instance of APISession to manage interactions with the API.
|
|
315
|
-
prompt_file : BinaryIO
|
|
316
|
-
Binary I/O object representing the prompt file.
|
|
317
|
-
|
|
318
|
-
Raises
|
|
319
|
-
------
|
|
320
|
-
APIError
|
|
321
|
-
If there is an issue with the API request.
|
|
322
|
-
|
|
323
|
-
Returns
|
|
324
|
-
-------
|
|
325
|
-
Job
|
|
326
|
-
An object representing the status and results of the prompt job.
|
|
327
|
-
"""
|
|
328
|
-
|
|
329
|
-
endpoint = "v1/align/upload_prompt"
|
|
330
|
-
files = {"prompt_file": prompt_file}
|
|
331
|
-
try:
|
|
332
|
-
response = session.post(endpoint, files=files)
|
|
333
|
-
return Job.model_validate(response.json())
|
|
334
|
-
except Exception as exc:
|
|
335
|
-
raise APIError(f"Failed to upload prompt post: {exc}") from exc
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
def poet_score_post(
|
|
339
|
-
session: APISession, prompt_id: str, queries: list[bytes | str]
|
|
340
|
-
) -> Job:
|
|
341
|
-
"""
|
|
342
|
-
Submits a job to score sequences based on the given prompt.
|
|
343
|
-
|
|
344
|
-
Parameters
|
|
345
|
-
----------
|
|
346
|
-
session : APISession
|
|
347
|
-
An instance of APISession to manage interactions with the API.
|
|
348
|
-
prompt_id : str
|
|
349
|
-
The ID of the prompt.
|
|
350
|
-
queries : List[str]
|
|
351
|
-
A list of query sequences to be scored.
|
|
352
|
-
|
|
353
|
-
Raises
|
|
354
|
-
------
|
|
355
|
-
APIError
|
|
356
|
-
If there is an issue with the API request.
|
|
357
|
-
|
|
358
|
-
Returns
|
|
359
|
-
-------
|
|
360
|
-
Job
|
|
361
|
-
An object representing the status and results of the scoring job.
|
|
362
|
-
"""
|
|
363
|
-
endpoint = "v1/poet/score"
|
|
364
|
-
|
|
365
|
-
if len(queries) == 0:
|
|
366
|
-
raise MissingParameterError("Must include queries for scoring!")
|
|
367
|
-
if not prompt_id:
|
|
368
|
-
raise MissingParameterError("Must include prompt_id in request!")
|
|
369
|
-
|
|
370
|
-
queries_bytes = [i.encode() if isinstance(i, str) else i for i in queries]
|
|
371
|
-
try:
|
|
372
|
-
variant_file = io.BytesIO(b"\n".join(queries_bytes))
|
|
373
|
-
params = {"prompt_id": prompt_id}
|
|
374
|
-
response = session.post(
|
|
375
|
-
endpoint, files={"variant_file": variant_file}, params=params
|
|
376
|
-
)
|
|
377
|
-
return Job.model_validate(response.json())
|
|
378
|
-
except Exception as exc:
|
|
379
|
-
raise APIError(f"Failed to post poet score: {exc}") from exc
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
def poet_score_get(
|
|
383
|
-
session: APISession, job_id, page_size=config.POET_PAGE_SIZE, page_offset=0
|
|
384
|
-
) -> Job:
|
|
385
|
-
"""
|
|
386
|
-
Fetch a page of results from a PoET score job.
|
|
387
|
-
|
|
388
|
-
Parameters
|
|
389
|
-
----------
|
|
390
|
-
session : APISession
|
|
391
|
-
An instance of APISession to manage interactions with the API.
|
|
392
|
-
job_id : str
|
|
393
|
-
The ID of the PoET scoring job to fetch results from.
|
|
394
|
-
page_size : int, optional
|
|
395
|
-
The number of results to fetch in a single page. Defaults to config.POET_PAGE_SIZE.
|
|
396
|
-
page_offset : int, optional
|
|
397
|
-
The offset (number of results) to start fetching results from. Defaults to 0.
|
|
398
|
-
|
|
399
|
-
Raises
|
|
400
|
-
------
|
|
401
|
-
APIError
|
|
402
|
-
If the provided page size is larger than the maximum allowed page size.
|
|
403
|
-
|
|
404
|
-
Returns
|
|
405
|
-
-------
|
|
406
|
-
Job
|
|
407
|
-
An object representing the PoET scoring job, including its current status and results (if any).
|
|
408
|
-
"""
|
|
409
|
-
endpoint = "v1/poet/score"
|
|
410
|
-
|
|
411
|
-
if page_size > config.POET_MAX_PAGE_SIZE:
|
|
412
|
-
raise APIError(
|
|
413
|
-
f"Page size must be less than the max for PoET: {config.POET_MAX_PAGE_SIZE}"
|
|
414
|
-
)
|
|
415
|
-
|
|
416
|
-
response = session.get(
|
|
417
|
-
endpoint,
|
|
418
|
-
params={"job_id": job_id, "page_size": page_size, "page_offset": page_offset},
|
|
419
|
-
)
|
|
420
|
-
|
|
421
|
-
return Job.model_validate(response.json())
|
|
@@ -3,6 +3,8 @@ import random
|
|
|
3
3
|
from typing import Iterator
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
|
+
from pydantic import TypeAdapter
|
|
7
|
+
|
|
6
8
|
from openprotein.base import APISession
|
|
7
9
|
from openprotein.csv import csv_stream
|
|
8
10
|
from openprotein.errors import InvalidParameterError
|
|
@@ -16,7 +18,6 @@ from openprotein.schemas import (
|
|
|
16
18
|
ScoreJob,
|
|
17
19
|
ScoreSingleSiteJob,
|
|
18
20
|
)
|
|
19
|
-
from pydantic import TypeAdapter
|
|
20
21
|
|
|
21
22
|
PATH_PREFIX = "v1/embeddings"
|
|
22
23
|
|
|
@@ -161,7 +162,7 @@ def request_post(
|
|
|
161
162
|
model_id: str,
|
|
162
163
|
sequences: list[bytes] | list[str],
|
|
163
164
|
reduction: str | None = "MEAN",
|
|
164
|
-
|
|
165
|
+
**kwargs,
|
|
165
166
|
) -> EmbeddingsJob:
|
|
166
167
|
"""
|
|
167
168
|
POST a request for embeddings from the given model ID. Returns a Job object referring to this request
|
|
@@ -177,8 +178,8 @@ def request_post(
|
|
|
177
178
|
sequences to request results for
|
|
178
179
|
reduction : str | None
|
|
179
180
|
reduction to apply to the embeddings. options are None, "MEAN", or "SUM". defaul: "MEAN"
|
|
180
|
-
kwargs:
|
|
181
|
-
|
|
181
|
+
**kwargs:
|
|
182
|
+
Optional parameters for models, e.g. prompt_id for PoET
|
|
182
183
|
|
|
183
184
|
Returns
|
|
184
185
|
-------
|
|
@@ -190,10 +191,16 @@ def request_post(
|
|
|
190
191
|
body: dict = {
|
|
191
192
|
"sequences": sequences_unicode,
|
|
192
193
|
}
|
|
193
|
-
if prompt_id is not None:
|
|
194
|
-
body["prompt_id"] = prompt_id
|
|
195
194
|
if reduction is not None:
|
|
196
195
|
body["reduction"] = reduction
|
|
196
|
+
if kwargs.get("prompt_id"):
|
|
197
|
+
body["prompt_id"] = kwargs["prompt_id"]
|
|
198
|
+
if kwargs.get("query_id"):
|
|
199
|
+
body["query_id"] = kwargs["query_id"]
|
|
200
|
+
if "use_query_structure_in_decoder" in kwargs:
|
|
201
|
+
body["use_query_structure_in_decoder"] = kwargs[
|
|
202
|
+
"use_query_structure_in_decoder"
|
|
203
|
+
]
|
|
197
204
|
response = session.post(endpoint, json=body)
|
|
198
205
|
return EmbeddingsJob.model_validate(response.json())
|
|
199
206
|
|
|
@@ -202,7 +209,7 @@ def request_logits_post(
|
|
|
202
209
|
session: APISession,
|
|
203
210
|
model_id: str,
|
|
204
211
|
sequences: list[bytes] | list[str],
|
|
205
|
-
|
|
212
|
+
**kwargs,
|
|
206
213
|
) -> LogitsJob:
|
|
207
214
|
"""
|
|
208
215
|
POST a request for logits from the given model ID. Returns a Job object referring to this request
|
|
@@ -216,6 +223,8 @@ def request_logits_post(
|
|
|
216
223
|
model ID to request results from
|
|
217
224
|
sequences : List[bytes]
|
|
218
225
|
sequences to request results for
|
|
226
|
+
**kwargs:
|
|
227
|
+
Optional parameters for models, e.g. prompt_id for PoET
|
|
219
228
|
|
|
220
229
|
Returns
|
|
221
230
|
-------
|
|
@@ -227,8 +236,14 @@ def request_logits_post(
|
|
|
227
236
|
body: dict = {
|
|
228
237
|
"sequences": sequences_unicode,
|
|
229
238
|
}
|
|
230
|
-
if prompt_id
|
|
231
|
-
body["prompt_id"] = prompt_id
|
|
239
|
+
if kwargs.get("prompt_id"):
|
|
240
|
+
body["prompt_id"] = kwargs["prompt_id"]
|
|
241
|
+
if kwargs.get("query_id"):
|
|
242
|
+
body["query_id"] = kwargs["query_id"]
|
|
243
|
+
if "use_query_structure_in_decoder" in kwargs:
|
|
244
|
+
body["use_query_structure_in_decoder"] = kwargs[
|
|
245
|
+
"use_query_structure_in_decoder"
|
|
246
|
+
]
|
|
232
247
|
response = session.post(endpoint, json=body)
|
|
233
248
|
return LogitsJob.model_validate(response.json())
|
|
234
249
|
|
|
@@ -237,7 +252,7 @@ def request_attn_post(
|
|
|
237
252
|
session: APISession,
|
|
238
253
|
model_id: str,
|
|
239
254
|
sequences: list[bytes] | list[str],
|
|
240
|
-
|
|
255
|
+
**kwargs,
|
|
241
256
|
) -> AttnJob:
|
|
242
257
|
"""
|
|
243
258
|
POST a request for attention embeddings from the given model ID. \
|
|
@@ -252,6 +267,8 @@ def request_attn_post(
|
|
|
252
267
|
model ID to request results from
|
|
253
268
|
sequences : List[bytes]
|
|
254
269
|
sequences to request results for
|
|
270
|
+
**kwargs:
|
|
271
|
+
Optional parameters for models, e.g. prompt_id for PoET
|
|
255
272
|
|
|
256
273
|
Returns
|
|
257
274
|
-------
|
|
@@ -263,8 +280,14 @@ def request_attn_post(
|
|
|
263
280
|
body: dict = {
|
|
264
281
|
"sequences": sequences_unicode,
|
|
265
282
|
}
|
|
266
|
-
if prompt_id
|
|
267
|
-
body["prompt_id"] = prompt_id
|
|
283
|
+
if kwargs.get("prompt_id"):
|
|
284
|
+
body["prompt_id"] = kwargs["prompt_id"]
|
|
285
|
+
if kwargs.get("query_id"):
|
|
286
|
+
body["query_id"] = kwargs["query_id"]
|
|
287
|
+
if "use_query_structure_in_decoder" in kwargs:
|
|
288
|
+
body["use_query_structure_in_decoder"] = kwargs[
|
|
289
|
+
"use_query_structure_in_decoder"
|
|
290
|
+
]
|
|
268
291
|
response = session.post(endpoint, json=body)
|
|
269
292
|
return AttnJob.model_validate(response.json())
|
|
270
293
|
|
|
@@ -273,7 +296,7 @@ def request_score_post(
|
|
|
273
296
|
session: APISession,
|
|
274
297
|
model_id: str,
|
|
275
298
|
sequences: list[bytes] | list[str],
|
|
276
|
-
|
|
299
|
+
**kwargs,
|
|
277
300
|
) -> ScoreJob:
|
|
278
301
|
"""
|
|
279
302
|
POST a request for sequence scoring for the given model ID. \
|
|
@@ -294,13 +317,18 @@ def request_score_post(
|
|
|
294
317
|
job : Job
|
|
295
318
|
"""
|
|
296
319
|
endpoint = PATH_PREFIX + f"/models/{model_id}/score"
|
|
297
|
-
|
|
298
320
|
sequences_unicode = [(s if isinstance(s, str) else s.decode()) for s in sequences]
|
|
299
321
|
body: dict = {
|
|
300
322
|
"sequences": sequences_unicode,
|
|
301
323
|
}
|
|
302
|
-
if prompt_id
|
|
303
|
-
body["prompt_id"] = prompt_id
|
|
324
|
+
if kwargs.get("prompt_id"):
|
|
325
|
+
body["prompt_id"] = kwargs["prompt_id"]
|
|
326
|
+
if kwargs.get("query_id"):
|
|
327
|
+
body["query_id"] = kwargs["query_id"]
|
|
328
|
+
if "use_query_structure_in_decoder" in kwargs:
|
|
329
|
+
body["use_query_structure_in_decoder"] = kwargs[
|
|
330
|
+
"use_query_structure_in_decoder"
|
|
331
|
+
]
|
|
304
332
|
response = session.post(endpoint, json=body)
|
|
305
333
|
return ScoreJob.model_validate(response.json())
|
|
306
334
|
|
|
@@ -309,7 +337,7 @@ def request_score_single_site_post(
|
|
|
309
337
|
session: APISession,
|
|
310
338
|
model_id: str,
|
|
311
339
|
base_sequence: bytes | str,
|
|
312
|
-
|
|
340
|
+
**kwargs,
|
|
313
341
|
) -> ScoreSingleSiteJob:
|
|
314
342
|
"""
|
|
315
343
|
POST a request for single site mutation scoring for the given model ID. \
|
|
@@ -324,6 +352,8 @@ def request_score_single_site_post(
|
|
|
324
352
|
model ID to request results from
|
|
325
353
|
sequences : List[bytes]
|
|
326
354
|
sequences to request results for
|
|
355
|
+
**kwargs:
|
|
356
|
+
Optional parameters for models, e.g. prompt_id for PoET
|
|
327
357
|
|
|
328
358
|
Returns
|
|
329
359
|
-------
|
|
@@ -338,8 +368,14 @@ def request_score_single_site_post(
|
|
|
338
368
|
else base_sequence
|
|
339
369
|
),
|
|
340
370
|
}
|
|
341
|
-
if prompt_id
|
|
342
|
-
body["prompt_id"] = prompt_id
|
|
371
|
+
if kwargs.get("prompt_id"):
|
|
372
|
+
body["prompt_id"] = kwargs["prompt_id"]
|
|
373
|
+
if kwargs.get("query_id"):
|
|
374
|
+
body["query_id"] = kwargs["query_id"]
|
|
375
|
+
if "use_query_structure_in_decoder" in kwargs:
|
|
376
|
+
body["use_query_structure_in_decoder"] = kwargs[
|
|
377
|
+
"use_query_structure_in_decoder"
|
|
378
|
+
]
|
|
343
379
|
response = session.post(endpoint, json=body)
|
|
344
380
|
return ScoreSingleSiteJob.model_validate(response.json())
|
|
345
381
|
|
|
@@ -353,7 +389,7 @@ def request_generate_post(
|
|
|
353
389
|
topp: float | None = None,
|
|
354
390
|
max_length: int = 1000,
|
|
355
391
|
random_seed: int | None = None,
|
|
356
|
-
|
|
392
|
+
**kwargs,
|
|
357
393
|
) -> GenerateJob:
|
|
358
394
|
"""
|
|
359
395
|
POST a request for sequence generation for the given model ID. \
|
|
@@ -366,6 +402,8 @@ def request_generate_post(
|
|
|
366
402
|
Session object for API communication.
|
|
367
403
|
model_id : str
|
|
368
404
|
model ID to request results from
|
|
405
|
+
**kwargs:
|
|
406
|
+
Optional parameters for models, e.g. prompt_id for PoET
|
|
369
407
|
|
|
370
408
|
Returns
|
|
371
409
|
-------
|
|
@@ -396,7 +434,13 @@ def request_generate_post(
|
|
|
396
434
|
body["topp"] = topp
|
|
397
435
|
if random_seed is not None:
|
|
398
436
|
body["seed"] = random_seed
|
|
399
|
-
if prompt_id
|
|
400
|
-
body["prompt_id"] = prompt_id
|
|
437
|
+
if kwargs.get("prompt_id"):
|
|
438
|
+
body["prompt_id"] = kwargs["prompt_id"]
|
|
439
|
+
if kwargs.get("query_id"):
|
|
440
|
+
body["query_id"] = kwargs["query_id"]
|
|
441
|
+
if "use_query_structure_in_decoder" in kwargs:
|
|
442
|
+
body["use_query_structure_in_decoder"] = kwargs[
|
|
443
|
+
"use_query_structure_in_decoder"
|
|
444
|
+
]
|
|
401
445
|
response = session.post(endpoint, json=body)
|
|
402
446
|
return GenerateJob.model_validate(response.json())
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
|
|
1
3
|
from openprotein.api.embedding import ModelMetadata
|
|
2
4
|
from openprotein.base import APISession
|
|
3
5
|
from openprotein.schemas import FoldJob
|
|
@@ -78,7 +80,7 @@ def fold_get_sequence_result(
|
|
|
78
80
|
|
|
79
81
|
def fold_models_esmfold_post(
|
|
80
82
|
session: APISession,
|
|
81
|
-
sequences:
|
|
83
|
+
sequences: Sequence[bytes | str],
|
|
82
84
|
num_recycles: int | None = None,
|
|
83
85
|
) -> FoldJob:
|
|
84
86
|
"""
|
|
@@ -89,7 +91,7 @@ def fold_models_esmfold_post(
|
|
|
89
91
|
----------
|
|
90
92
|
session : APISession
|
|
91
93
|
Session object for API communication.
|
|
92
|
-
sequences :
|
|
94
|
+
sequences : Sequence[bytes | str]
|
|
93
95
|
sequences to request results for
|
|
94
96
|
num_recycles : Optional[int]
|
|
95
97
|
number of recycles for structure prediction
|
|
@@ -100,7 +102,7 @@ def fold_models_esmfold_post(
|
|
|
100
102
|
"""
|
|
101
103
|
endpoint = PATH_PREFIX + "/models/esmfold"
|
|
102
104
|
|
|
103
|
-
sequences_unicode = [
|
|
105
|
+
sequences_unicode = [s if isinstance(s, str) else s.decode() for s in sequences]
|
|
104
106
|
body: dict = {
|
|
105
107
|
"sequences": sequences_unicode,
|
|
106
108
|
}
|
|
@@ -113,6 +113,17 @@ def predictor_fit_gp_post(
|
|
|
113
113
|
return TrainJob.model_validate(response.json())
|
|
114
114
|
|
|
115
115
|
|
|
116
|
+
def predictor_ensemble(session: APISession, predictor_ids: list[str]):
|
|
117
|
+
endpoint = PATH_PREFIX + f"/ensemble"
|
|
118
|
+
|
|
119
|
+
body = {
|
|
120
|
+
"model_ids": predictor_ids,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
response = session.post(endpoint, json=body)
|
|
124
|
+
return TypeAdapter(PredictorMetadata).validate_python(response.json())
|
|
125
|
+
|
|
126
|
+
|
|
116
127
|
def predictor_delete(session: APISession, predictor_id: str):
|
|
117
128
|
endpoint = PATH_PREFIX + f"/{predictor_id}"
|
|
118
129
|
response = session.delete(endpoint)
|