openprotein-python 0.8.2__1-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.
Files changed (84) hide show
  1. openprotein/__init__.py +164 -0
  2. openprotein/_version.py +48 -0
  3. openprotein/align/__init__.py +8 -0
  4. openprotein/align/align.py +395 -0
  5. openprotein/align/api.py +428 -0
  6. openprotein/align/future.py +55 -0
  7. openprotein/align/msa.py +129 -0
  8. openprotein/align/schemas.py +165 -0
  9. openprotein/base.py +181 -0
  10. openprotein/chains.py +88 -0
  11. openprotein/common/__init__.py +5 -0
  12. openprotein/common/features.py +7 -0
  13. openprotein/common/model_metadata.py +33 -0
  14. openprotein/common/reduction.py +8 -0
  15. openprotein/config.py +9 -0
  16. openprotein/csv.py +31 -0
  17. openprotein/data/__init__.py +9 -0
  18. openprotein/data/api.py +218 -0
  19. openprotein/data/assaydataset.py +178 -0
  20. openprotein/data/data.py +93 -0
  21. openprotein/data/schemas.py +27 -0
  22. openprotein/design/__init__.py +16 -0
  23. openprotein/design/api.py +259 -0
  24. openprotein/design/design.py +125 -0
  25. openprotein/design/future.py +146 -0
  26. openprotein/design/schemas.py +607 -0
  27. openprotein/embeddings/__init__.py +27 -0
  28. openprotein/embeddings/api.py +619 -0
  29. openprotein/embeddings/embeddings.py +151 -0
  30. openprotein/embeddings/esm.py +33 -0
  31. openprotein/embeddings/future.py +146 -0
  32. openprotein/embeddings/models.py +421 -0
  33. openprotein/embeddings/openprotein.py +21 -0
  34. openprotein/embeddings/poet.py +446 -0
  35. openprotein/embeddings/poet2.py +505 -0
  36. openprotein/embeddings/schemas.py +78 -0
  37. openprotein/errors.py +76 -0
  38. openprotein/fasta.py +92 -0
  39. openprotein/fold/__init__.py +21 -0
  40. openprotein/fold/alphafold2.py +131 -0
  41. openprotein/fold/api.py +287 -0
  42. openprotein/fold/boltz.py +691 -0
  43. openprotein/fold/esmfold.py +54 -0
  44. openprotein/fold/fold.py +107 -0
  45. openprotein/fold/future.py +509 -0
  46. openprotein/fold/models.py +139 -0
  47. openprotein/fold/schemas.py +39 -0
  48. openprotein/jobs/__init__.py +9 -0
  49. openprotein/jobs/api.py +71 -0
  50. openprotein/jobs/futures.py +746 -0
  51. openprotein/jobs/jobs.py +69 -0
  52. openprotein/jobs/schemas.py +135 -0
  53. openprotein/models/__init__.py +4 -0
  54. openprotein/models/base.py +63 -0
  55. openprotein/models/foundation/rfdiffusion.py +283 -0
  56. openprotein/models/models.py +33 -0
  57. openprotein/predictor/__init__.py +25 -0
  58. openprotein/predictor/api.py +384 -0
  59. openprotein/predictor/models.py +374 -0
  60. openprotein/predictor/prediction.py +79 -0
  61. openprotein/predictor/predictor.py +242 -0
  62. openprotein/predictor/schemas.py +113 -0
  63. openprotein/predictor/validate.py +40 -0
  64. openprotein/prompt/__init__.py +9 -0
  65. openprotein/prompt/api.py +505 -0
  66. openprotein/prompt/models.py +142 -0
  67. openprotein/prompt/prompt.py +130 -0
  68. openprotein/prompt/schemas.py +49 -0
  69. openprotein/protein.py +587 -0
  70. openprotein/svd/__init__.py +9 -0
  71. openprotein/svd/api.py +206 -0
  72. openprotein/svd/models.py +288 -0
  73. openprotein/svd/schemas.py +31 -0
  74. openprotein/svd/svd.py +134 -0
  75. openprotein/umap/__init__.py +9 -0
  76. openprotein/umap/api.py +259 -0
  77. openprotein/umap/models.py +211 -0
  78. openprotein/umap/schemas.py +35 -0
  79. openprotein/umap/umap.py +175 -0
  80. openprotein/utils/uuid.py +29 -0
  81. openprotein_python-0.8.2.dist-info/METADATA +176 -0
  82. openprotein_python-0.8.2.dist-info/RECORD +84 -0
  83. openprotein_python-0.8.2.dist-info/WHEEL +4 -0
  84. openprotein_python-0.8.2.dist-info/licenses/LICENSE.txt +30 -0
@@ -0,0 +1,139 @@
1
+ """Fold model representations which can be used directly for creating structure predictions."""
2
+
3
+ from openprotein.base import APISession
4
+ from openprotein.common import ModelMetadata
5
+
6
+ from . import api
7
+ from .future import FoldComplexResultFuture, FoldResultFuture
8
+
9
+
10
+ class FoldModel:
11
+
12
+ # overridden by subclasses
13
+ # used to get correct fold model
14
+ model_id: list[str] | str
15
+
16
+ def __init__(
17
+ self,
18
+ session: APISession,
19
+ model_id: str,
20
+ metadata: ModelMetadata | None = None,
21
+ ):
22
+ self.session = session
23
+ self.id = model_id
24
+ self._metadata = metadata
25
+
26
+ def __str__(self) -> str:
27
+ return self.id
28
+
29
+ def __repr__(self) -> str:
30
+ return self.id
31
+
32
+ @classmethod
33
+ def get_model(cls):
34
+ """
35
+ Get the model_id(s) for this FoldModel subclass.
36
+
37
+ Returns
38
+ -------
39
+ list of str
40
+ List of model_id strings associated with this class.
41
+ """
42
+ if isinstance(cls.model_id, str):
43
+ return [cls.model_id]
44
+ return cls.model_id
45
+
46
+ @classmethod
47
+ def create(
48
+ cls,
49
+ session: APISession,
50
+ model_id: str,
51
+ default: type["FoldModel"] | None = None,
52
+ **kwargs,
53
+ ):
54
+ """
55
+ Create and return an instance of the appropriate FoldModel subclass based on the model_id.
56
+
57
+ Parameters
58
+ ----------
59
+ session : APISession
60
+ The API session to use.
61
+ model_id : str
62
+ The model identifier.
63
+ default : type[FoldModel] or None, optional
64
+ Default FoldModel subclass to use if no match is found.
65
+ **kwargs : dict, optional
66
+ Additional keyword arguments to pass to the model constructor.
67
+
68
+ Returns
69
+ -------
70
+ FoldModel
71
+ An instance of the appropriate FoldModel subclass.
72
+
73
+ Raises
74
+ ------
75
+ ValueError
76
+ If no suitable FoldModel subclass is found and no default is provided.
77
+ """
78
+ # Dynamically discover all subclasses of FoldModel
79
+ model_classes = FoldModel.__subclasses__()
80
+
81
+ # Find the FoldModel class that matches the model_id
82
+ for model_class in model_classes:
83
+ if model_id in model_class.get_model():
84
+ return model_class(session=session, model_id=model_id, **kwargs)
85
+ # default to FoldModel
86
+ if default is not None:
87
+ try:
88
+ return default(session=session, model_id=model_id, **kwargs)
89
+ except:
90
+ pass
91
+ raise ValueError(f"Unsupported model_id type: {model_id}")
92
+
93
+ @property
94
+ def metadata(self):
95
+ """
96
+ ModelMetadata : Model metadata for this model.
97
+ """
98
+ if self._metadata is None:
99
+ self._metadata = self.get_metadata()
100
+ return self._metadata
101
+
102
+ def get_metadata(self) -> ModelMetadata:
103
+ """
104
+ Get model metadata for this model.
105
+
106
+ Returns
107
+ -------
108
+ ModelMetadata
109
+ The metadata associated with this model.
110
+ """
111
+ return api.fold_model_get(self.session, self.id)
112
+
113
+ def fold(self, **kwargs) -> FoldResultFuture | FoldComplexResultFuture:
114
+ """
115
+ Fold a sequence using this model.
116
+
117
+ Parameters
118
+ ----------
119
+ **kwargs : dict, optional
120
+ Additional keyword arguments to pass to the underlying
121
+ `fold` request.
122
+
123
+ Returns
124
+ -------
125
+ FoldResultFuture or FoldComplexResultFuture
126
+ Future object representing the fold result.
127
+ """
128
+ return FoldResultFuture.create(
129
+ session=self.session,
130
+ job=api.fold_models_post(
131
+ session=self.session,
132
+ model_id=(
133
+ model_id
134
+ if isinstance(model_id := self.model_id, str)
135
+ else model_id[0]
136
+ ),
137
+ **kwargs,
138
+ ),
139
+ )
@@ -0,0 +1,39 @@
1
+ """Schema for OpenProtein fold system."""
2
+
3
+ from typing import Literal
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from openprotein.jobs import BatchJob, Job, JobType
8
+
9
+
10
+ class FoldMetadata(BaseModel):
11
+ """
12
+ Metadata for a folding job.
13
+
14
+ Attributes
15
+ ----------
16
+ job_id : str
17
+ Unique identifier for the job.
18
+ model_id : str
19
+ Identifier for the model used in the job.
20
+ args : dict or None, optional
21
+ Additional arguments for the job.
22
+ """
23
+
24
+ job_id: str
25
+ model_id: str
26
+ args: dict | None = None
27
+
28
+
29
+ class FoldJob(Job, BatchJob):
30
+ """
31
+ Folding job class.
32
+
33
+ Attributes
34
+ ----------
35
+ job_type : Literal[JobType.embeddings_fold]
36
+ The type of job, set to embeddings_fold.
37
+ """
38
+
39
+ job_type: Literal[JobType.embeddings_fold]
@@ -0,0 +1,9 @@
1
+ """
2
+ Jobs module for OpenProtein.
3
+
4
+ isort:skip_file
5
+ """
6
+
7
+ from .schemas import BatchJob, Job, JobStatus, JobType
8
+ from .futures import Future, MappedFuture, PagedFuture, StreamingFuture
9
+ from .jobs import JobsAPI
@@ -0,0 +1,71 @@
1
+ """Jobs and job-centric flows."""
2
+
3
+ from typing import List
4
+
5
+ from pydantic import TypeAdapter
6
+
7
+ from openprotein.base import APISession
8
+
9
+ from .schemas import Job
10
+
11
+
12
+ def job_args_get(session: APISession, job_id: str) -> dict:
13
+ """Get job."""
14
+ endpoint = f"v1/jobs/{job_id}/args"
15
+ response = session.get(endpoint)
16
+ return dict(**response.json())
17
+
18
+
19
+ def job_get(session: APISession, job_id: str) -> Job:
20
+ """Get job."""
21
+ endpoint = f"v1/jobs/{job_id}"
22
+ response = session.get(endpoint)
23
+ return TypeAdapter(Job).validate_python(response.json())
24
+
25
+
26
+ def jobs_list(
27
+ session: APISession,
28
+ status: str | None = None,
29
+ job_type: str | None = None,
30
+ assay_id: str | None = None,
31
+ more_recent_than: str | None = None,
32
+ limit: int | None = None,
33
+ ) -> List[Job]:
34
+ """
35
+ Retrieve a list of jobs filtered by specific criteria.
36
+
37
+ Parameters
38
+ ----------
39
+ session : APISession
40
+ The current API session for communication with the server.
41
+ status : str, optional
42
+ Filter by job status. If None, jobs of all statuses are retrieved. Default is None.
43
+ job_type : str, optional
44
+ Filter by Filter. If None, jobs of all types are retrieved. Default is None.
45
+ assay_id : str, optional
46
+ Filter by assay. If None, jobs for all assays are retrieved. Default is None.
47
+ more_recent_than : str, optional
48
+ Retrieve jobs that are more recent than a specified date. If None, no date filtering is applied. Default is None.
49
+
50
+ Returns
51
+ -------
52
+ List[Job]
53
+ A list of Job instances that match the specified criteria.
54
+ """
55
+ endpoint = "v1/jobs"
56
+
57
+ params = {}
58
+ if status is not None:
59
+ params["status"] = status
60
+ if job_type is not None:
61
+ params["job_type"] = job_type
62
+ if assay_id is not None:
63
+ params["assay_id"] = assay_id
64
+ if more_recent_than is not None:
65
+ params["more_recent_than"] = more_recent_than
66
+ if limit is not None:
67
+ params["limit"] = limit
68
+
69
+ response = session.get(endpoint, params=params)
70
+ # return jobs, not futures
71
+ return TypeAdapter(List[Job]).validate_python(response.json())