API reference¶
The reference below is generated directly from the current Python sources. Names beginning with an underscore are implementation details.
Runtime¶
AMDockVSRuntime
¶
AMDockVSRuntime()
Bases: AppRuntime
Public AMDockVS runtime on top of the stable MolSuite API.
Methods:
| Name | Description |
|---|---|
general_ligand_count |
How many screening ligands are rows here — what the importer asks before offering |
set_forced_dependencies |
Workflow channel: ids the NEXT submit_job call(s) must also depend on. Lets the |
submit_job |
Submit a job, auto-waiting for active prerequisite jobs by default. |
job_destinations |
|
resume_job |
Continue a job that was canceled or interrupted, on |
resolve_job_dependencies |
Union of explicit depends_on and the ids of active jobs this one should wait for. |
wait_for_job |
Block until the job has ended. |
watch_job |
Display tqdm progress in a terminal or notebook and return the job status. |
watch_jobs |
Display concurrent tqdm progress for several jobs of this session. |
run_destinations |
Where a job may be sent now, as (executor_name, label): the executors that are |
Attributes:
| Name | Type | Description |
|---|---|---|
tools |
ToolAPI
|
Optional external programs managed by AMDockVS. |
shards |
ShardAPI
|
Access registered shard containers without wrapping their records. |
ligands_store |
The row tools' view of the library. The shard tools build their own store. |
|
mode |
str
|
Where the screening library lives, read off the data ( |
workflow |
The single active workflow (a WorkflowRunner). Panels add steps to this shared |
Source code in src/amdockvs/runtime.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
shards
property
¶
shards: ShardAPI
Access registered shard containers without wrapping their records.
ligands_store
property
¶
ligands_store
The row tools' view of the library. The shard tools build their own store.
mode
property
¶
mode: str
Where the screening library lives, read off the data (vs = rows, htpvs = shards).
Not stored anywhere: a project becomes a campaign by holding shards, not by having been declared one before it held anything.
workflow
property
¶
workflow
The single active workflow (a WorkflowRunner). Panels add steps to this shared instance via runtime.workflow.add_step(...); it persists for the session.
general_ligand_count
¶
general_ligand_count() -> int
How many screening ligands are rows here — what the importer asks before offering to shard, since the two libraries cannot coexist.
Source code in src/amdockvs/runtime.py
299 300 301 302 303 | |
set_forced_dependencies
¶
set_forced_dependencies(job_ids: Optional[list[str]]) -> None
Workflow channel: ids the NEXT submit_job call(s) must also depend on. Lets the orchestrator inject same-category serialization that the category auto-deps don't cover, without every submit API needing a depends_on parameter. Cleared by passing None.
Source code in src/amdockvs/runtime.py
376 377 378 379 380 | |
submit_job
¶
submit_job(job, *, params: Any = None, executor_name: Optional[str] = None, cpu_required: Optional[int] = None, max_job_cpu: Optional[int] = None, max_inflight_tasks: Optional[int] = None, total_chunks: Optional[int] = None, depends_on: Optional[list[str]] = None, priority: int = 0, result_handler_kwargs: Optional[dict] = None, auto_depends: bool = True) -> str
Submit a job, auto-waiting for active prerequisite jobs by default.
With auto_depends=True (default) the job is held until every active job of its prerequisite categories finishes, so a deferred pipeline can be queued at once. Pass auto_depends=False to submit immediately regardless of running jobs. Returns the key of the job in the project's journal, which is its id everywhere here.
Source code in src/amdockvs/runtime.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
job_destinations
¶
job_destinations(job_id: str) -> list[tuple[str, str]]
run_destinations for a job on record: where it may be continued now. Nowhere for one
that cannot be submitted again.
Source code in src/amdockvs/runtime.py
460 461 462 463 464 465 466 | |
resume_job
¶
resume_job(job_id: str, executor_name: Optional[str] = None) -> str
Continue a job that was canceled or interrupted, on executor_name or where it was.
A job that is still running is canceled first and waited for, which is how it is moved to another executor: not from a thread that cannot wait. It waits for the jobs its kind waits for, as when it was submitted.
Source code in src/amdockvs/runtime.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
resolve_job_dependencies
¶
resolve_job_dependencies(job, explicit: Optional[list[str]] = None) -> Optional[list[str]]
Union of explicit depends_on and the ids of active jobs this one should wait for.
Source code in src/amdockvs/runtime.py
492 493 494 495 496 497 498 499 500 501 502 503 | |
wait_for_job
¶
wait_for_job(job_id: str, *, poll_s: float = 0.2) -> JobStatus
Block until the job has ended. poll_s is not used: the engine tells.
Source code in src/amdockvs/runtime.py
518 519 520 521 522 523 524 525 526 527 | |
watch_job
¶
watch_job(job_id: str, *, poll_s: float = 0.2) -> JobStatus
Display tqdm progress in a terminal or notebook and return the job status.
Source code in src/amdockvs/runtime.py
529 530 531 | |
watch_jobs
¶
watch_jobs(job_ids: Iterable[str], *, poll_s: float = 0.2) -> dict[str, JobStatus]
Display concurrent tqdm progress for several jobs of this session.
Source code in src/amdockvs/runtime.py
533 534 535 536 537 538 539 540 541 | |
run_destinations
¶
run_destinations(job=None) -> list[tuple[str, str]]
Where a job may be sent now, as (executor_name, label): the executors that are
active, the default one first. With job, only the ones that job can run on.
Source code in src/amdockvs/runtime.py
576 577 578 579 580 581 582 583 584 585 586 | |
Molecules¶
api
¶
Classes:
| Name | Description |
|---|---|
MoleculeAPI |
|
MoleculeAPI
dataclass
¶
MoleculeAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
get |
Return one molecule without exposing the project session to callers. |
details |
Load the complete Details-panel projection for a molecule. |
list_sets |
List saved molecule sets newest first. |
resolve_set |
Resolve UI/catalog set values into the public typed set reference. |
sync_set_membership |
Reconcile the denormalized |
scope_clause |
Opaque SmartTable adapter for a public molecule scope. |
evaluate_filter |
Count filter outcomes without mutating molecules. |
apply_filter |
Apply an evaluated filter or persist its matches as a molecule set. |
stream |
Compatibility entry point; prefer iterating the returned Selection. |
library_shape |
|
shard_counts |
Inventory of the sharded library: shards, molecules in them, and how many are prepared. |
get
¶
get(molecule_id: int) -> MoleculeRecord | None
Return one molecule without exposing the project session to callers.
Source code in src/amdockvs/molecules/api.py
99 100 101 102 103 | |
details
¶
details(molecule_id: int) -> Details | None
Load the complete Details-panel projection for a molecule.
Source code in src/amdockvs/molecules/api.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
list_sets
¶
list_sets() -> list[SetRecord]
List saved molecule sets newest first.
Source code in src/amdockvs/molecules/api.py
147 148 149 150 151 | |
resolve_set
¶
resolve_set(source: MoleculeSetRef | SetRecord | int) -> MoleculeSetRef
Resolve UI/catalog set values into the public typed set reference.
Source code in src/amdockvs/molecules/api.py
153 154 155 156 157 158 159 160 161 162 | |
sync_set_membership
¶
sync_set_membership() -> None
Reconcile the denormalized in_set molecule flag.
Source code in src/amdockvs/molecules/api.py
164 165 166 167 | |
scope_clause
¶
scope_clause(scope: MoleculeScope | Selection[Any])
Opaque SmartTable adapter for a public molecule scope.
ORM expressions stay behind the AMDock API; UI callers only pass the returned value to SmartTableView's external-clause hook.
Source code in src/amdockvs/molecules/api.py
169 170 171 172 173 174 175 176 177 178 179 | |
evaluate_filter
¶
evaluate_filter(scope: MoleculeScope | Selection[Any], criteria, *, exclusion_reason_prefix: str = '') -> dict[str, int]
Count filter outcomes without mutating molecules.
Source code in src/amdockvs/molecules/api.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
apply_filter
¶
apply_filter(scope: MoleculeScope | Selection[Any], criteria, *, action: str, reason: str = '', exclusion_reason_prefix: str = '', set_name: str = '') -> tuple[int, int | None]
Apply an evaluated filter or persist its matches as a molecule set.
Source code in src/amdockvs/molecules/api.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
stream
¶
stream(scope: MoleculeScope | Selection[MoleculeRecord] | None = None) -> Iterator[MoleculeRecord]
Compatibility entry point; prefer iterating the returned Selection.
Source code in src/amdockvs/molecules/api.py
280 281 282 283 284 | |
library_shape
¶
library_shape() -> tuple[bool, int]
(the library is sharded, how many ligand rows exist) — two small indexed counts.
What the catalog bar needs to know and the only thing it needs the db for: Shards is there when there are shards, Ligands lights up when there is any ligand row at all.
Source code in src/amdockvs/molecules/api.py
308 309 310 311 312 313 314 315 316 317 318 | |
shard_counts
¶
shard_counts(*, engine: str = 'ad4') -> dict[str, int]
Inventory of the sharded library: shards, molecules in them, and how many are prepared.
Preparation is engine-specific and does not rewrite the chemical inventory.
Source code in src/amdockvs/molecules/api.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
Import¶
LoaderAPI
dataclass
¶
LoaderAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
shard_ligands |
The |
shard_ligands
¶
shard_ligands(files: Iterable[PathLike], *, shard_size: int | None = None, executor_name: str = 'compute', depends_on: list[str] | None = None, molecule_kind: str = 'small_molecule', prefilter: Mapping[str, Any] | None = None) -> list[str]
The htpvs import: split the library into shards, materialize nothing.
Same feed as load_ligands — the byte-span splitter — with the record cap read as
shard size. What changes is the worker: it writes the span back out as a file and
registers a screening_shards row instead of parsing molecules into the project db.
Source code in src/amdockvs/io/api.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
Chemistry¶
ChemistryAPI
dataclass
¶
ChemistryAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
run_ligand_pipeline |
Run several chemistry steps in one pass over the active screening library. |
run_shard_pipeline |
The same steps as |
predict_receptors |
Predict protein structures from sequence with the ESMFold API (thread executor). |
run_ligand_pipeline
¶
run_ligand_pipeline(steps: Sequence[str | tuple[str, dict[str, Any]]], *, ligands: MoleculeSetRef | MoleculeScope | int | None = None, structure_source: str = 'current', batch_size: int = 128, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None, wait: bool = False, shard_state: str = PENDING) -> str | JobStatus
Run several chemistry steps in one pass over the active screening library.
run_ligand_pipeline(["standardize", "protonate", "generate_3d"]) reads and writes every
ligand once; the three single-step jobs read and rewrite the whole library three times.
With no explicit row scope, a sharded library dispatches whole shards automatically.
Passing ligands always selects the row adapter for curated/reference molecules.
ponytail: the single-step methods below validate their own arguments (pH range, method names, tool installs). Here the step params go through as given and the worker raises.
Source code in src/amdockvs/chemistry/api.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
run_shard_pipeline
¶
run_shard_pipeline(steps: Sequence[str | tuple[str, dict[str, Any]]], *, state: str = PENDING, params: dict[str, Any] | None = None, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None, wait: bool = False) -> str | JobStatus
The same steps as run_ligand_pipeline, over the shards of an htpvs project.
One shard per chunk, one file in and one file out. The run writes into a new generation and only switches to it if it finishes, so a crashed run changes nothing and the retry simply starts over from the generation that is still the library.
Source code in src/amdockvs/chemistry/api.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
predict_receptors
¶
predict_receptors(*, receptors: MoleculeSetRef | MoleculeScope | int | None = None, model: str = FAST_MODEL, force: bool = False, depends_on: list[str] | None = None, wait: bool = False) -> str | JobStatus
Predict protein structures from sequence with the ESMFold API (thread executor).
Only proteins without 3D by default; force=True predicts again and repoints current_path
to the new model. The token comes from ESM_API_KEY and is never stored.
Source code in src/amdockvs/chemistry/api.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
Complexes¶
ComplexAPI
dataclass
¶
ComplexAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
details |
Load the complete Details-panel projection for a receptor-ligand pair. |
details
¶
details(complex_ref: ComplexRef | int) -> Details | None
Load the complete Details-panel projection for a receptor-ligand pair.
Source code in src/amdockvs/complexes/api.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
QSAR¶
QSARAPI
dataclass
¶
QSARAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
set_activity |
Create or edit a ligand's activity for an endpoint (activity_type). With |
delete_activity |
Delete a ligand's activities (all, or only for one endpoint). Returns count removed. |
activity_rows |
Activities joined with the ligand name, for the editor table: |
list_endpoints |
Distinct activity endpoints present in the project. |
load_activities |
Bulk-load activities from a CSV/TSV. |
load_activity_matrix |
Load a wide CSV where several columns are each an activity endpoint (e.g. Tox21's 12 |
endpoint_kinds |
{endpoint: 'categorical'|'continuous'} so the model UI can default the task. |
compute_descriptors |
Submit the descriptor job. only_missing=True skips ligands that already have |
compute_fingerprints |
Submit a Morgan-fingerprint job (also fills physchem descriptors as a side effect). |
applicability_domain |
Per-ligand applicability domain by ECFP4 similarity: mean Tanimoto to the k nearest |
correlation_matrix |
Pearson correlation matrix across the descriptor block's features (over the project's |
split_preview |
Train/test label distribution for an endpoint WITHOUT training, so you can see whether the |
train |
Fit a model template from the ligands of |
load_external_model |
Register a pre-built model artifact (a joblib FittedModel) for prediction. No |
roc_curve_points |
(fpr, tpr) ROC points + AUC for a binary classification model. subset 'test' (held-out — |
prediction_rows |
Predictions joined with the ligand name, for the Predictions table: |
cut_predictions |
Use a model's predictions as a filter: keep the ligands at or beyond |
evaluate |
Score a labeled molecule set against a model and return task-appropriate metrics. |
model_subsets |
{ligand_id: 'train'|'test'} for a trained model's split (empty if not recorded). |
atom_contributions |
Per-atom contribution to an ECFP4 model's prediction (StarDrop's "glowing molecule"). |
set_activity
¶
set_activity(*, ligand_id: int, endpoint: str, value: float, unit: str = '', source: str = '', description: str = '', replace: bool = True) -> ActivityRecord
Create or edit a ligand's activity for an endpoint (activity_type). With replace=True (default) it overwrites existing values for that (ligand, endpoint).
Source code in src/amdockvs/qsar/api.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
delete_activity
¶
delete_activity(*, ligand_id: int, endpoint: str | None = None) -> int
Delete a ligand's activities (all, or only for one endpoint). Returns count removed.
Source code in src/amdockvs/qsar/api.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
activity_rows
¶
activity_rows(*, endpoint: str | None = None) -> list[dict[str, Any]]
Activities joined with the ligand name, for the editor table: [{molecule_id, name, value, unit}] ordered by ligand id.
Source code in src/amdockvs/qsar/api.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
list_endpoints
¶
list_endpoints() -> list[str]
Distinct activity endpoints present in the project.
Source code in src/amdockvs/qsar/api.py
328 329 330 331 332 333 334 | |
load_activities
¶
load_activities(file: PathLike, *, endpoint: str, value_key: str = 'value', match_by: str = 'auto', key_column: str | None = None, unit: str = '', unit_key: str | None = None, transform: str | None = None, kind: str = 'continuous', source: str = '', replace: bool = True, delimiter: str | None = None, import_missing: bool = False, executor_name: str = 'compute') -> dict[str, Any]
Bulk-load activities from a CSV/TSV.
match_by: 'auto' (default — prefer InChIKey, then SMILES, then name), 'inchikey', 'smiles' or 'name'. Structural keys match the stored representations (InChIKey is robust to SMILES formatting). transform (e.g. 'pIC50'/'pKi') converts a concentration value+unit to pX = -log10(M) — the modeling endpoint — keeping the raw value in the description. replace=True wipes prior activities for the matched ligands+endpoint first (idempotent reload). import_missing=True first imports (via the real ligand importer) any CSV row whose molecule isn't in the project yet, so a fresh CSV becomes molecules+activities in one call.
Source code in src/amdockvs/qsar/api.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
load_activity_matrix
¶
load_activity_matrix(file: PathLike, *, value_columns: Sequence[str] | None = None, kind: str = 'auto', match_by: str = 'name', key_column: str | None = None, source: str = '', replace: bool = True, delimiter: str | None = None, import_missing: bool = False, executor_name: str = 'compute') -> dict[str, Any]
Load a wide CSV where several columns are each an activity endpoint (e.g. Tox21's 12 assays). value_columns=None auto-picks every column except the structural/name keys. Each column becomes one endpoint (activity_type=column); empty cells are skipped so a sparse assay matrix loads cleanly. kind 'auto' (default) records categorical for 0/1-label columns and continuous otherwise, per column; pass 'categorical'/'continuous' to force it. import_missing=True first imports molecules for rows not yet in the project (one importer pass), then loads every endpoint — turning a raw CSV into molecules+activities in one call.
Source code in src/amdockvs/qsar/api.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
endpoint_kinds
¶
endpoint_kinds() -> dict[str, str]
{endpoint: 'categorical'|'continuous'} so the model UI can default the task.
Source code in src/amdockvs/qsar/api.py
663 664 665 666 667 668 669 670 | |
compute_descriptors
¶
compute_descriptors(*, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, only_missing: bool = True, batch_size: int = 1000, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None, compute_fingerprints: bool = False, fp_radius: int = 2, fp_nbits: int = 2048) -> str
Submit the descriptor job. only_missing=True skips ligands that already have descriptors computed (MoleculeRecord.mw populated). With compute_fingerprints=True it also stores a Morgan fingerprint per ligand, and only_missing then means "lacks that fingerprint" so FPs can be added to already-described ligands.
Source code in src/amdockvs/qsar/api.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
compute_fingerprints
¶
compute_fingerprints(*, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, only_missing: bool = True, radius: int = 2, nbits: int = 2048, batch_size: int = 1000, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None) -> str
Submit a Morgan-fingerprint job (also fills physchem descriptors as a side effect).
Source code in src/amdockvs/qsar/api.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |
applicability_domain
¶
applicability_domain(*, model: QSARModelRef | int, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, k: int = 5, threshold: float = 0.3, fp_radius: int = 2, fp_nbits: int = 2048) -> list[dict[str, Any]]
Per-ligand applicability domain by ECFP4 similarity: mean Tanimoto to the k nearest
training ligands of model; in_domain = that mean >= threshold. Answers "is this
prediction an interpolation or an extrapolation?". Needs Morgan fingerprints computed.
Source code in src/amdockvs/qsar/api.py
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | |
correlation_matrix
¶
correlation_matrix(*, feature_source: str = 'descriptors', molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, corr_threshold: float = 0.95) -> dict[str, Any]
Pearson correlation matrix across the descriptor block's features (over the project's ligands) — the redundancy the training pipeline prunes. feature_source 'descriptors' (14) or 'rdkit2d' (~200); ecfp4 is unsupported (2048 binary bits). Returns {labels, matrix, dropped} where dropped = features the |r|>corr_threshold filter would remove (kept feature listed first).
Source code in src/amdockvs/qsar/api.py
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 | |
split_preview
¶
split_preview(*, endpoint: str, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, split: str = 'scaffold', test_size: float = 0.3, class_threshold: float | None = None, seed: int = 0, bins: int = 10) -> dict[str, Any]
Train/test label distribution for an endpoint WITHOUT training, so you can see whether the
split balances the labels — not just chemical space. Scaffold split keeps whole scaffolds
together but does NOT stratify by class, so an imbalanced endpoint can land most actives on
one side. Returns {task, categories, train[], test[], n_train, n_test, note} — counts per
class (classification) or per value-bin (regression), aligned to categories.
Source code in src/amdockvs/qsar/api.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
train
¶
train(*, endpoint: str, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, algorithm: str = 'linear_regression', task: str = 'regression', feature_names: Sequence[str] | None = None, feature_source: str = 'descriptors', fp_radius: int = 2, fp_nbits: int = 2048, name: str = '', test_size: float = 0.0, split: str = 'random', cv_folds: int = 0, class_threshold: float | None = None, corr_threshold: float = 0.95, y_scramble: int = 0, hyperparams: dict[str, Any] | None = None, seed: int = 0) -> QSARModelRecord
Fit a model template from the ligands of molecule_set that have an activity for
endpoint. feature_source: 'descriptors' (14 physchem columns), 'rdkit2d' (full ~200
RDKit block, computed+cached on first use) or 'ecfp4' (stored Morgan fingerprint). For
descriptor sources the preprocessing (impute→drop zero-variance→drop |r|>corr_threshold→
scale) lives inside the CV pipeline, so scores are leakage-free. split 'scaffold' holds out
whole Bemis-Murcko scaffolds. cv_folds>=2 adds a CV score (Q²/MCC). class_threshold binarizes
a continuous endpoint (active = value >= threshold); leave None for categorical endpoints.
y_scramble>=1 runs that many label-permutation refits (should score ~0; else signal is spurious).
Source code in src/amdockvs/qsar/api.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | |
load_external_model
¶
load_external_model(*, path: PathLike, name: str, endpoint: str = '') -> QSARModelRecord
Register a pre-built model artifact (a joblib FittedModel) for prediction. No training input needed — the artifact already carries features + task.
Source code in src/amdockvs/qsar/api.py
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 | |
roc_curve_points
¶
roc_curve_points(*, model: QSARModelRef | int, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, endpoint: str | None = None, subset: str = 'all') -> dict[str, Any]
(fpr, tpr) ROC points + AUC for a binary classification model. subset 'test' (held-out — the honest predictivity), 'train' (optimistic; the gap to test shows overfitting) or 'all'. Classification-only; needs a probabilistic model and both classes present.
Source code in src/amdockvs/qsar/api.py
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 | |
prediction_rows
¶
prediction_rows(*, model: QSARModelRef | int) -> list[dict[str, Any]]
Predictions joined with the ligand name, for the Predictions table: [{molecule_id, name, value, confidence}] ordered by ligand id. Excluded ligands are left out, as in every other ligand listing.
Source code in src/amdockvs/qsar/api.py
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 | |
cut_predictions
¶
cut_predictions(*, model: QSARModelRef | int, top_n: int | None = None, cutoff: float | None = None, higher_is_better: bool = True, exclude_rest: bool = False, ids_limit: int = 0) -> dict[str, Any]
Use a model's predictions as a filter: keep the ligands at or beyond cutoff (>= when
higher is better, <= otherwise) and, of those, at most the top_n best (ties break by
id). With exclude_rest every other ligand the model scored is marked excluded
(reversible); ligands it could not score, and ligands already excluded, are left alone.
The cut is a subquery over the predictions, so nothing here grows with the library: the
exclusion is one UPDATE and only ids_limit ids ever come back. Returns {"kept": n,
"rest": n, "excluded": how many were marked, "ids": the first ids_limit kept, best first}.
Source code in src/amdockvs/qsar/api.py
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 | |
evaluate
¶
evaluate(*, model: QSARModelRef | int, molecule_set: MoleculeSetRef | MoleculeScope | int | None = None, endpoint: str | None = None) -> dict[str, Any]
Score a labeled molecule set against a model and return task-appropriate metrics.
Source code in src/amdockvs/qsar/api.py
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 | |
model_subsets
¶
model_subsets(*, model: QSARModelRef | int) -> dict[int, str]
{ligand_id: 'train'|'test'} for a trained model's split (empty if not recorded). The lean pipeline has no separate validation set — only train/test.
Source code in src/amdockvs/qsar/api.py
1421 1422 1423 1424 1425 1426 1427 1428 1429 | |
atom_contributions
¶
atom_contributions(*, model: QSARModelRef | int, ligand_id: int) -> dict[str, Any]
Per-atom contribution to an ECFP4 model's prediction (StarDrop's "glowing molecule"). Returns {molblock, weights[per atom], prediction}. ECFP4 models only.
Source code in src/amdockvs/qsar/api.py
1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 | |
Binding sites¶
BindingSiteAPI
dataclass
¶
BindingSiteAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
select |
Build a lazy binding-site selection. |
delete_sites |
Deletes sites by id. The counterpart of prediction being additive. |
save_site |
Saves a site. Without |
suggest_box_from_ligand |
Auto box from a reference ligand: center = its centroid, size = cubic box |
select
¶
select(*, molecule_id: int | None = None, source: str | None = None, run_id: str | None = None, limit: int | None = None) -> Selection[BindingSite]
Build a lazy binding-site selection.
Source code in src/amdockvs/binding_sites/api.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
delete_sites
¶
delete_sites(binding_site_ids: Iterable[int]) -> int
Deletes sites by id. The counterpart of prediction being additive.
Source code in src/amdockvs/binding_sites/api.py
271 272 273 274 275 276 | |
save_site
¶
save_site(*, molecule_id: int, name: str = '', source: str = 'manual', source_ref: str = '', center: tuple[float, float, float], size: tuple[float, float, float], binding_site_id: int | None = None, set_active: bool = False, extra_data: dict[str, Any] | None = None) -> BindingSite
Saves a site. Without binding_site_id it creates a new one; with it, rewrites that one.
Source code in src/amdockvs/binding_sites/api.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
suggest_box_from_ligand
¶
suggest_box_from_ligand(*, ligand_id: int, scale: float | None = None, padding: float | None = None) -> dict[str, Any]
Auto box from a reference ligand: center = its centroid, size = cubic box derived from the ligand's radius of gyration. Returns {center, size, rg}.
scale/padding default to the configured geometry (settings > binding_sites).
Source code in src/amdockvs/binding_sites/api.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
Docking¶
DockingAPI
dataclass
¶
DockingAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
live_campaign_progress |
Current per-receptor totals of what is written. |
recoverable_ranked_runs |
Interrupted top-N campaigns recoverable from completed result shards. |
select_hits |
Select a recomputable Top-N from the durable HTP result dataset. |
recover_ranked_hits |
Materialize the best available N without submitting docking work. |
preparation_summary |
Return total/ready/failed preparation counts for a molecule scope. |
unprepared_molecules_clause |
Opaque SmartTable clause selecting molecules not ready for every engine family. |
prepare_ligand_shards |
|
run_shards |
|
list_box_residues |
Residues with at least one atom inside the receptor's active binding-site box. |
check_receptors |
Receptor-only half of check_required: preparation + grid status, no ligand scan. |
run |
Run docking over the active library, selecting its row or shard adapter. |
ligand_summaries |
(best pose, pose count) per ligand, one page at a time. |
compute_diagrams |
Render 2D interaction diagrams for docking poses as a standalone job. |
diagram_path |
Convention path for a pose's diagram (may not exist yet). |
live_campaign_progress
¶
live_campaign_progress(*, job_ids: list[str] | tuple[str, ...] = ()) -> dict[int, dict[str, int]]
Current per-receptor totals of what is written.
Source code in src/amdockvs/docking/api.py
118 119 120 121 122 123 124 125 126 127 | |
recoverable_ranked_runs
¶
recoverable_ranked_runs() -> list[dict[str, Any]]
Interrupted top-N campaigns recoverable from completed result shards.
Source code in src/amdockvs/docking/api.py
129 130 131 132 133 134 135 | |
select_hits
¶
select_hits(*, run_id: str, protocol_hash: str, filters: dict[str, Any] | None = None, top_n: int) -> list[dict[str, Any]]
Select a recomputable Top-N from the durable HTP result dataset.
Source code in src/amdockvs/docking/api.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
recover_ranked_hits
¶
recover_ranked_hits(*, run_id: str, protocol_hash: str, top_n: int, threshold: float = 0.0) -> dict[str, int]
Materialize the best available N without submitting docking work.
Source code in src/amdockvs/docking/api.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
preparation_summary
¶
preparation_summary(scope: MoleculeScope, *, role_type: str, engine: str = 'ad4') -> dict[str, int]
Return total/ready/failed preparation counts for a molecule scope.
Source code in src/amdockvs/docking/api.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
unprepared_molecules_clause
¶
unprepared_molecules_clause(*, role_type: str, engines: list[str] | tuple[str, ...])
Opaque SmartTable clause selecting molecules not ready for every engine family.
Source code in src/amdockvs/docking/api.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
prepare_ligand_shards
¶
prepare_ligand_shards(*, program: str = key, force: bool = False, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None) -> str
prepare_ligands for a sharded library: the unit of work is a shard, not a row.
No scope argument on purpose — a sharded library has no rows to select from, so the whole inventory is the scope and narrowing it happened at import. One shard is one task.
Source code in src/amdockvs/docking/api.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
run_shards
¶
run_shards(*, program: str = key, receptor_set: MoleculeSetRef | MoleculeScope | int | None = None, hit_threshold: float, hit_cap: int, hit_mode: str = HIT_MODE_THRESHOLD, output_dir: PathLike | None = None, exhaustiveness: int = 8, num_modes: int = 9, box_center: tuple[float, float, float] | None = None, box_size: tuple[float, float, float] | None = None, scoring_function: str = 'vina', vina_backend: str = DEFAULT_VINA_BACKEND, vina_command: str = DEFAULT_VINA_COMMAND, vina_cpu: int = 1, seed: int = 0, spacing: float = 0.375, energy_range: float = 3.0, min_rmsd: float = 1.0, run_id: str | None = None, protocol_metadata: dict | None = None, engine_config: dict[str, Any] | None = None, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None, skip_existing: bool = True, payload: str = PAYLOAD_LIGHT, check_required: bool = True, selected_from_receptor_id: int | None = None, selected_top_n: int | None = None) -> str
run for a sharded library: the campaign, with the gate that makes it end.
No ligand scope — the library is the inventory of prepared shards. hit_threshold and
hit_cap are required, not defaulted: a campaign without them writes back everything it
scored, which is the failure mode htpvs exists to prevent. A dependent off-target
stage sets selected_from_receptor_id; its deferred chunker reads that receptor's
durable Top-N and extracts only those records from the source shards.
Source code in src/amdockvs/docking/api.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
list_box_residues
¶
list_box_residues(*, receptor_id: int, engine: str = 'vina') -> list[dict[str, Any]]
Residues with at least one atom inside the receptor's active binding-site box.
Candidate set for flexible-residue selection — short because the box filters it. Returns [] when there's no active grid or the structure file is unavailable.
Source code in src/amdockvs/docking/api.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | |
check_receptors
¶
check_receptors(*, program: str = key, receptor_set: MoleculeSetRef | MoleculeScope | int | None = None) -> dict[str, Any]
Receptor-only half of check_required: preparation + grid status, no ligand scan.
check_required materializes the full ligand set to report missing ligands; that's the expensive part. The Receptors step only shows receptor prep/grid status, so this skips ligands entirely (receptor sets are small).
Source code in src/amdockvs/docking/api.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | |
run
¶
run(*, program: str = key, ligands: MoleculeSetRef | MoleculeScope | Selection[MoleculeRecord] | int | None = None, receptors: MoleculeSetRef | MoleculeScope | Selection[MoleculeRecord] | int | None = None, ligand_set: MoleculeSetRef | MoleculeScope | int | None = None, receptor_set: MoleculeSetRef | MoleculeScope | int | None = None, output_dir: PathLike | None = None, batch_size: int | None = None, exhaustiveness: int = 8, num_modes: int = 9, box_center: tuple[float, float, float] | None = None, box_size: tuple[float, float, float] | None = None, scoring_function: str = 'vina', vina_backend: str = DEFAULT_VINA_BACKEND, vina_command: str = DEFAULT_VINA_COMMAND, vina_cpu: int = 1, seed: int = 0, spacing: float = 0.375, energy_range: float = 3.0, min_rmsd: float = 1.0, run_id: str | None = None, protocol_metadata: dict | None = None, engine_config: dict[str, Any] | None = None, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None, check_required: bool = True, skip_existing: bool = True, compute_diagram: bool = False, diagram_format: str = 'png', hit_threshold: float | None = None, hit_cap: int = 0, hit_mode: str = HIT_MODE_THRESHOLD, payload: str = PAYLOAD_LIGHT) -> str
Run docking over the active library, selecting its row or shard adapter.
hit_threshold/hit_cap are optional for materialized rows and mandatory for a
sharded library, where returning every scored molecule would defeat the storage model.
Source code in src/amdockvs/docking/api.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | |
ligand_summaries
¶
ligand_summaries(*, limit: int = 200, offset: int = 0, receptor_id: int | None = None, only_completed: bool = False, score_lte: float | None = None, metric_key: str | None = None, metric_lte: float | None = None, metric_gte: float | None = None, metric_filters: list[tuple[str, str, float]] | None = None, protocol_hash: str | None = None, exclude_run_kind: str | None = 'redocking')
(best pose, pose count) per ligand, one page at a time.
Source code in src/amdockvs/docking/api.py
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 | |
compute_diagrams
¶
compute_diagrams(*, result_ids: list[int] | None = None, run_id: str = '', receptor_id: int | None = None, score_lte: float | None = None, pose_rank: int | None = 1, fmt: str = 'png', chunk_size: int = 64, replace_existing: bool = False, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None) -> str
Render 2D interaction diagrams for docking poses as a standalone job.
Files land next to each pose (see diagram.diagram_path_for); nothing
is written to the DB, so re-run with replace_existing=True to refresh.
Source code in src/amdockvs/docking/api.py
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 | |
diagram_path
¶
diagram_path(*, pose_path: str, pose_rank: int = 1, fmt: str = 'png') -> str
Convention path for a pose's diagram (may not exist yet).
Source code in src/amdockvs/docking/api.py
1428 1429 1430 1431 1432 1433 | |
Diversity¶
DiversityAPI
dataclass
¶
DiversityAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
cluster_job |
Submit the clustering job over the DB; results land in |
load_universe |
Load a scope's fingerprint matrix + 2-D projection for the interactive view. Samples a |
cluster_loaded |
Cluster an already-loaded |
analyze |
Convenience: |
scope_count |
How many molecules a scope holds — the cheap count used to route serial vs. parallel |
run_selection |
Cluster the ENTIRE scope (no sampling) and pick representatives — the real 'run the |
register_run_from_sidecar |
Register a finished parallel run as a saved result WITHOUT recomputing anything: the job's |
list_runs |
Persisted clustering runs, newest first: run id, method, cluster/centroid counts. |
pick_representatives |
Choose again what represents each cluster of a finished run. Nothing is clustered |
members_clause |
Opaque SmartTable adapter: the molecules of one cluster, or the run's representatives |
exclude_non_representatives |
Mark every non-representative of a run as excluded (the flag Filter uses; reversible). |
save_selection_as_set |
Persist the chosen representatives as a molecule set (an enrichment set) so the rest of |
molblock_for |
A 2-D-drawable molblock for one molecule (its stored structure file), or None if there's |
save_clustering_result |
Persist an applied clustering as a durable run: the graph points (x, y, molecule_id, |
list_clustering_results |
Saved runs, newest first — for the results table. |
load_clustering_result |
Everything needed to redraw a saved run (graph points + cluster stats + evr) — read the |
cluster_job
¶
cluster_job(*, method: str = 'bitbirch', threshold: float = 0.65, per_cluster: int = 1, molecule_set: MoleculeSetRef | int | None = None, molecule_filters: dict[str, Any] | None = None, fp_radius: int = 2, fp_nbits: int = 2048, with_activity: str = '', cluster_run_id: str = '', num_cpus: int | None = None, executor_name: str = DEFAULT_LOCAL_CPU_EXECUTOR, depends_on: list[str] | None = None) -> str
Submit the clustering job over the DB; results land in clustering_results. Returns
the job id. The run is tagged with cluster_run_id (auto if blank) — read it back with
list_runs / get_run or persist its centroids with save_centroids_as_set.
with_activity (an activity endpoint) narrows the scope to the ligands measured for it.
Each cluster starts with its per_cluster centroid-nearest members as representatives;
pick_representatives chooses again, by any mode, without clustering again.
num_cpus sets the parallelism: >1 runs bblean multiround with that many processes and the
job requests exactly that many CPUs (cpu_required) so mf schedules it correctly. When
None it is derived from the scope size via plan_cpus.
Source code in src/amdockvs/diversity/api.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
load_universe
¶
load_universe(*, molecule_set: MoleculeSetRef | int | None = None, molecule_filters: dict[str, Any] | None = None, fp_radius: int = 2, fp_nbits: int = 2048, sample_limit: int = DEFAULT_SAMPLE_LIMIT, seed: int = 0, basis: Any = None, exclude_ids: Any = None) -> UniverseMatrix
Load a scope's fingerprint matrix + 2-D projection for the interactive view. Samples a
random sample_limit subset (seeded by seed so each preview draws a fresh subset),
skipping exclude_ids (molecules already previewed) so repeated previews cover more of
the space. Projects onto basis when given (a prior preview's fitted PCA axes) so runs
overlay in one comparable space; otherwise fits a new basis and returns it. Heavy (DB read +
PCA); call off the GUI thread. Cheap re-clustering then uses cluster_loaded.
Source code in src/amdockvs/diversity/api.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
cluster_loaded
staticmethod
¶
cluster_loaded(universe: UniverseMatrix, *, method: str = 'bitbirch', per_cluster: int = 1, **method_params: Any) -> AnalysisResult
Cluster an already-loaded UniverseMatrix — the cheap step that re-runs on every knob
change without touching the DB. method_params (threshold, batch_size, …) go straight to
the registered method, so each method's own knobs pass through untouched.
Source code in src/amdockvs/diversity/api.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
analyze
¶
analyze(*, method: str = 'bitbirch', threshold: float = 0.65, per_cluster: int = 1, molecule_set: MoleculeSetRef | int | None = None, molecule_filters: dict[str, Any] | None = None, fp_radius: int = 2, fp_nbits: int = 2048, sample_limit: int = DEFAULT_SAMPLE_LIMIT) -> AnalysisResult
Convenience: load_universe then cluster_loaded in one call (scripting/preview).
Source code in src/amdockvs/diversity/api.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
scope_count
¶
scope_count(*, molecule_set: MoleculeSetRef | int | None = None, molecule_filters: dict[str, Any] | None = None, fp_radius: int = 2, fp_nbits: int = 2048, with_activity: str = '') -> int
How many molecules a scope holds — the cheap count used to route serial vs. parallel (no fingerprint load, no clustering). Reads ids only via the MolSuite query API.
Source code in src/amdockvs/diversity/api.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
run_selection
¶
run_selection(*, method: str = 'bitbirch', per_cluster: int = 1, molecule_set: MoleculeSetRef | int | None = None, molecule_filters: dict[str, Any] | None = None, fp_radius: int = 2, fp_nbits: int = 2048, **method_params: Any) -> dict[str, Any]
Cluster the ENTIRE scope (no sampling) and pick representatives — the real 'run the
selection' behind the interactive Preview. Every molecule's fingerprint is loaded and
clustered (bblean is fast); only the 2-D graph basis is fitted on a random sub-sample and
every point projected onto it (cheap), so the plot scales without the full-N SVD. Returns the
same mapping as cluster_loaded, over the whole scope. Heavy — call off the GUI thread.
Raises if the scope exceeds INLINE_RUN_LIMIT (that needs the parallel job).
Source code in src/amdockvs/diversity/api.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
register_run_from_sidecar
¶
register_run_from_sidecar(cluster_run_id: str, *, method: str, threshold: float, scope_label: str, fp_radius: int = 2, fp_nbits: int = 2048) -> str
Register a finished parallel run as a saved result WITHOUT recomputing anything: the job's
task already wrote the graph sidecar <root>/clustering_runs/<run_id>.parquet (PCA points +
cluster/centroid flags). Read it for the counts + aggregated cluster sizes and insert the
compact ClusteringRun summary pointing at it. No fingerprints, no PCA here.
Source code in src/amdockvs/diversity/api.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
list_runs
¶
list_runs() -> list[dict[str, Any]]
Persisted clustering runs, newest first: run id, method, cluster/centroid counts.
Source code in src/amdockvs/diversity/api.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
pick_representatives
¶
pick_representatives(cluster_run_id: str, *, mode: str = 'centroid', per_cluster: int = 1, fraction: float = 0.1, rank_by: str = '') -> dict[str, int]
Choose again what represents each cluster of a finished run. Nothing is clustered
again: the run already ranks every member, and this only reads that ranking (modes:
see clustering.pick_representatives). rank_by (an activity endpoint) replaces
similarity as what 'extremes' / 'quartiles' / 'proportional' spread over. Rewrites the
run's representative flags; returns {"n_molecules", "n_clusters", "n_reps"}.
ponytail: in-process over the run's columns (~20 B/molecule) and one UPDATE per 900 picks. Make it a job when a run outgrows the tens of millions.
Source code in src/amdockvs/diversity/api.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | |
members_clause
¶
members_clause(cluster_run_id: str, cluster_id: int | None = None)
Opaque SmartTable adapter: the molecules of one cluster, or the run's representatives when no cluster is given. A subquery, so it costs the same for 10 members or 10^6.
Source code in src/amdockvs/diversity/api.py
580 581 582 583 584 585 586 587 588 589 590 | |
exclude_non_representatives
¶
exclude_non_representatives(cluster_run_id: str) -> int
Mark every non-representative of a run as excluded (the flag Filter uses; reversible). Returns how many were marked.
Source code in src/amdockvs/diversity/api.py
592 593 594 595 596 597 598 599 600 601 602 603 604 | |
save_selection_as_set
¶
save_selection_as_set(molecule_ids: Iterable[int], *, name: str) -> MoleculeSetRef
Persist the chosen representatives as a molecule set (an enrichment set) so the rest of the app (docking, filter, export) can target the redundancy-reduced library.
Source code in src/amdockvs/diversity/api.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
molblock_for
¶
molblock_for(molecule_id: int) -> str | None
A 2-D-drawable molblock for one molecule (its stored structure file), or None if there's no usable structure. Best-effort — used by the universe scatter's hover preview.
Source code in src/amdockvs/diversity/api.py
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
save_clustering_result
¶
save_clustering_result(*, points: Iterable[tuple], cluster_stats: list[dict[str, Any]], evr: Iterable[float], method: str, threshold: float, scope_label: str, fp_radius: int = 2, fp_nbits: int = 2048, n_molecules: int | None = None, n_clusters: int | None = None, n_reps: int | None = None) -> str
Persist an applied clustering as a durable run: the graph points (x, y, molecule_id,
cluster_id, is_centroid) to a parquet sidecar, and a compact ClusteringRun row (metadata
+ counts + the sidecar path). Returns the run id. Only the PCA + cluster flags are stored —
fingerprints stay in their table, loaded by id if ever needed. Counts default to what the
points imply; the parallel path passes them explicitly (it saves no graph sidecar yet).
Source code in src/amdockvs/diversity/api.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
list_clustering_results
¶
list_clustering_results() -> list[dict[str, Any]]
Saved runs, newest first — for the results table.
Source code in src/amdockvs/diversity/api.py
692 693 694 695 696 697 698 699 700 701 702 | |
load_clustering_result
¶
load_clustering_result(run_id: str) -> dict[str, Any]
Everything needed to redraw a saved run (graph points + cluster stats + evr) — read the sidecar directly, no re-clustering or PCA recompute.
Source code in src/amdockvs/diversity/api.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
External tools¶
ToolAPI
dataclass
¶
ToolAPI(runtime: Any)
Methods:
| Name | Description |
|---|---|
status |
Return the current readiness of one managed tool, or every tool. |
install |
Install a tool if needed and return its verified status. |
uninstall |
Remove a managed tool from disk. |
repair |
Remove and reinstall a tool whose on-disk installation is suspect. |
status
¶
status(tool_id: str | None = None) -> ToolStatus | tuple[ToolStatus, ...]
Return the current readiness of one managed tool, or every tool.
Source code in src/amdockvs/integrations/api.py
22 23 24 25 26 | |
install
¶
install(tool_id: str) -> ToolStatus
Install a tool if needed and return its verified status.
Source code in src/amdockvs/integrations/api.py
28 29 30 31 32 33 34 35 36 | |
uninstall
¶
uninstall(tool_id: str) -> str
Remove a managed tool from disk.
Source code in src/amdockvs/integrations/api.py
38 39 40 | |
repair
¶
repair(tool_id: str) -> ToolStatus
Remove and reinstall a tool whose on-disk installation is suspect.
Source code in src/amdockvs/integrations/api.py
42 43 44 45 | |