OpenKinetics API Reference¶
This page documents the OpenKinetics API-backed kinetic scorers. The package provides an HTTP client for the OpenKinetics Predictor REST API, a family of dynamically-created scorer classes registered with the Magician plugin system, and helpers for PDB ligand discovery and SMILES resolution.
Architecture¶
The OpenKinetics package is structured as a Magician designer subpackage under REvoDesign.magician.designers.openkinetics/.
openkinetics/
├── __init__.py # Re-exports all public symbols + dynamic scorer classes
├── _client.py # REST API client, config loading, data I/O, result normalisation
├── _models.py # Exception hierarchy, dataclasses, endpoint constants
├── _scorers.py # Abstract base scorer + dynamic subclass creation via _SCORER_SPECS
└── _pdb.py # PDB ligand discovery, SMILES extraction, mutation label helpers
Scorer classes are generated dynamically at import time from the _SCORER_SPECS tuple in _scorers.py. Each spec produces a concrete subclass of OpenKineticsScorerAbstract with a fixed method, prediction_type, and citation key. The __init__.py re-exports these classes by name.
Beyond the core scoring workflow (submit, status, result), the OpenKineticsClient also wraps four additional service endpoints: check_health() (/health/), list_methods() (/methods/), get_status() (/status/{job_id}/), and check_quota() (/quota/). The submit() method accepts optional parameters handle_long_sequences, use_experimental, include_similarity_columns, and canonicalize_substrates.
YAML Configuration¶
The package reads its runtime configuration from config/third_party/scorers/openkinetics_api.yaml:
scorers:
openkinetics:
enabled: false
base_url: "https://predictor.openkinetics.org/api/v1"
default_method: "CataPro"
default_prediction_type: "kcat/Km"
poll_interval_seconds: 3
timeout_seconds: 600
cache_enabled: true
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
bool |
false |
Whether the OpenKinetics scorers are available. |
base_url |
str |
https://predictor.openkinetics.org/api/v1 |
Base URL of the OpenKinetics Predictor API. |
default_method |
str |
CataPro |
Default prediction method. |
default_prediction_type |
str |
kcat/Km |
Default prediction target. |
poll_interval_seconds |
int |
3 |
Seconds between status-poll requests. |
timeout_seconds |
int |
600 |
Maximum overall wall-clock time for a prediction job. |
cache_enabled |
bool |
true |
Whether per-variant SQLite caching is on by default. |
The config is loaded at runtime via load_openkinetics_config().
API Key Configuration¶
The API key is auto-registered by default. OpenKineticsScorerAbstract
defaults auto_register_api_key=True, which triggers automatic key generation
and persistence on first use (see resolve_api_key() below). Manual setup in
environ.yaml is still supported as a fallback and takes precedence if set.
Constants¶
REvoDesign.magician.designers.openkinetics._models.DEFAULT_OPENKINETICS_API_KEY_ENV = 'OPENKINETICS_API_KEY'
module-attribute
¶
REvoDesign.magician.designers.openkinetics._models.OPENKINETICS_ENDPOINTS = {'health': '/health/', 'methods': '/methods/', 'validate': '/validate/', 'submit': '/submit/', 'status': '/status/{job_id}/', 'result': '/result/{job_id}/', 'quota': '/quota/'}
module-attribute
¶
REvoDesign.magician.designers.openkinetics._models.WATER_RESIDUE_NAMES = frozenset({'HOH', 'WAT'})
module-attribute
¶
REvoDesign.magician.designers.openkinetics._models.COFACTOR_EXCLUSIONS = frozenset({'HEM'})
module-attribute
¶
Exception Hierarchy¶
REvoDesign.magician.designers.openkinetics._models.OpenKineticsError
¶
Bases: RuntimeError
Base OpenKinetics integration error.
REvoDesign.magician.designers.openkinetics._models.OpenKineticsConfigurationError
¶
Bases: OpenKineticsError
Raised when required local configuration is missing or invalid.
REvoDesign.magician.designers.openkinetics._models.OpenKineticsAPIError
¶
Bases: OpenKineticsError
Raised for HTTP or remote API failures.
REvoDesign.magician.designers.openkinetics._models.OpenKineticsTimeoutError
¶
Bases: OpenKineticsError
Raised when a remote job does not complete within the timeout.
REvoDesign.magician.designers.openkinetics._models.OpenKineticsValidationError
¶
Bases: OpenKineticsError
Raised when prepared OpenKinetics input data is invalid.
Dataclasses¶
REvoDesign.magician.designers.openkinetics._models.LigandCandidate
dataclass
¶
REvoDesign.magician.designers.openkinetics._models.OpenKineticsFixturePaths
dataclass
¶
Configuration Functions¶
REvoDesign.magician.designers.openkinetics._client.load_openkinetics_config()
¶
Load OpenKinetics config from third_party/scorers/openkinetics_api.yaml.
REvoDesign.magician.designers.openkinetics._client.resolve_api_key(*, api_key=None, auto_register=False, replace_existing=False, base_url=None, timeout_seconds=None, session=None)
¶
Resolve the OpenKinetics API key from various sources in order of preference.
This function attempts to find an OpenKinetics API key from multiple sources: 1. Directly supplied API key parameter 2. Environment variable 3. Auto-registration (if enabled)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Direct API key provided as a parameter. If not provided or empty, other sources will be checked. |
None
|
auto_register
|
bool
|
Whether to automatically register and persist a new API key if no existing key is found. |
False
|
replace_existing
|
bool
|
Whether to replace any existing API key during auto-registration. |
False
|
base_url
|
str | None
|
Base URL for API calls when fetching a new key during auto-registration. |
None
|
timeout_seconds
|
int | None
|
Timeout value for API requests during auto-registration. |
None
|
session
|
Session | None
|
Requests session object for making HTTP requests during auto-registration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The resolved OpenKinetics API key as a string. |
Raises:
| Type | Description |
|---|---|
OpenKineticsConfigurationError
|
If no API key is found and auto_registration is disabled. |
REvoDesign.magician.designers.openkinetics._client.fetch_openkinetics_api_key(*, base_url=None, timeout_seconds=None, session=None, replace_existing=False)
¶
Generate a self-service OpenKinetics API key for the current client IP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str | None
|
The base URL for the OpenKinetics API. If None, uses the configured default. |
None
|
timeout_seconds
|
int | None
|
Request timeout in seconds. If None, uses the configured default. |
None
|
session
|
Session | None
|
Requests session to use for making HTTP requests. If None, creates a new session. |
None
|
replace_existing
|
bool
|
Whether to replace any existing API key if one exists for this IP. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The generated OpenKinetics API key. |
Raises:
| Type | Description |
|---|---|
OpenKineticsAPIError
|
If there's an error during API key generation or communication. |
OpenKineticsConfigurationError
|
If an API key already exists but isn't available locally. |
REvoDesign.magician.designers.openkinetics._client.persist_openkinetics_api_key(api_key)
¶
Persist an OpenKinetics API key and register it for this process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The OpenKinetics API key to persist. Must be a non-empty string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The persisted API key that was passed in. |
Raises:
| Type | Description |
|---|---|
OpenKineticsConfigurationError
|
If the API key is empty or if persistence to environ.yaml fails. |
Data I/O Helpers¶
REvoDesign.magician.designers.openkinetics._client.build_openkinetics_data_rows(variant_rows, substrate_smiles)
¶
Builds OpenKinetics data rows by combining protein sequences from variant rows with a common substrate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variant_rows
|
list[dict[str, str]]
|
A list of dictionaries containing variant data, each with a 'protein_sequence' key |
required |
substrate_smiles
|
str
|
The SMILES string representing the substrate to be used for all entries |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
A list of dictionaries where each dictionary contains 'Protein Sequence' and 'Substrate' keys |
REvoDesign.magician.designers.openkinetics._client.build_openkinetics_request_payload(*, data_rows, method_metadata, method, prediction_type)
¶
REvoDesign.magician.designers.openkinetics._client.get_method_metadata(methods_response, *, method, prediction_type)
¶
Extract metadata for a specific method from the OpenKinetics methods response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
methods_response
|
dict[str, Any]
|
Dictionary containing the methods response from OpenKinetics API |
required |
method
|
str
|
The identifier or display name of the method to find |
required |
prediction_type
|
str
|
The type of prediction to filter methods by |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing the metadata for the requested method |
Raises:
| Type | Description |
|---|---|
OpenKineticsValidationError
|
If the methods response is malformed or the requested method is not found |
REvoDesign.magician.designers.openkinetics._client.write_csv_rows(path, rows)
¶
REvoDesign.magician.designers.openkinetics._client.write_json(path, payload)
¶
REvoDesign.magician.designers.openkinetics._client.sha256_file(path)
¶
REvoDesign.magician.designers.openkinetics._client.write_normalized_scores_csv(path, rows)
¶
REvoDesign.magician.designers.openkinetics._client._normalize_result_rows(result_payload, *, method, prediction_type, substrate_smiles, variant_rows=None, job_id='')
¶
OpenKineticsClient¶
The HTTP client for the OpenKinetics Predictor REST API. Used by both the scoring workflow (OpenKineticsScorerAbstract) and the manual fixture-collection workflow.
REvoDesign.magician.designers.openkinetics._client.OpenKineticsClient
¶
HTTP client for the OpenKinetics Predictor REST API.
Used by both the scoring workflow (OpenKineticsScorerAbstract)
and the manual fixture-collection workflow
(collect_openkinetics_fixture_dataset).
list_methods()
¶
Retrieve a list of available methods from the OpenKinetics API.
This method sends a GET request to the 'methods' endpoint to fetch information about the available methods in the OpenKinetics service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
None
|
This method does not take any parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The response from the OpenKinetics API containing method information. The exact type and structure depends on the API response format. |
validate_file(csv_path, *, run_similarity=False)
¶
Validates a CSV file using the OpenKinetics API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
str | Path
|
Path to the CSV file to be validated |
required |
run_similarity
|
bool
|
Whether to run similarity analysis during validation (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
JSON response from the OpenKinetics API |
Raises:
| Type | Description |
|---|---|
OpenKineticsAPIError
|
If the API request fails or returns an error status code |
validate(rows, *, run_similarity=False)
¶
Validates a list of data rows by normalizing input and processing through temporary CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
list[dict[str, Any]]
|
A list of dictionaries containing protein sequence and substrate information |
required |
run_similarity
|
bool
|
Boolean flag to indicate whether similarity analysis should be performed |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing validation results |
check_health()
¶
Check the OpenKinetics service health endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
self
|
The instance of the class containing this method |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the health status response from the OpenKinetics service |
check_quota()
¶
Check the account quota (daily usage / limit).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
self
|
The instance of the class containing this method |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing quota information including daily usage and limit data |
submit(rows, method, prediction_type, *, handle_long_sequences='truncate', use_experimental=False, include_similarity_columns=True, canonicalize_substrates=True)
¶
Submit a batch of protein sequence and substrate pairs to the OpenKinetics service for prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
self
|
The instance of the class containing this method |
required | |
rows
|
list[dict[str, Any]]
|
A list of dictionaries, each containing 'Protein Sequence' and 'Substrate' keys with corresponding values |
required |
method
|
str
|
The prediction method to be used for the analysis |
required |
prediction_type
|
str
|
The type of prediction to perform |
required |
handle_long_sequences
|
str
|
Strategy for handling long sequences, defaults to "truncate" |
'truncate'
|
use_experimental
|
bool
|
Whether to use experimental features, defaults to False |
False
|
include_similarity_columns
|
bool
|
Whether to include similarity columns in the output, defaults to True |
True
|
canonicalize_substrates
|
bool
|
Whether to canonicalize substrates, defaults to True |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the response from the OpenKinetics service, including job identifier |
Raises:
| Type | Description |
|---|---|
OpenKineticsValidationError
|
If no rows are provided or if the submit response doesn't contain a job identifier |
get_result(job_id, result_format='json', *, poll_interval_seconds=3, timeout_seconds=None)
¶
Retrieves the result of a job from the OpenKinetics API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The unique identifier of the job to retrieve results for |
required |
result_format
|
str
|
Format of the result, either 'json' or 'csv' (default is 'json') |
'json'
|
poll_interval_seconds
|
int
|
Interval in seconds between polling attempts when result is not ready (default is 3) |
3
|
timeout_seconds
|
int | None
|
Maximum time to wait for the result in seconds, None means default timeout (default is None) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | str
|
A dictionary containing the result data if format is JSON, or a string containing CSV data if format is CSV |
Raises:
| Type | Description |
|---|---|
OpenKineticsAPIError
|
If the API request fails or returns an error status |
OpenKineticsTimeoutError
|
If the timeout is exceeded while waiting for the result |
OpenKineticsValidationError
|
If an unsupported result format is specified |
poll_until_complete(job_id, *, poll_interval_seconds=3, timeout_seconds=600)
¶
Polls the job status until completion or timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The identifier of the job to poll |
required |
poll_interval_seconds
|
int
|
Time interval between status checks in seconds (default: 3) |
3
|
timeout_seconds
|
int
|
Maximum time to wait for job completion in seconds (default: 600) |
600
|
Returns:
| Type | Description |
|---|---|
list[Any]
|
A list of status payloads collected during polling |
Raises:
| Type | Description |
|---|---|
OpenKineticsAPIError
|
If the job fails or encounters an error |
OpenKineticsTimeoutError
|
If the timeout is reached before job completion |
PDB / Ligand Functions¶
REvoDesign.magician.designers.openkinetics._pdb.discover_ligand_candidates(pdb_path, excluded_residue_names=WATER_RESIDUE_NAMES | COFACTOR_EXCLUSIONS)
¶
REvoDesign.magician.designers.openkinetics._pdb.choose_primary_ligand(pdb_path)
¶
REvoDesign.magician.designers.openkinetics._pdb.extract_ligand_pdb_block(pdb_path, ligand)
¶
REvoDesign.magician.designers.openkinetics._pdb.smiles_from_ligand_pdb_block(pdb_block)
¶
REvoDesign.magician.designers.openkinetics._pdb._canonicalize_smiles(smiles)
¶
REvoDesign.magician.designers.openkinetics._pdb.resolve_substrate_metadata(pdb_path, structure_id='1SUO')
¶
REvoDesign.magician.designers.openkinetics._pdb.load_chain_sequence_context(pdb_path, chain_id='A')
¶
REvoDesign.magician.designers.openkinetics._pdb.load_mutation_labels(mutation_path, limit=None)
¶
REvoDesign.magician.designers.openkinetics._pdb.relabel_pdb_position_to_sequential(label, residue_numbers, *, chain_id='A')
¶
Convert a PDB-numbered mutation label to its sequential-position equivalent.
Mutation labels like AE93D use PDB residue numbering which may be
non-contiguous. :func:REvoDesign.tools.mutant_tools.extract_mutants_from_mutant_id
expects sequential (1-based) positions, so this helper performs the remapping
using the residue-number list obtained from :func:load_chain_sequence_context.
Scorer Classes¶
OpenKineticsScorerAbstract¶
Base class for all OpenKinetics API-based kinetic scorers. Concrete subclasses fix the method and prediction_type via the abstract built_in_defaults() class method.
REvoDesign.magician.designers.openkinetics._scorers.OpenKineticsScorerAbstract
¶
Bases: ExternalDesignerAbstract, ABC
Base class for OpenKinetics API-based kinetic scorers.
Concrete subclasses fix the method and prediction type via
:meth:built_in_defaults.
built_in_defaults()
abstractmethod
classmethod
¶
Return {"method": ..., "prediction_type": ...}.
Dynamically Created Scorer Subclasses¶
Rather than defining one class per prediction method, _scorers.py declares a _SCORER_SPECS tuple and creates concrete subclasses with type() at import time. Each subclass sets name, prefer_lower, built_in_defaults, and __bibtex__.
The following 19 scorer classes are generated from the spec:
| Class name | Scorer name | Method | Prediction type | Citation key |
|---|---|---|---|---|
CataProKcatScorer |
OpenKinetics-CataPro-kcat |
CataPro | kcat | CataPro |
CatPredKcatScorer |
OpenKinetics-CatPred-kcat |
CatPred | kcat | CatPred |
DLKcatScorer |
OpenKinetics-DLKcat-kcat |
DLKcat | kcat | DLKcat |
EITLEMKcatScorer |
OpenKinetics-EITLEM-kcat |
EITLEM | kcat | EITLEM |
KinFormHKcatScorer |
OpenKinetics-KinForm-H-kcat |
KinForm-H | kcat | KinForm |
KinFormLKcatScorer |
OpenKinetics-KinForm-L-kcat |
KinForm-L | kcat | KinForm |
OmniESIKcatScorer |
OpenKinetics-OmniESI-kcat |
OmniESI | kcat | OmniESI |
RealKcatScorer |
OpenKinetics-RealKcat-kcat |
RealKcat | kcat | RealKcat |
UniKPKcatScorer |
OpenKinetics-UniKP-kcat |
UniKP | kcat | UniKP |
CataProKmScorer |
OpenKinetics-CataPro-Km |
CataPro | Km | CataPro |
CatPredKmScorer |
OpenKinetics-CatPred-Km |
CatPred | Km | CatPred |
EITLEMKmScorer |
OpenKinetics-EITLEM-Km |
EITLEM | Km | EITLEM |
KinFormHKmScorer |
OpenKinetics-KinForm-H-Km |
KinForm-H | Km | KinForm |
MMISAKMKmScorer |
OpenKinetics-MMISA-KM-Km |
MMISA-KM | Km | MMISA-KM |
OmniESIKmScorer |
OpenKinetics-OmniESI-Km |
OmniESI | Km | OmniESI |
RealKcatKmScorer |
OpenKinetics-RealKcat-Km |
RealKcat | Km | RealKcat |
UniKPKmScorer |
OpenKinetics-UniKP-Km |
UniKP | Km | UniKP |
CataProKcatKmScorer |
OpenKinetics-CataPro-kcat/Km |
CataPro | kcat/Km | CataPro |
IECataKcatKmScorer |
OpenKinetics-IECata-kcat/Km |
IECata | kcat/Km | IECata |
Km-targeting scorers set prefer_lower = True (lower scores are better). kcat and kcat/Km scorers set prefer_lower = False (higher scores are better).