Public API¶
adaptivepy ¶
AdaptivePy: adaptive sampling for molecular dynamics trajectories.
run_adaptive_sampling ¶
run_adaptive_sampling(config_path: str | Path, config: Optional[RunConfig] = None) -> Dict[str, List[SeedResult]]
Execute a full adaptive sampling run from a YAML configuration.
Workflow
- Load features (and optionally validate trajectories).
- Cluster the concatenated feature matrix.
- Compute cluster statistics.
- Apply each configured policy and select seed frames.
- Write metadata, assignments, model, and optional PDBs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str or Path
|
Path to the YAML configuration file. |
required |
config
|
RunConfig or None
|
Pre-parsed configuration. If |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping from policy name to lists of :class: |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If required input paths do not exist. |
ValueError
|
If validation checks fail. |
api ¶
High-level API orchestrating the adaptive sampling workflow.
run_adaptive_sampling ¶
run_adaptive_sampling(config_path: str | Path, config: Optional[RunConfig] = None) -> Dict[str, List[SeedResult]]
Execute a full adaptive sampling run from a YAML configuration.
Workflow
- Load features (and optionally validate trajectories).
- Cluster the concatenated feature matrix.
- Compute cluster statistics.
- Apply each configured policy and select seed frames.
- Write metadata, assignments, model, and optional PDBs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str or Path
|
Path to the YAML configuration file. |
required |
config
|
RunConfig or None
|
Pre-parsed configuration. If |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping from policy name to lists of :class: |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If required input paths do not exist. |
ValueError
|
If validation checks fail. |
validate_config ¶
Validate a configuration file and input data without running clustering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str or Path
|
Path to the YAML configuration file. |
required |
Returns:
| Type | Description |
|---|---|
RunConfig
|
Parsed configuration if validation succeeds. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If validation fails. |
models ¶
Core data models for AdaptivePy.
FrameRecord
dataclass
¶
FrameRecord(traj_id: int, frame_id: int, features: ndarray, cluster_id: Optional[int] = None, global_index: Optional[int] = None)
A single frame tracked through the adaptive sampling pipeline.
Attributes:
| Name | Type | Description |
|---|---|---|
traj_id |
int
|
Index of the source trajectory. |
frame_id |
int
|
Frame index within the source trajectory. |
features |
ndarray
|
Feature vector for this frame, shape |
cluster_id |
int or None
|
Assigned cluster label after clustering. |
global_index |
int or None
|
Row index in the concatenated feature matrix. |
Dataset
dataclass
¶
Dataset(frames: List[FrameRecord] = list(), feature_matrix: Optional[ndarray] = None, traj_index_map: Dict[int, tuple[int, int]] = dict(), traj_names: List[str] = list())
Internal representation of loaded trajectory features.
Attributes:
| Name | Type | Description |
|---|---|---|
frames |
list of FrameRecord
|
One record per frame across all trajectories. |
feature_matrix |
ndarray
|
Concatenated features, shape |
traj_index_map |
dict
|
Maps |
traj_names |
list of str
|
Basenames of feature files (without extension), e.g. |
SeedResult
dataclass
¶
SeedResult(seed_id: int, policy: str, traj_id: int, frame_id: int, cluster_id: Optional[int], global_index: int)
A selected seed frame produced by a policy.
Attributes:
| Name | Type | Description |
|---|---|---|
seed_id |
int
|
Sequential identifier within a policy run. |
policy |
str
|
Name of the policy that selected this seed. |
traj_id |
int
|
Source trajectory index. |
frame_id |
int
|
Frame index within the source trajectory. |
cluster_id |
int or None
|
Cluster from which the seed was drawn, or |
global_index |
int
|
Row index in the concatenated feature matrix. |