Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.17.0"
".": "0.18.0"
}
102 changes: 97 additions & 5 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ result = future.get(verbose=True) # get the result from a finished job
## Jobs Interface

### Listing Jobs
To view all jobs associated with each session, the following method is available, providing an option to filter results by date, job type, or status.
To view all jobs associated with each session, the following method is available, providing an option to filter results by date, job type, status, or name.
```
session.jobs.list()
session.jobs.list(name="my-run") # filter to jobs with an exact name match
```

### Retrieving Specific Job
Expand All @@ -86,6 +87,15 @@ For detailed information about a particular job, use the following command with
session.jobs.get(JOB_ID) # Replace JOB_ID with the ID of the specific job to be retrieved
```

### Naming Jobs
A job can be given a name and description once it's created, to make it easier to find:
```
session.jobs.update(JOB_ID, name="my-run", description="baseline model")

# equivalent, from a Future
future.rename(name="my-run", description="baseline model")
```

### Resuming Jobs
Jobs from prior workflows can be resumed using the load_job method provided by each API.
```
Expand Down
29 changes: 23 additions & 6 deletions openprotein/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@
from openprotein.jobs import Future
from openprotein.base import APISession

__all__ = [
"SVDAPI",
"UMAPAPI",
"APISession",
"AlignAPI",
"ClusteringAPI",
"DataAPI",
"DeprecationError",
"DesignAPI",
"EmbeddingsAPI",
"FoldAPI",
"Future",
"JobsAPI",
"ModelsAPI",
"OpenProtein",
"PredictorAPI",
"PromptAPI",
"__version__",
"connect",
]


class OpenProtein(APISession):
"""
Expand Down Expand Up @@ -102,9 +123,7 @@ def embedding(self) -> EmbeddingsAPI:

@property
def svd(self) -> SVDAPI:
"""
The embedding submodule gives access to protein embedding models and their inference endpoints.
"""
"""Fit and apply SVD projections through the SVD API."""
if self._svd is None:
self._svd = SVDAPI(
session=self,
Expand All @@ -113,9 +132,7 @@ def svd(self) -> SVDAPI:

@property
def umap(self) -> UMAPAPI:
"""
The embedding submodule gives access to protein embedding models and their inference endpoints.
"""
"""Fit and apply UMAP projections through the UMAP API."""
if self._umap is None:
self._umap = UMAPAPI(
session=self,
Expand Down
38 changes: 38 additions & 0 deletions openprotein/_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Helper for deprecating public interfaces."""

import warnings


def warn_deprecated(
name: str,
use: str,
*,
since: str,
removed_in: str,
stacklevel: int = 3,
) -> None:
"""
Warn that a public interface is deprecated.

The default ``stacklevel`` points the warning at the caller of the
deprecated function that calls this helper.

Parameters
----------
name : str
Name of the deprecated interface.
use : str
The replacement, already formatted for display.
since : str
Version the interface was deprecated in.
removed_in : str
Version the interface is removed in.
stacklevel : int, default=3
Stack level passed to `warnings.warn`.
"""
warnings.warn(
f"`{name}` is deprecated since {since} and will be removed in {removed_in}. "
f"Use {use}.",
FutureWarning,
stacklevel=stacklevel,
)
2 changes: 0 additions & 2 deletions openprotein/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ def _get_hatch_version():
"""Compute the most up-to-date version number in a development environment.

Returns `None` if Hatchling is not installed, e.g. in a production environment.

For more details, see <https://github.com/maresb/hatch-vcs-footgun-example/>.
"""
import os

Expand Down
2 changes: 2 additions & 0 deletions openprotein/align/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

from .msa import MSAFuture
from .align import AlignAPI

__all__ = ["AlignAPI", "MSAFuture"]
61 changes: 61 additions & 0 deletions openprotein/align/_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Sequence files read by the deprecated align methods."""

import csv

from openprotein import fasta
from openprotein.errors import InvalidParameterError


def read_file_content(file) -> bytes | bytearray | str:
"""Read the sequence file a deprecated align method was given.

Accepts a file-like object, ``bytes``, ``bytearray``, ``str`` or a
``(filename, fileobj)`` / ``(filename, fileobj, content_type)`` tuple or list.
"""
if isinstance(file, (tuple, list)):
file = file[1]
return file.read() if hasattr(file, "read") else file


def read_sequences(
content: bytes | bytearray | str,
) -> tuple[list[str], list[str] | None]:
"""Parse FASTA or headerless CSV text into sequences and optional names."""
if isinstance(content, (bytes, bytearray)):
content = content.decode("utf-8-sig")
text = content.removeprefix("\ufeff")
lines = text.splitlines()
if any(line.lstrip().startswith(">") for line in lines):
parsed_names, parsed_sequences = fasta.parse(lines)
names: list[str] | None = []
sequences: list[str] = []
for name, sequence in zip(parsed_names, parsed_sequences):
if sequence.strip():
names.append(str(name))
sequences.append(str(sequence))
else:
rows = []
width = 1
for row in csv.reader(text.splitlines(keepends=True)):
trimmed = row.copy()
while trimmed and not trimmed[-1].strip():
trimmed.pop()
if trimmed:
rows.append(row)
width = max(width, len(trimmed))
if width > 2:
raise InvalidParameterError(
"CSV must have one sequence column or name and sequence columns."
)
names = None if width == 1 else []
sequences = []
for row in rows:
sequence = row[1] if names is not None and len(row) > 1 else row[0]
if not sequence.strip():
continue
sequences.append(sequence.strip())
if names is not None:
names.append(row[0].strip() if len(row) > 1 else "")
if not sequences:
raise InvalidParameterError("The file contains no sequences.")
return sequences, names
Loading
Loading