Skip to content

Commit

Permalink
release v0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
markgeejw committed Nov 29, 2024
1 parent 60d0122 commit 922c573
Show file tree
Hide file tree
Showing 56 changed files with 2,770 additions and 529 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION ?= 0.5.0
VERSION ?= 0.5.2
SHELL := /bin/bash

.PHONY: releasehere
Expand Down
12 changes: 6 additions & 6 deletions anaconda_build/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: openprotein-python
version: "0.5.0"
version: "0.5.2"

source:
path: ../
Expand All @@ -12,19 +12,19 @@ build:

requirements:
build:
- python >=3.10,<3.11
- python >=3.10
- hatchling >=1.25.0,<2
host:
- python >=3.10,<3.11
- python >=3.10
- pip
- hatchling >=1.25.0,<2
run:
- python >=3.10,<3.11
- python >=3.10
- requests >=2.32.3,<3
- pydantic >=2.5,<3
- tqdm >=4.66.5,<5
- pandas >=2.1.4,<3
- numpy >=2.1.1,<3
- pandas >=2.2.2,<3
- numpy >=1.9,<3

about:
home: https://www.openprotein.ai/
Expand Down
76 changes: 53 additions & 23 deletions openprotein/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
"""
OpenProtein Python client.
A pythonic interface for interacting with our cutting-edge protein engineering platform.
isort:skip_file
"""

from openprotein._version import __version__
from openprotein.app import (
SVDAPI,
AlignAPI,
AssayDataAPI,
JobsAPI,
TrainingAPI,
DesignAPI,
AlignAPI,
EmbeddingsAPI,
FoldAPI,
JobsAPI,
SVDAPI,
UMAPAPI,
PredictorAPI,
TrainingAPI,
DesignerAPI,
)
from openprotein.app.models import Future
from openprotein.base import APISession
Expand All @@ -19,15 +29,17 @@ class OpenProtein(APISession):
The base class for accessing OpenProtein API functionality.
"""

_embedding = None
_svd = None
_fold = None
_align = None
_jobs = None
_data = None
_jobs = None
_train = None
_design = None
_align = None
_embedding = None
_svd = None
_umap = None
_fold = None
_predictor = None
_designer = None

def wait(self, future: Future, *args, **kwargs):
return future.wait(*args, **kwargs)
Expand All @@ -37,15 +49,6 @@ def wait(self, future: Future, *args, **kwargs):
def load_job(self, job_id):
return self.jobs.__load(job_id=job_id)

@property
def jobs(self) -> JobsAPI:
"""
The jobs submodule gives access to functionality for listing jobs and checking their status.
"""
if self._jobs is None:
self._jobs = JobsAPI(self)
return self._jobs

@property
def data(self) -> AssayDataAPI:
"""
Expand All @@ -55,6 +58,15 @@ def data(self) -> AssayDataAPI:
self._data = AssayDataAPI(self)
return self._data

@property
def jobs(self) -> JobsAPI:
"""
The jobs submodule gives access to functionality for listing jobs and checking their status.
"""
if self._jobs is None:
self._jobs = JobsAPI(self)
return self._jobs

@property
def train(self) -> TrainingAPI:
"""
Expand All @@ -64,6 +76,15 @@ def train(self) -> TrainingAPI:
self._train = TrainingAPI(self)
return self._train

@property
def design(self) -> DesignAPI:
"""
The design submodule gives access to functionality for designing new sequences using models from train.
"""
if self._design is None:
self._design = DesignAPI(self)
return self._design

@property
def align(self) -> AlignAPI:
"""
Expand Down Expand Up @@ -91,6 +112,15 @@ def svd(self) -> SVDAPI:
self._svd = SVDAPI(self, self.embedding)
return self._svd

@property
def umap(self) -> UMAPAPI:
"""
The embedding submodule gives access to protein embedding models and their inference endpoints.
"""
if self._umap is None:
self._umap = UMAPAPI(self)
return self._umap

@property
def predictor(self) -> PredictorAPI:
"""
Expand All @@ -101,13 +131,13 @@ def predictor(self) -> PredictorAPI:
return self._predictor

@property
def design(self) -> DesignAPI:
def designer(self) -> DesignerAPI:
"""
The design submodule gives access to functionality for designing new sequences using models from train.
The designer submodule gives access to functionality for designing new sequences using models from predictor train.
"""
if self._design is None:
self._design = DesignAPI(self)
return self._design
if self._designer is None:
self._designer = DesignerAPI(self)
return self._designer

@property
def fold(self) -> FoldAPI:
Expand Down
1 change: 0 additions & 1 deletion openprotein/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import align, assaydata, design, embedding, fold, predict, predictor, train
from .deprecated import poet
24 changes: 1 addition & 23 deletions openprotein/api/align.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
import codecs
import csv
import io
import random
from typing import BinaryIO, Iterator

import openprotein.config as config
import requests
from openprotein.base import APISession
from openprotein.csv import csv_stream
from openprotein.errors import APIError, InvalidParameterError, MissingParameterError
from openprotein.schemas import Job, MSASamplingMethod, PoetInputType


def csv_stream(response: requests.Response) -> Iterator[list[str]]:
"""
Returns a CSV reader from a requests.Response object.
Parameters
----------
response : requests.Response
The response object to parse.
Returns
-------
csv.reader
A csv reader object for the response.
"""
raw_content = response.raw # the raw bytes stream
content = codecs.getreader("utf-8")(
raw_content
) # force the response to be encoded as utf-8
return csv.reader(content)


def get_align_job_inputs(
session: APISession,
job_id: str,
Expand Down
6 changes: 5 additions & 1 deletion openprotein/api/deprecated/poet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from openprotein import config
from openprotein.base import APISession
from openprotein.errors import APIError, InvalidParameterError, MissingParameterError
from openprotein.schemas import PoetGenerateJob, PoetScoreJob, PoetSSPJob
from openprotein.schemas.deprecated.poet import (
PoetGenerateJob,
PoetScoreJob,
PoetSSPJob,
)


def poet_score_post(
Expand Down
20 changes: 12 additions & 8 deletions openprotein/api/design.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from openprotein.base import APISession
from openprotein.schemas import DesignJobCreate, DesignResults, Job
from openprotein.schemas import (
WorkflowDesign,
WorkflowDesignJob,
WorkflowDesignJobCreate,
)


def create_design_job(session: APISession, design_job: DesignJobCreate):
def create_design_job(session: APISession, design_job: WorkflowDesignJobCreate):
"""
Send a POST request for protein design job.
Expand All @@ -13,7 +17,7 @@ def create_design_job(session: APISession, design_job: DesignJobCreate):
design_job : DesignJobCreate
The details of the design job to be created, with the following parameters:
- assay_id: The ID for the assay.
- criteria: A list of CriterionItem lists for evaluating the design.
- criteria: Criteria for evaluating the design.
- num_steps: The number of steps in the genetic algo. Default is 8.
- pop_size: The population size for the genetic algo. Default is None.
- n_offsprings: The number of offspring for the genetic algo. Default is None.
Expand All @@ -24,13 +28,13 @@ def create_design_job(session: APISession, design_job: DesignJobCreate):
Returns
-------
Job
WorkflowDesignJob
The created job as a Job instance.
"""
params = design_job.model_dump(exclude_none=True)
# print(f"sending design: {params}")
response = session.post("v1/workflow/design/genetic-algorithm", json=params)
return Job.model_validate(response.json())
return WorkflowDesignJob.model_validate(response.json())


def get_design_results(
Expand All @@ -39,7 +43,7 @@ def get_design_results(
step: int | None = None,
page_size: int | None = None,
page_offset: int | None = None,
) -> DesignResults:
) -> WorkflowDesign:
"""
Retrieves the results of a Design job.
Expand All @@ -60,7 +64,7 @@ def get_design_results(
Returns
-------
DesignJob
WorkflowDesignJob
The job object representing the Design job.
Raises
Expand All @@ -79,4 +83,4 @@ def get_design_results(

response = session.get(endpoint, params=params)

return DesignResults.model_validate(response.json())
return WorkflowDesign.model_validate(response.json())
Loading

0 comments on commit 922c573

Please sign in to comment.