Skip to content

deeporigin.drug_discovery.uniprot_discovery

Bases: Execution, SyncExecutableMixin

Rank experimental PDBs for a UniProt accession via the platform tool.

Call :meth:run for ranked candidates. Call :meth:import_proteins to sync recommended or selected PDB IDs into a project with uniprot_accession persisted.

Attributes

USER_LOG_COLUMNS class-attribute

USER_LOG_COLUMNS: list[str] = [
    "log_level",
    "tool_key",
    "timestamp",
    "message",
]

candidates property

candidates: list[UniprotDiscoveryCandidate] | None

Cached candidates from the last successful :meth:run, if any.

client instance-attribute

client: DeepOriginClient = client

cost property

cost: float | None

Actual cost in dollars, set after execution completes.

This property cannot be set manually.

dto property

dto: dict[str, Any] | None

Last tools execution DTO from the platform, if any.

estimate property

estimate: float | None

Cost estimate in dollars, populated when the platform returns a quotation.

Set after run(quote=True), start(quote=True), or any call with approve_amount=-1. None until a quotation result is received. This property cannot be set manually.

id property

id: str | None

Platform execution ID when set (read-only).

name instance-attribute

name = name

project_id property

project_id: str | None

Optional project id used as a default for :meth:import_proteins.

runtime property

runtime: float | None

Seconds from DTO startedAt to completedAt or current UTC time.

Uses :attr:dto (same shape as client.executions.get). When completedAt is present, it is the end time; otherwise the end time is datetime.now(timezone.utc). Returns None if there is no DTO or startedAt is missing or empty.

tool_key class-attribute instance-attribute

tool_key: str = TOOL_KEYS_AND_VERSIONS["uniprot_discovery"][
    "tool_key"
]

tool_version instance-attribute

tool_version = tool_version

uniprot_accession property

uniprot_accession: str

UniProtKB accession configured for this job.

Methods:

confirm

confirm() -> None

Confirm a quoted tools execution on the platform.

Requires :attr:id and status equal to "Quoted". Uses :meth:~deeporigin.platform.executions.Executions.confirm with :data:~deeporigin.utils.constants.TOOL_EXECUTION_POST_TIMEOUT_SECONDS (10 minutes) and retry=False, then applies the returned DTO via :meth:update_from_dto so status, :attr:cost, and :attr:dto reflect the platform response. For direct (blocking) tools the response is typically terminal (Completed); for async tools it may be Created or Running — call :meth:sync until the job finishes.

Raises:

Type Description
ValueError

If there is no platform execution id or status is not "Quoted".

duplicate

duplicate(
    *, client: DeepOriginClient | None = None
) -> Self

Create a fresh copy with the same configuration but no execution state.

Useful after from_id() to re-run the same calculation. The returned instance has no id, status, estimate, or cost — it is ready for run() / start().

Parameters:

Name Type Description Default
client DeepOriginClient | None

Optional API client for the new instance. Falls back to the current instance's client.

None

Returns:

Type Description
Self

A new instance sharing the same domain-specific configuration.

from_dto classmethod

from_dto(
    dto: dict[str, Any],
    *,
    client: DeepOriginClient | None = None
) -> Self

Construct a UniprotDiscovery from a tools execution DTO.

Restores uniprot_accession from userInputs (falling back to inputs).

Parameters:

Name Type Description Default
dto dict[str, Any]

Execution payload (same shape as client.executions.get).

required
client DeepOriginClient | None

Optional API client.

None

Returns:

Type Description
Self

A UniprotDiscovery with id and domain inputs restored.

Raises:

Type Description
ValueError

If stored inputs lack uniprot_accession.

from_id classmethod

from_id(
    id: str, *, client: DeepOriginClient | None = None
) -> Self

Construct an instance from an existing platform execution ID.

Fetches the execution DTO via client.executions.get and delegates to :meth:from_dto. Concrete subclasses override :meth:from_dto to attach domain state from userInputs.

Parameters:

Name Type Description Default
id str

Platform execution ID.

required
client DeepOriginClient | None

Optional API client. Uses the default if not provided.

None

Returns:

Type Description
Self

A partially-hydrated instance with common fields populated.

Raises:

Type Description
NotImplementedError

If cls has no tool_key (bare :class:Execution).

from_last_run classmethod

from_last_run(
    *, client: DeepOriginClient | None = None
) -> Self

Construct an instance from the most recently created execution of this tool.

Scoped to the client's project, like :meth:list. Calls client.executions.list with tool_key, order set to :data:~deeporigin.utils.constants.EXECUTION_LIST_ORDER_CREATED_DESC, the client's project_id, and page_size=1, then delegates to :meth:from_dto. Concrete subclasses inherit this method; domain state is restored via their from_dto overrides.

Parameters:

Name Type Description Default
client DeepOriginClient | None

Optional API client. Uses the default if not provided.

None

Returns:

Type Description
Self

A partially-hydrated instance for the newest execution by

Self

createdAt.

Raises:

Type Description
NotImplementedError

If cls has no tool_key (bare :class:Execution).

ValueError

If no executions exist for this tool type.

get_results

get_results(**kwargs: Any) -> Any

Fetch results for this execution from the data platform.

Thin wrapper around :meth:deeporigin.platform.results.Results.get scoped to this execution's compute_job_id. Subclasses that need result-type-specific filtering (e.g. poses, prepared systems) should override this method and call the appropriate Results wrapper directly rather than teaching this base method about those filters.

Parameters:

Name Type Description Default
**kwargs Any

Forwarded to :meth:~deeporigin.platform.results.Results.get (typically filter_dict, limit, select). When :attr:tool_key is set, a tool_key equality filter is injected into filter_dict via setdefault so callers can override it by passing tool_key themselves.

{}

Returns:

Type Description
Any

Result-explorer response dict with data and meta keys.

Raises:

Type Description
ValueError

If the execution has no ID yet.

get_user_logs

get_user_logs(
    *,
    limit: int | None = None,
    offset: int | None = None,
    select: list[str] | None = None,
    with_total_count: bool = False
) -> DataFrame | None

Search data-platform user_logs rows for this execution.

Uses :meth:deeporigin.platform.user_logs.UserLogs.search with this execution's id (tools executionId), stored as execution_id on user_logs rows — the same string passed to :meth:get_results as compute_job_id.

When no execution id is assigned yet, returns None without calling the API.

Parameters:

Name Type Description Default
limit int | None

Max rows to return (forwarded to UserLogs.search).

None
offset int | None

Skip offset (forwarded).

None
select list[str] | None

Columns to select (forwarded).

None
with_total_count bool

Request total count from the server (forwarded).

False

Returns:

Type Description
DataFrame | None

A DataFrame with columns log_level, tool_key, timestamp,

DataFrame | None

and message. tool_key omits the deeporigin. prefix;

DataFrame | None

timestamp is a compact humanized relative time. Returns None

DataFrame | None

if this instance has no execution id yet or the client has no

DataFrame | None

user_logs API.

import_proteins

import_proteins(
    pdb_ids: list[str] | None = None,
    *,
    project_id: str | None = None
) -> list[Protein]

Download and sync selected (or recommended) PDB candidates.

Runs :meth:run if candidates are not already cached. Requires a resolvable project id. Each protein is synced with :attr:~deeporigin.drug_discovery.structures.protein.Protein.uniprot_accession set from this job.

Parameters:

Name Type Description Default
pdb_ids list[str] | None

PDB IDs to import. Must appear in this accession's candidates. When None, imports the single recommended candidate.

None
project_id str | None

Project to sync into. Falls back to the instance project_id, then client.project_id.

None

Returns:

Name Type Description
Synced list[Protein]

class:~deeporigin.drug_discovery.structures.protein.Protein

list[Protein]

instances (one per selected PDB ID).

Raises:

Type Description
DeepOriginException

If project is missing, candidates are empty, selection is invalid, or sync fails.

list classmethod

list(
    *,
    client: DeepOriginClient | None = None,
    status: list[str] | None = None
) -> list[Self]

List executions of this tool, newest first, scoped to the client's project.

Parameters:

Name Type Description Default
client DeepOriginClient | None

Optional API client. Uses the default if not provided.

None
status list[str] | None

Optional list of statuses to keep.

None

Returns:

Type Description
list[Self]

Instances of this class, newest first.

Raises:

Type Description
NotImplementedError

If cls has no tool_key (bare :class:Execution).

run

run(
    *,
    quote: bool = False,
    approve_amount: int | None = None
) -> list[UniprotDiscoveryCandidate] | None

Run UniProt discovery synchronously and return ranked candidates.

Parameters:

Name Type Description Default
quote bool

Shorthand for approve_amount=-1. Returns None when the platform returns a quotation.

False
approve_amount int | None

Spend cap forwarded as approveAmount.

None

Returns:

Name Type Description
Ranked list[UniprotDiscoveryCandidate] | None

class:UniprotDiscoveryCandidate rows (possibly empty), or

list[UniprotDiscoveryCandidate] | None

None for quote-only responses.

Raises:

Type Description
DeepOriginException

If the execution does not succeed or jobOutputs.candidates is missing/invalid.

sync

sync() -> None

Fetch the latest tools execution from the platform and refresh fields.

Calls client.executions.get for :attr:id and applies the response with :meth:update_from_dto. Use when the job may have changed outside this process (for example after submission from the web UI), to poll lifecycle state, or to refresh an instance built from an older DTO. Available on sync-only and async execution types alike.

Rejected executions are refreshed without raising for their status, so history inspection and notebook displays remain available. HTTP failures while fetching the execution still raise.

If executions.get returns a falsy value, this instance is left unchanged.

Raises:

Type Description
ValueError

If this instance has no execution id yet.

NotImplementedError

If type(self).tool_key is empty (bare :class:Execution).

ValueError

If the returned DTO tool.key does not match this class (see :meth:update_from_dto).

update_from_dto

update_from_dto(dto: dict[str, Any]) -> None

Apply tools execution fields from dto onto this instance.

Updates id, pricing, lifecycle fields, and _dto the same way as :meth:from_dto for a newly created instance. Use after a live executions.create / sync() response to refresh state without constructing a new object (domain inputs on self are unchanged).

Parameters:

Name Type Description Default
dto dict[str, Any]

Execution payload (same shape as client.executions.get).

required

Raises:

Type Description
NotImplementedError

If type(self) has no tool_key (bare :class:Execution).

ValueError

If the DTO tool.key does not match tool_key.

wait

wait(
    *,
    poll_interval: float = 5.0,
    timeout: float | None = None
) -> dict[str, Any] | None

Block until this execution reaches a terminal state.

Parameters:

Name Type Description Default
poll_interval float

Seconds to sleep between polling cycles.

5.0
timeout float | None

Maximum total seconds to wait. If None, waits indefinitely.

None

Returns:

Type Description
dict[str, Any] | None

The latest execution DTO, or None if the platform returned no DTO.

Raises:

Type Description
ValueError

If this instance has no execution id yet.

TimeoutError

If timeout elapses before the execution terminates.