deeporigin.drug_discovery.protein_prep¶
ProteinPrep drives deeporigin.protein-prep v10. Recommend inventories
components, returns a component table (pandas.DataFrame), and updates the same
object with an editable Selection. Prepare applies resolved keep/skip decisions
and cleans the structure. run() blocks on served prepare (including loop
modelling); find_pockets="novel" requires start() (workflow path).
Pocket-bearing runs support quote / approve_amount and confirm().
Structure reports are not part of this tool — use StructureReport.
Recommend settings and prepare a protein with one mutable configuration.
ProteinPrep is the sole public preparation session. It uses
deeporigin.protein-prep v10 for :meth:recommend and all :meth:run /
:meth:start prepare paths. Extracting a ligand also requests one crystal-ligand
Pocket per extract (find_pockets=from-crystal-ligand). Novel pockets use the
platform workflow path; use :meth:start (not blocking :meth:run) for those.
Set :attr:find_pockets to "novel" or "from-crystal-ligand" to include
pockets in prepare. :meth:get_results returns the prepared
:class:~deeporigin.drug_discovery.structures.protein.Protein; use
:meth:get_pockets and :meth:get_crystal_poses for other prepare artifacts.
Structure reports are out of band — use :class:~deeporigin.drug_discovery.structure_report.StructureReport.
Usage::
prep = ProteinPrep(protein)
prep.recommend()
prep.keep(kind="water")
prep.skip(decision="review")
prep.model_missing_loops = False
prepared = prep.run()
Attributes¶
ProteinPrepFindPockets
module-attribute
¶
ProteinPrepFindPockets = Literal[
"no", "from-crystal-ligand", "novel"
]
Classes¶
ProteinPrep
¶
Bases: Execution, SyncExecutableMixin, AsyncExecutableMixin, NotebookWatchMixin
Recommend settings and prepare a protein.
All operations use deeporigin.protein-prep (v10). Blocking :meth:run
supports served prepare including loop modelling. Novel pocket finding uses
the platform workflow path — use :meth:start (with quote /
approve_amount when pockets are billable). Structure reports are not
produced by this tool; use :class:~deeporigin.drug_discovery.structure_report.StructureReport.
Attributes:
| Name | Type | Description |
|---|---|---|
protein |
Protein
|
Constructor-only input protein structure. |
pdb_id |
str | None
|
Mutable 4-character PDB ID for loop-modelling templates. |
selection |
dict[str, Any] | None
|
Editable keep/review/skip/extract map. Reads return a copy. |
recommendation |
DataFrame | None
|
Component table as a :class: |
recommendation_payload |
dict[str, Any] | None
|
Deep copy of analyzer JSON, or |
model_missing_loops |
bool
|
Whether prepare models missing loops. |
pocket |
bool
|
Optional Pocket Finder settings. |
Attributes¶
USER_LOG_COLUMNS
class-attribute
¶
USER_LOG_COLUMNS: list[str] = [
"log_level",
"tool_key",
"timestamp",
"message",
]
box_geometry
property
writable
¶
box_geometry: BoxGeometry | None
Crystal-ligand box geometry when :attr:find_pockets is crystal mode.
box_padding
property
writable
¶
box_padding: float | None
Padding for ligand-extents crystal-ligand boxes.
component_id
property
writable
¶
component_id: str | None
Component id for find_pockets='from-crystal-ligand'.
cost
property
¶
cost: float | None
Actual cost in dollars, set after execution completes.
This property cannot be set manually.
crystal_ligand
property
writable
¶
crystal_ligand: Ligand | None
External ligand file for find_pockets='from-crystal-ligand'.
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.
find_pockets
property
writable
¶
find_pockets: ProteinPrepFindPockets
Whether prepare runs Pocket Finder (no, from-crystal-ligand, novel).
Infers from-crystal-ligand when the Selection extracts a ligand and
pocket mode has not been set explicitly.
ligand_id
property
writable
¶
ligand_id: str | None
In-structure ligand code for find_pockets='from-crystal-ligand'.
model_missing_loops
property
writable
¶
model_missing_loops: bool
Whether prepare will run loop modelling (unused for recommend).
pdb_id
property
writable
¶
pdb_id: str | None
4-character PDB ID used for loop-modelling templates, if set.
pocket_min_size
property
writable
¶
pocket_min_size: float
Minimum pocket size when :attr:find_pockets is "novel".
pocket_radius
property
writable
¶
pocket_radius: float | None
Half-edge for fixed-radius crystal-ligand boxes.
protein
property
¶
protein: Protein
Constructor-only protein used for recommendation and preparation.
recommendation
property
¶
recommendation: DataFrame | None
Component table, or None when analyzer evidence is missing.
recommendation_payload
property
¶
recommendation_payload: dict[str, Any] | None
Deep copy of the analyzer recommendation payload.
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.
selection
property
writable
¶
selection: dict[str, Any] | None
Editable Selection copy, or None before recommendation.
Methods:¶
cancel
¶
cancel() -> None
Cancel a running or queued execution.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the job has no execution ID. |
ValueError
|
If the job is not in a cancellable state. |
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
|
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. |
extract
¶
extract(
component_ids: (
str | Iterable[str] | DataFrame | None
) = None,
*,
kind: str | None = None,
subtype: str | None = None,
decision: str | None = None
) -> Self
Mark matching ligand Selection components to extract.
Same calling styles as :meth:keep. Non-ligand ids raise
:class:ValueError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_ids
|
str | Iterable[str] | DataFrame | None
|
Component ids to extract. |
None
|
kind
|
str | None
|
Extract every ligand Component of this kind (typically
|
None
|
subtype
|
str | None
|
Extract every Component of this subtype. |
None
|
decision
|
str | None
|
Extract every Component with this live Decision. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
This |
Self
|
class: |
from_dto
classmethod
¶
from_dto(
dto: dict[str, Any],
*,
client: DeepOriginClient | None = None
) -> Self
Construct a ProteinPrep from a tools execution DTO.
Rehydrates protein-prep recommendation and preparation executions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any]
|
Execution payload (same shape as |
required |
client
|
DeepOriginClient | None
|
Optional API client. Uses the default if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A |
Self
|
set. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If stored inputs are missing |
from_id
classmethod
¶
from_id(
id: str, *, client: DeepOriginClient | None = None
) -> Self
Construct from a protein-prep execution id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Platform execution ID. |
required |
client
|
DeepOriginClient | None
|
Optional API client. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Rehydrated |
Self
|
class: |
from_last_run
classmethod
¶
from_last_run(
*, client: DeepOriginClient | None = None
) -> Self
Return the newest protein-prep execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
DeepOriginClient | None
|
Optional API client. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Rehydrated |
Self
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no protein-prep executions exist. |
get_crystal_poses
¶
get_crystal_poses(
dto: dict[str, Any] | None = None,
) -> PoseSet | None
Return crystal poses extracted during prepare when extract was selected.
Tries result-explorer rows (result_type=pose), then
jobOutputs.poses. Rows use the Protein Prep Pose shape
(origin: cocrystal, prepared protein_id, ligand_id,
file_path, component_id). Coordinates are not downloaded;
call :meth:~deeporigin.drug_discovery.structures.pose.Pose.download
on individual poses when needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any] | None
|
Optional execution payload used as a job-output fallback. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
PoseSet | None
|
class: |
PoseSet | None
|
crystal poses, an empty set when prepare completed with none, or |
|
PoseSet | None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If :attr: |
DeepOriginException
|
If this was a recommend-only run. |
get_pockets
¶
get_pockets(
dto: dict[str, Any] | None = None,
) -> list[Pocket] | None
Return Pocket Finder results when this run requested pockets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any] | None
|
Optional execution payload used as a job-output fallback. |
None
|
Returns:
| Type | Description |
|---|---|
list[Pocket] | None
|
Pocket list (possibly empty for a valid zero-pocket result), or |
list[Pocket] | None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If :attr: |
get_results
¶
get_results(dto: dict[str, Any] | None = None) -> Protein
Load the prepared protein as an in-memory :class:Protein.
Works for either routed tool key. Tries result-explorer rows
(result_type=preparedprotein), then jobOutputs.protein.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any] | None
|
Optional execution payload. Passing it avoids an extra GET
when the result-explorer path fails but |
None
|
Returns:
| Type | Description |
|---|---|
Protein
|
An in-memory :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :attr: |
DeepOriginException
|
If this was a recommend run, or no prepared protein could be loaded. |
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 |
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 |
DataFrame | None
|
and |
DataFrame | None
|
|
DataFrame | None
|
if this instance has no execution id yet or the client has no |
DataFrame | None
|
|
keep
¶
keep(
component_ids: (
str | Iterable[str] | DataFrame | None
) = None,
*,
kind: str | None = None,
subtype: str | None = None,
decision: str | None = None
) -> Self
Mark matching Selection components to keep.
Pass ids (a string, iterable, or DataFrame id column) or
keyword matchers, not both. kind="water" is equivalent to
passing every water component id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_ids
|
str | Iterable[str] | DataFrame | None
|
Component ids to keep. |
None
|
kind
|
str | None
|
Keep every Component of this kind. |
None
|
subtype
|
str | None
|
Keep every Component of this subtype. |
None
|
decision
|
str | None
|
Keep every Component with this live Decision. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
This |
Self
|
class: |
list
classmethod
¶
List protein-prep executions for this session type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
DeepOriginClient | None
|
Optional API client. |
None
|
status
|
list[str] | None
|
Optional status filter on hydrated instances. |
None
|
Returns:
| Type | Description |
|---|---|
list[Self]
|
Instances for |
recommend
¶
recommend() -> DataFrame
Recommend settings into this object without binding an execution ID.
Always uses direct deeporigin.protein-prep. The platform operation
is synchronous and persisted by the backend, but its execution ID is
deliberately not copied onto this object. Repeated calls atomically
replace :attr:recommendation and :attr:selection only after a
complete recommendation is available.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Component inventory table for this structure. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If this object is already bound to prepare. |
DeepOriginException
|
If recommendation output is unavailable. |
run
¶
run(
*,
quote: bool = False,
approve_amount: int | None = None
) -> Protein | None
Execute served prepare synchronously (blocking).
Valid for loops on or off when :attr:find_pockets is not "novel".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quote
|
bool
|
Shorthand for :data: |
False
|
approve_amount
|
int | None
|
Optional spend cap (usually omitted on this path). |
None
|
Returns:
| Type | Description |
|---|---|
Protein | None
|
An in-memory prepared :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If already submitted or this is not the direct path. |
DeepOriginException
|
If no prepared PDB path could be loaded. |
show
¶
show() -> None
Display the current execution in Jupyter using the execution card HTML view.
If no platform execution ID exists yet, shows the same card with a short notice
instead of raising (see :meth:~deeporigin.platform.execution_display.ExecutionDisplay.from_pending).
skip
¶
skip(
component_ids: (
str | Iterable[str] | DataFrame | None
) = None,
*,
kind: str | None = None,
subtype: str | None = None,
decision: str | None = None
) -> Self
Mark matching Selection components to skip.
Same calling styles as :meth:keep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_ids
|
str | Iterable[str] | DataFrame | None
|
Component ids to skip. |
None
|
kind
|
str | None
|
Skip every Component of this kind. |
None
|
subtype
|
str | None
|
Skip every Component of this subtype. |
None
|
decision
|
str | None
|
Skip every Component with this live Decision. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
This |
Self
|
class: |
start
¶
start(
*,
quote: bool = False,
approve_amount: int | None = None,
**kwargs
) -> None
Submit a persisted async execution to the platform.
Only valid when status is None (no execution exists yet).
All other statuses raise immediately to prevent re-submission.
Pass quote=True or approve_amount=-1 to request a cost estimate
without running. If the platform returns a Quoted DTO the instance
is left in that state — call :meth:~deeporigin.drug_discovery.execution.Execution.confirm
explicitly to proceed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quote
|
bool
|
Shorthand for |
False
|
approve_amount
|
int | None
|
Spend cap passed to the platform as |
None
|
**kwargs
|
Forwarded verbatim to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the current status is not |
stop_watching
¶
stop_watching() -> None
Cancel an in-flight watch loop if one is running.
Safe to call when no watch is active. Does not cancel the caller's current task when invoked from inside the watch loop.
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.
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 |
ValueError
|
If the returned DTO |
update_from_dto
¶
update_from_dto(dto: dict[str, Any]) -> None
Apply tools execution fields from a protein-prep execution DTO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any]
|
Execution payload (same shape as |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the DTO tool key is not |
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
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The latest execution DTO, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this instance has no execution id yet. |
TimeoutError
|
If |
watch
async
¶
watch(
*, interval: float = 5.0, blocking: bool = False
) -> Task | None
Start live notebook updates; optionally block until the job finishes.
By default, awaiting this coroutine finishes in one event-loop turn, so the cell returns while the display keeps updating in the background. Use this when you need to run other cells while the job runs::
task = await abfe.watch()
Set blocking=True or export JOB_WATCH_BLOCK=1 (truthy values:
1, true, yes, on) to run the poll loop inline so the cell
does not return until a terminal state — useful for nbconvert --execute
and doc CI (see :data:~deeporigin.utils.constants.JOB_WATCH_BLOCK_ENV)::
await abfe.watch(blocking=True)
# or: export JOB_WATCH_BLOCK=1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interval
|
float
|
Seconds between polls. |
5.0
|
blocking
|
bool
|
When True, await the watch loop instead of returning a
background task. Also blocks when |
False
|
Returns:
| Type | Description |
|---|---|
Task | None
|
The background task when not blocking; |
Task | None
|
Cancel a background watch with :meth: |