openprotein-python 0.5.4__tar.gz → 0.6.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.
Files changed (102) hide show
  1. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/PKG-INFO +3 -1
  2. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/__init__.py +67 -34
  3. openprotein_python-0.6.0/openprotein/align/__init__.py +2 -0
  4. openprotein_python-0.6.0/openprotein/api/__init__.py +9 -0
  5. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/align.py +6 -6
  6. openprotein_python-0.6.0/openprotein/api/deprecated/__init__.py +5 -0
  7. {openprotein_python-0.5.4/openprotein/api → openprotein_python-0.6.0/openprotein/api/deprecated}/design.py +1 -1
  8. {openprotein_python-0.5.4/openprotein/api → openprotein_python-0.6.0/openprotein/api/deprecated}/predict.py +4 -1
  9. {openprotein_python-0.5.4/openprotein/api → openprotein_python-0.6.0/openprotein/api/deprecated}/train.py +14 -12
  10. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/designer.py +3 -0
  11. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/predictor.py +7 -1
  12. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/svd.py +6 -3
  13. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/umap.py +6 -3
  14. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/__init__.py +2 -4
  15. openprotein_python-0.6.0/openprotein/app/deprecated.py +8 -0
  16. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/__init__.py +5 -6
  17. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/align/base.py +2 -2
  18. openprotein_python-0.6.0/openprotein/app/models/deprecated/__init__.py +13 -0
  19. {openprotein_python-0.5.4/openprotein/app/models → openprotein_python-0.6.0/openprotein/app/models/deprecated}/design.py +7 -3
  20. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/deprecated/poet.py +27 -7
  21. {openprotein_python-0.5.4/openprotein/app/models → openprotein_python-0.6.0/openprotein/app/models/deprecated}/predict.py +8 -4
  22. {openprotein_python-0.5.4/openprotein/app/models → openprotein_python-0.6.0/openprotein/app/models/deprecated}/train.py +10 -6
  23. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/designer.py +26 -4
  24. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/__init__.py +5 -1
  25. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/base.py +7 -7
  26. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/future.py +13 -5
  27. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/poet.py +85 -59
  28. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/fold/future.py +3 -0
  29. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/futures.py +23 -10
  30. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/predictor/predictor.py +41 -5
  31. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/svd.py +4 -4
  32. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/umap.py +4 -4
  33. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/__init__.py +3 -5
  34. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/align.py +4 -6
  35. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/assaydata.py +1 -9
  36. openprotein_python-0.6.0/openprotein/app/services/deprecated/__init__.py +9 -0
  37. {openprotein_python-0.5.4/openprotein/app/services → openprotein_python-0.6.0/openprotein/app/services/deprecated}/design.py +4 -4
  38. {openprotein_python-0.5.4/openprotein/app/services → openprotein_python-0.6.0/openprotein/app/services/deprecated}/predict.py +12 -5
  39. {openprotein_python-0.5.4/openprotein/app/services → openprotein_python-0.6.0/openprotein/app/services/deprecated}/train.py +15 -10
  40. openprotein_python-0.6.0/openprotein/app/services/designer.py +107 -0
  41. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/embeddings.py +14 -7
  42. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/predictor.py +1 -1
  43. openprotein_python-0.6.0/openprotein/design/__init__.py +9 -0
  44. openprotein_python-0.6.0/openprotein/embeddings/__init__.py +17 -0
  45. openprotein_python-0.6.0/openprotein/fold/__init__.py +2 -0
  46. openprotein_python-0.6.0/openprotein/jobs/__init__.py +3 -0
  47. openprotein_python-0.6.0/openprotein/predictor/__init__.py +2 -0
  48. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/__init__.py +3 -14
  49. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/align.py +1 -1
  50. openprotein_python-0.6.0/openprotein/schemas/deprecated/__init__.py +21 -0
  51. openprotein_python-0.6.0/openprotein/schemas/deprecated/design.py +173 -0
  52. {openprotein_python-0.5.4/openprotein/schemas → openprotein_python-0.6.0/openprotein/schemas/deprecated}/predict.py +1 -1
  53. {openprotein_python-0.5.4/openprotein/schemas → openprotein_python-0.6.0/openprotein/schemas/deprecated}/train.py +1 -1
  54. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/design.py +2 -178
  55. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/predictor.py +6 -0
  56. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/pyproject.toml +2 -2
  57. openprotein_python-0.5.4/openprotein/api/__init__.py +0 -1
  58. openprotein_python-0.5.4/openprotein/api/deprecated/__init__.py +0 -0
  59. openprotein_python-0.5.4/openprotein/app/models/deprecated/__init__.py +0 -0
  60. openprotein_python-0.5.4/openprotein/app/services/designer.py +0 -73
  61. openprotein_python-0.5.4/openprotein/schemas/deprecated/__init__.py +0 -0
  62. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/.gitignore +0 -0
  63. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/LICENSE.txt +0 -0
  64. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/README.md +0 -0
  65. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/_version.py +0 -0
  66. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/assaydata.py +0 -0
  67. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/deprecated/poet.py +0 -0
  68. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/embedding.py +0 -0
  69. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/fold.py +0 -0
  70. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/api/job.py +0 -0
  71. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/align/__init__.py +0 -0
  72. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/align/msa.py +0 -0
  73. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/align/prompt.py +0 -0
  74. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/assaydata.py +0 -0
  75. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/esm.py +0 -0
  76. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/openprotein.py +0 -0
  77. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/embeddings/test.py +0 -0
  78. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/fold/__init__.py +0 -0
  79. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/fold/alphafold2.py +0 -0
  80. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/fold/base.py +0 -0
  81. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/fold/esmfold.py +0 -0
  82. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/predictor/__init__.py +0 -0
  83. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/predictor/predict.py +0 -0
  84. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/models/predictor/validate.py +0 -0
  85. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/fold.py +0 -0
  86. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/job.py +0 -0
  87. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/svd.py +0 -0
  88. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/app/services/umap.py +0 -0
  89. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/base.py +0 -0
  90. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/config.py +0 -0
  91. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/csv.py +0 -0
  92. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/errors.py +0 -0
  93. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/fasta.py +0 -0
  94. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/assaydata.py +0 -0
  95. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/deprecated/poet.py +0 -0
  96. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/designer.py +0 -0
  97. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/embeddings.py +0 -0
  98. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/features.py +0 -0
  99. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/fold.py +0 -0
  100. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/job.py +0 -0
  101. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/svd.py +0 -0
  102. {openprotein_python-0.5.4 → openprotein_python-0.6.0}/openprotein/schemas/umap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openprotein_python
3
- Version: 0.5.4
3
+ Version: 0.6.0
4
4
  Summary: OpenProtein Python interface.
5
5
  Author-email: Mark Gee <markgee@ne47.bio>
6
6
  License: MIT
@@ -13,12 +13,14 @@ Requires-Dist: pydantic<3,>=2.5
13
13
  Requires-Dist: requests<3,>=2.32.3
14
14
  Requires-Dist: tqdm<5,>=4.66.5
15
15
  Provides-Extra: dev
16
+ Requires-Dist: editables<0.6,>=0.5; extra == 'dev'
16
17
  Requires-Dist: hatchling>=1.26.1; extra == 'dev'
17
18
  Requires-Dist: ipykernel<7,>=6.29.5; extra == 'dev'
18
19
  Requires-Dist: matplotlib<4,>=3.9.2; extra == 'dev'
19
20
  Requires-Dist: pandas-stubs<3,>=2.1.4.240909; extra == 'dev'
20
21
  Requires-Dist: pytest<9,>=8.3.3; extra == 'dev'
21
22
  Requires-Dist: scipy<2,>=1.14.1; extra == 'dev'
23
+ Requires-Dist: seaborn<0.14,>=0.13.2; extra == 'dev'
22
24
  Description-Content-Type: text/markdown
23
25
 
24
26
  [![PyPI version](https://badge.fury.io/py/openprotein-python.svg)](https://pypi.org/project/openprotein-python/)
@@ -6,23 +6,27 @@ A pythonic interface for interacting with our cutting-edge protein engineering p
6
6
  isort:skip_file
7
7
  """
8
8
 
9
+ from typing import TYPE_CHECKING
10
+ import warnings
11
+
9
12
  from openprotein._version import __version__
10
13
  from openprotein.app import (
11
- AssayDataAPI,
14
+ DataAPI,
12
15
  JobsAPI,
13
- TrainingAPI,
14
- DesignAPI,
15
16
  AlignAPI,
16
17
  EmbeddingsAPI,
17
18
  FoldAPI,
18
19
  SVDAPI,
19
20
  UMAPAPI,
20
21
  PredictorAPI,
21
- DesignerAPI,
22
+ DesignAPI,
22
23
  )
23
24
  from openprotein.app.models import Future
24
25
  from openprotein.base import APISession
25
26
 
27
+ if TYPE_CHECKING:
28
+ from openprotein.app.deprecated import TrainingAPI, DesignAPI
29
+
26
30
 
27
31
  class OpenProtein(APISession):
28
32
  """
@@ -31,15 +35,14 @@ class OpenProtein(APISession):
31
35
 
32
36
  _data = None
33
37
  _jobs = None
34
- _train = None
35
- _design = None
36
38
  _align = None
37
- _embedding = None
39
+ _embeddings = None
38
40
  _svd = None
39
41
  _umap = None
40
42
  _fold = None
41
43
  _predictor = None
42
44
  _designer = None
45
+ _deprecated = None
43
46
 
44
47
  def wait(self, future: Future, *args, **kwargs):
45
48
  return future.wait(*args, **kwargs)
@@ -50,14 +53,20 @@ class OpenProtein(APISession):
50
53
  return self.jobs.get(job_id=job_id)
51
54
 
52
55
  @property
53
- def data(self) -> AssayDataAPI:
56
+ def data(self) -> DataAPI:
54
57
  """
55
58
  The data submodule gives access to functionality for uploading and accessing user data.
56
59
  """
57
60
  if self._data is None:
58
- self._data = AssayDataAPI(self)
61
+ self._data = DataAPI(self)
59
62
  return self._data
60
63
 
64
+ @property
65
+ def train(self):
66
+ raise AttributeError(
67
+ "Access to deprecated train module is under the deprecated property, i.e. session.deprecated.train"
68
+ )
69
+
61
70
  @property
62
71
  def jobs(self) -> JobsAPI:
63
72
  """
@@ -67,24 +76,6 @@ class OpenProtein(APISession):
67
76
  self._jobs = JobsAPI(self)
68
77
  return self._jobs
69
78
 
70
- @property
71
- def train(self) -> TrainingAPI:
72
- """
73
- The train submodule gives access to functionality for training and validating ML models.
74
- """
75
- if self._train is None:
76
- self._train = TrainingAPI(self)
77
- return self._train
78
-
79
- @property
80
- def design(self) -> DesignAPI:
81
- """
82
- The design submodule gives access to functionality for designing new sequences using models from train.
83
- """
84
- if self._design is None:
85
- self._design = DesignAPI(self)
86
- return self._design
87
-
88
79
  @property
89
80
  def align(self) -> AlignAPI:
90
81
  """
@@ -99,9 +90,11 @@ class OpenProtein(APISession):
99
90
  """
100
91
  The embedding submodule gives access to protein embedding models and their inference endpoints.
101
92
  """
102
- if self._embedding is None:
103
- self._embedding = EmbeddingsAPI(self)
104
- return self._embedding
93
+ if self._embeddings is None:
94
+ self._embeddings = EmbeddingsAPI(self)
95
+ return self._embeddings
96
+
97
+ embeddings = embedding
105
98
 
106
99
  @property
107
100
  def svd(self) -> SVDAPI:
@@ -109,7 +102,7 @@ class OpenProtein(APISession):
109
102
  The embedding submodule gives access to protein embedding models and their inference endpoints.
110
103
  """
111
104
  if self._svd is None:
112
- self._svd = SVDAPI(self, self.embedding)
105
+ self._svd = SVDAPI(self, self.embeddings)
113
106
  return self._svd
114
107
 
115
108
  @property
@@ -127,16 +120,16 @@ class OpenProtein(APISession):
127
120
  The predictor submodule gives access to training and predicting with predictors built on top of embeddings.
128
121
  """
129
122
  if self._predictor is None:
130
- self._predictor = PredictorAPI(self, self.embedding, self.svd)
123
+ self._predictor = PredictorAPI(self, self.embeddings, self.svd)
131
124
  return self._predictor
132
125
 
133
126
  @property
134
- def designer(self) -> DesignerAPI:
127
+ def design(self) -> DesignAPI:
135
128
  """
136
129
  The designer submodule gives access to functionality for designing new sequences using models from predictor train.
137
130
  """
138
131
  if self._designer is None:
139
- self._designer = DesignerAPI(self)
132
+ self._designer = DesignAPI(self)
140
133
  return self._designer
141
134
 
142
135
  @property
@@ -148,5 +141,45 @@ class OpenProtein(APISession):
148
141
  self._fold = FoldAPI(self)
149
142
  return self._fold
150
143
 
144
+ @property
145
+ def deprecated(self) -> "Deprecated":
146
+
147
+ if self._deprecated is None:
148
+ warnings.warn(
149
+ "Support for deprecated APIs will be dropped in the future! Read the documentation to migrate to the updated APIs."
150
+ )
151
+ self._deprecated = self.Deprecated(self)
152
+ return self._deprecated
153
+
154
+ class Deprecated:
155
+
156
+ _train = None
157
+ _design = None
158
+
159
+ def __init__(self, session: APISession):
160
+ self.session = session
161
+
162
+ @property
163
+ def train(self) -> "TrainingAPI":
164
+ """
165
+ The train submodule gives access to functionality for training and validating ML models.
166
+ """
167
+ from openprotein.app.deprecated import TrainingAPI
168
+
169
+ if self._train is None:
170
+ self._train = TrainingAPI(self.session)
171
+ return self._train
172
+
173
+ @property
174
+ def design(self) -> "DesignAPI":
175
+ """
176
+ The design submodule gives access to functionality for designing new sequences using models from train.
177
+ """
178
+ from openprotein.app.deprecated import DesignAPI
179
+
180
+ if self._design is None:
181
+ self._design = DesignAPI(self.session)
182
+ return self._design
183
+
151
184
 
152
185
  connect = OpenProtein
@@ -0,0 +1,2 @@
1
+ from openprotein.app import AlignAPI
2
+ from openprotein.app.models import MSAFuture, PromptFuture
@@ -0,0 +1,9 @@
1
+ from . import align, assaydata, embedding, fold, predictor
2
+
3
+ __all__ = [
4
+ "align",
5
+ "assaydata",
6
+ "embedding",
7
+ "fold",
8
+ "predictor",
9
+ ]
@@ -7,13 +7,13 @@ import requests
7
7
  from openprotein.base import APISession
8
8
  from openprotein.csv import csv_stream
9
9
  from openprotein.errors import APIError, InvalidParameterError, MissingParameterError
10
- from openprotein.schemas import Job, MSASamplingMethod, PoetInputType
10
+ from openprotein.schemas import AlignType, Job, MSASamplingMethod
11
11
 
12
12
 
13
13
  def get_align_job_inputs(
14
14
  session: APISession,
15
15
  job_id: str,
16
- input_type: PoetInputType,
16
+ input_type: AlignType,
17
17
  prompt_index: int | None = None,
18
18
  ) -> requests.Response:
19
19
  """
@@ -52,7 +52,7 @@ def get_align_job_inputs(
52
52
  def get_input(
53
53
  session: APISession,
54
54
  job: Job,
55
- input_type: PoetInputType,
55
+ input_type: AlignType,
56
56
  prompt_index: int | None = None,
57
57
  ) -> Iterator[list[str]]:
58
58
  """
@@ -104,7 +104,7 @@ def get_prompt(
104
104
  return get_input(
105
105
  session=session,
106
106
  job=job,
107
- input_type=PoetInputType.PROMPT,
107
+ input_type=AlignType.PROMPT,
108
108
  prompt_index=prompt_index,
109
109
  )
110
110
 
@@ -125,7 +125,7 @@ def get_seed(session: APISession, job: Job) -> Iterator[list[str]]:
125
125
  Iterator[list[str]]
126
126
  A CSV reader for the seed sequence.
127
127
  """
128
- return get_input(session=session, job=job, input_type=PoetInputType.INPUT)
128
+ return get_input(session=session, job=job, input_type=AlignType.INPUT)
129
129
 
130
130
 
131
131
  def get_msa(session: APISession, job: Job) -> Iterator[list[str]]:
@@ -144,7 +144,7 @@ def get_msa(session: APISession, job: Job) -> Iterator[list[str]]:
144
144
  Iterator[list[str]]
145
145
  A CSV reader for the MSA data.
146
146
  """
147
- return get_input(session=session, job=job, input_type=PoetInputType.MSA)
147
+ return get_input(session=session, job=job, input_type=AlignType.MSA)
148
148
 
149
149
 
150
150
  def msa_post(
@@ -0,0 +1,5 @@
1
+ """Deprecated OpenProtein APIs."""
2
+
3
+ from . import design, predict, train
4
+
5
+ __all__ = ["design", "predict", "train"]
@@ -1,5 +1,5 @@
1
1
  from openprotein.base import APISession
2
- from openprotein.schemas import (
2
+ from openprotein.schemas.deprecated import (
3
3
  WorkflowDesign,
4
4
  WorkflowDesignJob,
5
5
  WorkflowDesignJobCreate,
@@ -1,6 +1,9 @@
1
1
  from openprotein.base import APISession
2
2
  from openprotein.errors import InvalidParameterError
3
- from openprotein.schemas import WorkflowPredictJob, WorkflowPredictSingleSiteJob
3
+ from openprotein.schemas.deprecated import (
4
+ WorkflowPredictJob,
5
+ WorkflowPredictSingleSiteJob,
6
+ )
4
7
  from pydantic import TypeAdapter
5
8
 
6
9
 
@@ -1,6 +1,6 @@
1
1
  from openprotein.base import APISession
2
2
  from openprotein.errors import InvalidJob
3
- from openprotein.schemas import Job, WorkflowCVJob, WorkflowTrainJob
3
+ from openprotein.schemas.deprecated import WorkflowCVJob, WorkflowTrainJob
4
4
 
5
5
 
6
6
  def list_models(session: APISession, job_id: str) -> list:
@@ -24,7 +24,9 @@ def list_models(session: APISession, job_id: str) -> list:
24
24
  return response.json()
25
25
 
26
26
 
27
- def crossvalidate(session: APISession, train_job_id: str, n_splits: int = 5) -> Job:
27
+ def crossvalidate(
28
+ session: APISession, train_job_id: str, n_splits: int = 5
29
+ ) -> WorkflowCVJob:
28
30
  """
29
31
  Submit a cross-validation job.
30
32
 
@@ -34,13 +36,13 @@ def crossvalidate(session: APISession, train_job_id: str, n_splits: int = 5) ->
34
36
  n_splits (int, optional): N of CV splits. Defaults to 5.
35
37
 
36
38
  Returns:
37
- Job:
39
+ CVJob: A crossvalidate job.
38
40
  """
39
41
  endpoint = "v1/workflow/crossvalidate"
40
42
  response = session.post(
41
43
  endpoint, json={"train_job_id": train_job_id, "n_splits": n_splits}
42
44
  )
43
- return Job.model_validate(response.json())
45
+ return WorkflowCVJob.model_validate(response.json())
44
46
 
45
47
 
46
48
  def get_crossvalidation(
@@ -57,7 +59,7 @@ def get_crossvalidation(
57
59
  job_id (str): Job id
58
60
 
59
61
  Returns:
60
- _type_: _description_
62
+ CVJob: A crossvalidate job.
61
63
  """
62
64
  endpoint = f"v1/workflow/crossvalidate/{job_id}"
63
65
  params = {"page_size": page_size, "page_offset": page_offset}
@@ -74,13 +76,13 @@ def _train_job(
74
76
  measurement_name: str | list[str],
75
77
  model_name: str = "",
76
78
  force_preprocess: bool = False,
77
- ) -> Job:
79
+ ) -> WorkflowTrainJob:
78
80
  """
79
81
  Create a training job.
80
82
 
81
83
  Validate inputs, format data, sends the job training request to the endpoint,
82
84
 
83
- Parses the response into a `Job` object.
85
+ Parses the response into a `TrainJob` object.
84
86
 
85
87
  Parameters
86
88
  ----------
@@ -99,8 +101,8 @@ def _train_job(
99
101
 
100
102
  Returns
101
103
  -------
102
- Job
103
- A Job
104
+ TrainJob
105
+ A train job.
104
106
 
105
107
  Raises
106
108
  ------
@@ -120,7 +122,7 @@ def _train_job(
120
122
  params = {"force_preprocess": str(force_preprocess).lower()}
121
123
 
122
124
  response = session.post(endpoint, params=params, json=data)
123
- return Job.model_validate(response.json())
125
+ return WorkflowTrainJob.model_validate(response.json())
124
126
 
125
127
 
126
128
  def create_train_job(
@@ -154,8 +156,8 @@ def create_train_job(
154
156
 
155
157
  Returns
156
158
  -------
157
- Job
158
- A Job
159
+ TrainJob
160
+ A train job.
159
161
 
160
162
  Raises
161
163
  ------
@@ -107,6 +107,9 @@ def designer_create_genetic_algorithm(
107
107
  elif isinstance(criteria, Criterion):
108
108
  criteria = Criteria([criteria])
109
109
 
110
+ if isinstance(allowed_tokens, DesignConstraint):
111
+ allowed_tokens = allowed_tokens.as_dict()
112
+
110
113
  endpoint = PATH_PREFIX + "/genetic-algorithm"
111
114
 
112
115
  body = {
@@ -4,6 +4,7 @@ import numpy as np
4
4
  import pandas as pd
5
5
  from openprotein.base import APISession
6
6
  from openprotein.csv import csv_stream
7
+ from openprotein.errors import APIError
7
8
  from openprotein.schemas import (
8
9
  CVJob,
9
10
  Job,
@@ -113,7 +114,12 @@ def predictor_fit_gp_post(
113
114
 
114
115
 
115
116
  def predictor_delete(session: APISession, predictor_id: str):
116
- raise NotImplementedError()
117
+ endpoint = PATH_PREFIX + f"/{predictor_id}"
118
+ response = session.delete(endpoint)
119
+ if 200 <= response.status_code < 300:
120
+ return True
121
+ else:
122
+ raise APIError(response.text)
117
123
 
118
124
 
119
125
  def predictor_crossvalidate_post(
@@ -2,7 +2,7 @@ import io
2
2
 
3
3
  import numpy as np
4
4
  from openprotein.base import APISession
5
- from openprotein.errors import InvalidParameterError
5
+ from openprotein.errors import APIError, InvalidParameterError
6
6
  from openprotein.schemas import SVDEmbeddingsJob, SVDFitJob, SVDMetadata
7
7
  from pydantic import TypeAdapter
8
8
 
@@ -100,8 +100,11 @@ def svd_delete(session: APISession, svd_id: str):
100
100
  """
101
101
 
102
102
  endpoint = PATH_PREFIX + f"/{svd_id}"
103
- session.delete(endpoint)
104
- return True
103
+ response = session.delete(endpoint)
104
+ if 200 <= response.status_code < 300:
105
+ return True
106
+ else:
107
+ raise APIError(response.text)
105
108
 
106
109
 
107
110
  def svd_fit_post(
@@ -3,7 +3,7 @@ import io
3
3
  import numpy as np
4
4
  import pandas as pd
5
5
  from openprotein.base import APISession
6
- from openprotein.errors import InvalidParameterError
6
+ from openprotein.errors import APIError, InvalidParameterError
7
7
  from openprotein.schemas import FeatureType, UMAPEmbeddingsJob, UMAPFitJob, UMAPMetadata
8
8
  from pydantic import TypeAdapter
9
9
 
@@ -142,8 +142,11 @@ def umap_delete(session: APISession, umap_id: str) -> bool:
142
142
  """
143
143
 
144
144
  endpoint = PATH_PREFIX + f"/{umap_id}"
145
- session.delete(endpoint)
146
- return True
145
+ response = session.delete(endpoint)
146
+ if 200 <= response.status_code < 300:
147
+ return True
148
+ else:
149
+ raise APIError(response.text)
147
150
 
148
151
 
149
152
  def umap_fit_post(
@@ -7,14 +7,12 @@ isort:skip_file
7
7
 
8
8
  from .services import (
9
9
  JobsAPI,
10
- AssayDataAPI,
11
- TrainingAPI,
12
- DesignAPI,
10
+ DataAPI,
13
11
  AlignAPI,
14
12
  EmbeddingsAPI,
15
13
  FoldAPI,
16
14
  SVDAPI,
17
15
  UMAPAPI,
18
16
  PredictorAPI,
19
- DesignerAPI,
17
+ DesignAPI,
20
18
  )
@@ -0,0 +1,8 @@
1
+ """
2
+ Deprecated OpenProtein interfaces.
3
+ """
4
+
5
+ # old workflow apis
6
+ from .services.deprecated.design import DesignAPI
7
+ from .services.deprecated.predict import PredictAPI
8
+ from .services.deprecated.train import TrainingAPI
@@ -8,19 +8,16 @@ from .assaydata import AssayDataPage, AssayDataset, AssayMetadata
8
8
 
9
9
  # workflow system
10
10
  from .futures import Future, MappedFuture, StreamingFuture
11
- from .train import CVFuture, TrainFuture
12
- from .predict import PredictionResultFuture as WorkflowPredictionResultFuture
13
- from .design import DesignFuture as WorkflowDesignFuture
14
11
 
15
12
  # poet system
16
13
  from .align import MSAFuture, PromptFuture
17
- from .deprecated.poet import PoetGenerateFuture, PoetScoreFuture, PoetSingleSiteFuture
18
14
 
19
15
  # distributed system
20
16
  from .embeddings import (
21
17
  EmbeddingModel,
22
- EmbeddingResultFuture,
23
- EmbeddingsScoreResultFuture,
18
+ EmbeddingsResultFuture,
19
+ EmbeddingsScoreFuture,
20
+ EmbeddingsGenerateFuture,
24
21
  ESMModel,
25
22
  OpenProteinModel,
26
23
  PoETModel,
@@ -30,3 +27,5 @@ from .umap import UMAPModel
30
27
  from .fold import AlphaFold2Model, ESMFoldModel, FoldModel, FoldResultFuture
31
28
  from .predictor import PredictionResultFuture, PredictorModel
32
29
  from .designer import DesignFuture
30
+
31
+ from .deprecated import *
@@ -1,13 +1,13 @@
1
1
  from openprotein.api import align
2
2
  from openprotein.base import APISession
3
- from openprotein.schemas import Job, PoetInputType
3
+ from openprotein.schemas import AlignType, Job
4
4
 
5
5
 
6
6
  class AlignFuture:
7
7
  session: APISession
8
8
  job: Job
9
9
 
10
- def get_input(self, input_type: PoetInputType):
10
+ def get_input(self, input_type: AlignType):
11
11
  """See child function docs."""
12
12
  return align.get_input(self.session, self.job, input_type)
13
13
 
@@ -0,0 +1,13 @@
1
+ """
2
+ Deprecated OpenProtein application objects.
3
+
4
+ isort:skip_file
5
+ """
6
+
7
+ # workflow apis
8
+ from .train import TrainFuture as WorkflowTrainFuture
9
+ from .predict import PredictionResultFuture as WorkflowPredictionResultFuture
10
+ from .design import DesignFuture as WorkflowDesignFuture
11
+
12
+ # old poet
13
+ from .poet import PoetGenerateFuture, PoetScoreFuture, PoetSingleSiteFuture
@@ -1,8 +1,12 @@
1
- from openprotein.api import design
1
+ """
2
+ (Deprecated) OpenProtein objects for working with workflow design APIs.
3
+ """
4
+
5
+ from openprotein.api.deprecated import design
2
6
  from openprotein.base import APISession
3
- from openprotein.schemas import WorkflowDesign, WorkflowDesignJob
7
+ from openprotein.schemas.deprecated import WorkflowDesign, WorkflowDesignJob
4
8
 
5
- from .futures import Future, PagedFuture
9
+ from ..futures import Future, PagedFuture
6
10
 
7
11
 
8
12
  class DesignFuture(PagedFuture, Future):
@@ -2,10 +2,12 @@ from typing import Collection, Iterator
2
2
 
3
3
  import numpy as np
4
4
  from openprotein import config
5
+ from openprotein.api import align
5
6
  from openprotein.api.deprecated import poet
6
7
  from openprotein.base import APISession
7
8
  from openprotein.csv import csv_stream
8
9
  from openprotein.errors import APIError
10
+ from openprotein.schemas import AlignType
9
11
  from openprotein.schemas.deprecated.poet import (
10
12
  PoetGenerateJob,
11
13
  PoetScoreJob,
@@ -17,7 +19,27 @@ from openprotein.schemas.deprecated.poet import (
17
19
  from ..futures import Future, PagedFuture, StreamingFuture
18
20
 
19
21
 
20
- class PoetScoreFuture(PagedFuture, Future):
22
+ class AlignPrompted(Future):
23
+ """Requests conditioned on an MSA prompt."""
24
+
25
+ def get_input(self, input_type: AlignType):
26
+ """Get prompt's input - can be INPUT (seed), GENERATED (aligned msa) or PROMPT."""
27
+ return align.get_input(self.session, self.job, input_type)
28
+
29
+ def get_prompt(self, prompt_index: int | None = None):
30
+ """Get sampled prompt."""
31
+ return align.get_prompt(self.session, self.job, prompt_index=prompt_index)
32
+
33
+ def get_seed(self):
34
+ """Get seed sequence to MSA."""
35
+ return align.get_seed(self.session, self.job)
36
+
37
+ def get_msa(self):
38
+ """Get aligned MSA."""
39
+ return align.get_msa(self.session, self.job)
40
+
41
+
42
+ class PoetScoreFuture(PagedFuture, AlignPrompted, Future):
21
43
  """
22
44
  Represents a result of a PoET scoring job.
23
45
 
@@ -44,7 +66,6 @@ class PoetScoreFuture(PagedFuture, Future):
44
66
  session: APISession,
45
67
  job: PoetScoreJob,
46
68
  page_size=config.POET_PAGE_SIZE,
47
- **kwargs,
48
69
  ):
49
70
  """
50
71
  init a PoetScoreFuture instance.
@@ -63,7 +84,7 @@ class PoetScoreFuture(PagedFuture, Future):
63
84
  # Format results after getting is complete
64
85
  return [(p.name, p.sequence, np.asarray(p.score)) for p in results]
65
86
 
66
- def get_slice(self, start: int, end: int, **kwargs) -> Collection:
87
+ def get_slice(self, start: int, end: int) -> Collection:
67
88
  results = poet.poet_score_get(
68
89
  self.session,
69
90
  self.id,
@@ -75,7 +96,7 @@ class PoetScoreFuture(PagedFuture, Future):
75
96
  return []
76
97
 
77
98
 
78
- class PoetSingleSiteFuture(PagedFuture, Future):
99
+ class PoetSingleSiteFuture(PagedFuture, AlignPrompted, Future):
79
100
  """
80
101
  Represents a result of a PoET single-site analysis job.
81
102
 
@@ -102,7 +123,6 @@ class PoetSingleSiteFuture(PagedFuture, Future):
102
123
  session: APISession,
103
124
  job: PoetSSPJob,
104
125
  page_size=config.POET_PAGE_SIZE,
105
- **kwargs,
106
126
  ):
107
127
  """
108
128
  init a PoetSingleSiteFuture instance.
@@ -121,7 +141,7 @@ class PoetSingleSiteFuture(PagedFuture, Future):
121
141
  # Format results after getting is complete
122
142
  return {p.sequence: np.asarray(p.score) for p in results}
123
143
 
124
- def get_slice(self, start: int, end: int, **kwargs) -> Collection:
144
+ def get_slice(self, start: int, end: int) -> Collection:
125
145
  results = poet.poet_single_site_get(
126
146
  self.session,
127
147
  self.id,
@@ -133,7 +153,7 @@ class PoetSingleSiteFuture(PagedFuture, Future):
133
153
  return []
134
154
 
135
155
 
136
- class PoetGenerateFuture(StreamingFuture, Future):
156
+ class PoetGenerateFuture(StreamingFuture, AlignPrompted, Future):
137
157
  """
138
158
  Represents a result of a PoET generation job.
139
159