pandocklab 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. pandocklab-0.1.0/PKG-INFO +19 -0
  2. pandocklab-0.1.0/README.md +341 -0
  3. pandocklab-0.1.0/pandoc/__init__.py +1 -0
  4. pandocklab-0.1.0/pandoc/agent_conversation.py +386 -0
  5. pandocklab-0.1.0/pandoc/agent_planner.py +108 -0
  6. pandocklab-0.1.0/pandoc/agent_ui.py +569 -0
  7. pandocklab-0.1.0/pandoc/assistant.py +314 -0
  8. pandocklab-0.1.0/pandoc/assistant_tools.py +280 -0
  9. pandocklab-0.1.0/pandoc/batch_review.py +218 -0
  10. pandocklab-0.1.0/pandoc/bulk_ligands.py +154 -0
  11. pandocklab-0.1.0/pandoc/campaign.py +333 -0
  12. pandocklab-0.1.0/pandoc/cli.py +183 -0
  13. pandocklab-0.1.0/pandoc/cli_prepare.py +277 -0
  14. pandocklab-0.1.0/pandoc/cofactor_templates.py +163 -0
  15. pandocklab-0.1.0/pandoc/compute.py +148 -0
  16. pandocklab-0.1.0/pandoc/compute_options.py +54 -0
  17. pandocklab-0.1.0/pandoc/computer_d_compute.py +169 -0
  18. pandocklab-0.1.0/pandoc/computer_e_compute.py +169 -0
  19. pandocklab-0.1.0/pandoc/core.py +683 -0
  20. pandocklab-0.1.0/pandoc/figures.py +113 -0
  21. pandocklab-0.1.0/pandoc/github_action_worker.py +317 -0
  22. pandocklab-0.1.0/pandoc/github_compute.py +421 -0
  23. pandocklab-0.1.0/pandoc/glycans.py +158 -0
  24. pandocklab-0.1.0/pandoc/heme_prep.py +569 -0
  25. pandocklab-0.1.0/pandoc/jobs.py +110 -0
  26. pandocklab-0.1.0/pandoc/kaggle_compute.py +175 -0
  27. pandocklab-0.1.0/pandoc/kaggle_task_worker.py +33 -0
  28. pandocklab-0.1.0/pandoc/ligand_recovery.py +83 -0
  29. pandocklab-0.1.0/pandoc/live_log_bridge.py +136 -0
  30. pandocklab-0.1.0/pandoc/pdb_search.py +130 -0
  31. pandocklab-0.1.0/pandoc/phprep.py +154 -0
  32. pandocklab-0.1.0/pandoc/profile_engine.py +396 -0
  33. pandocklab-0.1.0/pandoc/profile_quality.py +182 -0
  34. pandocklab-0.1.0/pandoc/pubchem_search.py +87 -0
  35. pandocklab-0.1.0/pandoc/structure_checks.py +132 -0
  36. pandocklab-0.1.0/pandoc/structure_view.py +174 -0
  37. pandocklab-0.1.0/pandoc/task_agent.py +635 -0
  38. pandocklab-0.1.0/pandoc/ui.py +146 -0
  39. pandocklab-0.1.0/pandoc/viewer_runtime.py +126 -0
  40. pandocklab-0.1.0/pandoc/worker.py +407 -0
  41. pandocklab-0.1.0/pandocklab/__init__.py +4 -0
  42. pandocklab-0.1.0/pandocklab/cli.py +43 -0
  43. pandocklab-0.1.0/pandocklab/local.py +81 -0
  44. pandocklab-0.1.0/pandocklab.egg-info/PKG-INFO +19 -0
  45. pandocklab-0.1.0/pandocklab.egg-info/SOURCES.txt +87 -0
  46. pandocklab-0.1.0/pandocklab.egg-info/dependency_links.txt +1 -0
  47. pandocklab-0.1.0/pandocklab.egg-info/entry_points.txt +3 -0
  48. pandocklab-0.1.0/pandocklab.egg-info/requires.txt +15 -0
  49. pandocklab-0.1.0/pandocklab.egg-info/top_level.txt +2 -0
  50. pandocklab-0.1.0/pyproject.toml +20 -0
  51. pandocklab-0.1.0/setup.cfg +4 -0
  52. pandocklab-0.1.0/tests/test_5e9c_glycan_smoke.py +52 -0
  53. pandocklab-0.1.0/tests/test_agent_conversation.py +209 -0
  54. pandocklab-0.1.0/tests/test_agent_planner.py +109 -0
  55. pandocklab-0.1.0/tests/test_agent_ui.py +229 -0
  56. pandocklab-0.1.0/tests/test_api.py +131 -0
  57. pandocklab-0.1.0/tests/test_assistant.py +294 -0
  58. pandocklab-0.1.0/tests/test_assistant_tools.py +175 -0
  59. pandocklab-0.1.0/tests/test_bulk_csv_gpu_export.py +59 -0
  60. pandocklab-0.1.0/tests/test_bulk_ligands.py +43 -0
  61. pandocklab-0.1.0/tests/test_ccd_atom_naming.py +37 -0
  62. pandocklab-0.1.0/tests/test_cif_chain_ids.py +91 -0
  63. pandocklab-0.1.0/tests/test_cli_campaign.py +64 -0
  64. pandocklab-0.1.0/tests/test_cli_prepare.py +50 -0
  65. pandocklab-0.1.0/tests/test_cofactor_resolution.py +139 -0
  66. pandocklab-0.1.0/tests/test_compute_options.py +39 -0
  67. pandocklab-0.1.0/tests/test_computer_d_live_progress.py +30 -0
  68. pandocklab-0.1.0/tests/test_core.py +151 -0
  69. pandocklab-0.1.0/tests/test_docking_worker.py +94 -0
  70. pandocklab-0.1.0/tests/test_figures.py +109 -0
  71. pandocklab-0.1.0/tests/test_github_compute.py +41 -0
  72. pandocklab-0.1.0/tests/test_heme_prep.py +187 -0
  73. pandocklab-0.1.0/tests/test_inspection_ui.py +73 -0
  74. pandocklab-0.1.0/tests/test_jobs.py +50 -0
  75. pandocklab-0.1.0/tests/test_ligand_recovery.py +36 -0
  76. pandocklab-0.1.0/tests/test_live_docking_logs.py +124 -0
  77. pandocklab-0.1.0/tests/test_navigation_ui.py +68 -0
  78. pandocklab-0.1.0/tests/test_pdb_search.py +122 -0
  79. pandocklab-0.1.0/tests/test_phprep.py +53 -0
  80. pandocklab-0.1.0/tests/test_preparation_flow_ui.py +60 -0
  81. pandocklab-0.1.0/tests/test_profile_quality.py +169 -0
  82. pandocklab-0.1.0/tests/test_pubchem_search.py +81 -0
  83. pandocklab-0.1.0/tests/test_python_cli.py +43 -0
  84. pandocklab-0.1.0/tests/test_structure_checks.py +87 -0
  85. pandocklab-0.1.0/tests/test_structure_view.py +177 -0
  86. pandocklab-0.1.0/tests/test_task_agent.py +293 -0
  87. pandocklab-0.1.0/tests/test_terminal_templates.py +26 -0
  88. pandocklab-0.1.0/tests/test_theme_contrast.py +65 -0
  89. pandocklab-0.1.0/tests/test_workflow.py +71 -0
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: pandocklab
3
+ Version: 0.1.0
4
+ Summary: PanDockLab molecular docking Python and command-line interface
5
+ Project-URL: Repository, https://github.com/peterDataScientia/PanDoc
6
+ Requires-Python: <3.13,>=3.11
7
+ Requires-Dist: numpy<3,>=1.26
8
+ Requires-Dist: rdkit<2027,>=2024.9
9
+ Requires-Dist: meeko==0.8.0
10
+ Requires-Dist: vina==1.2.7; platform_system != "Windows"
11
+ Requires-Dist: gemmi<1,>=0.6
12
+ Requires-Dist: scipy<2,>=1.12
13
+ Requires-Dist: pdbfixer==1.12.0
14
+ Requires-Dist: openmm<9,>=8.2
15
+ Requires-Dist: propka<4,>=3.5
16
+ Requires-Dist: molscrub==0.3.0
17
+ Requires-Dist: joblib<2,>=1.3
18
+ Requires-Dist: requests<3,>=2.31
19
+ Requires-Dist: pandas<4,>=2.2
@@ -0,0 +1,341 @@
1
+ # PanDockLab
2
+
3
+ **Formerly PanDoc.** PanDockLab is the public name of this chemistry-aware molecular docking workbench. The repository currently retains the established `peterDataScientia/PanDoc` URL, and the internal `pandoc` Python package, `PANDOC_*` environment variables, legacy archive paths and data folders remain unchanged for compatibility. The Windows desktop rebrand is being tested separately in the `feature/windows-desktop-installer` branch.
4
+
5
+ A guided Streamlit workbench for receptor inspection, Meeko preparation, crystallographic-ligand redocking and AutoDock Vina docking experiments.
6
+
7
+ ## Run locally
8
+
9
+ Use Python 3.11 on Linux (recommended), macOS or Windows with WSL2.
10
+
11
+ ```bash
12
+ python -m venv .venv
13
+ source .venv/bin/activate
14
+ pip install -r requirements.txt
15
+ streamlit run app.py
16
+ ```
17
+
18
+ PDBFixer and OpenMM are included in the main requirements. Heavy-atom reconstruction is available by checking the repair option during receptor preparation; it is not run automatically.
19
+
20
+ Docker:
21
+
22
+ ```bash
23
+ docker build -t pandocklab .
24
+ docker run --rm -p 8501:8501 pandocklab
25
+ ```
26
+
27
+ Streamlit Community Cloud: select this repository, `main`, `app.py`, and Python 3.11. Docking uses server CPU resources; start with small batches. Meeko and Vina versions are pinned. A server with a container and persistent storage is preferable for longer computations.
28
+
29
+
30
+ ### Deployment error: Vina / Boost on Python 3.14
31
+
32
+ If logs show Python 3.14 and `Boost library location was not found`, the installer is attempting to compile Vina because that runtime has no compatible prebuilt Vina 1.2.7 wheel. Deploy with **Python 3.11** instead. Adding a `runtime.txt` does not change an existing Community Cloud app's Python interpreter.
33
+
34
+ Community Cloud requires deleting and redeploying an existing app to change Python. Preserve your app settings and any secrets first, then redeploy with repository `peterDataScientia/PanDoc`, branch `main`, entrypoint `app.py`, and custom subdomain `pandoc`. In **Advanced settings**, explicitly select **Python 3.11** before clicking Deploy. Restarting the Python 3.14 app will not change its interpreter.
35
+
36
+ The requirements file now requires a prebuilt Vina wheel so unsupported runtimes fail clearly rather than starting a C++ build. A Linux CPython 3.11 wheel is available and has been verified. This guard does not itself change the cloud runtime.
37
+
38
+ Official guidance: https://docs.streamlit.io/deploy/streamlit-community-cloud/manage-your-app/upgrade-python
39
+
40
+ ## Workflow
41
+
42
+ 1. Upload PDB/mmCIF. Select protein chains, retained components and reference ligand. Choose alternate conformations per residue.
43
+ 2. Prepare the receptor with PDBFixer, PROPKA and Meeko. Optionally upload a curated receptor or reconstruct missing heavy atoms using PDBFixer, then run PROPKA at the selected preparation pH to obtain structure-dependent residue pKa predictions. PanDockLab presents proposed residue states for review, flags residues near their predicted pKa, and requires explicit HID/HIE selection for neutral histidines before passing reviewed template assignments to Meeko. No blanket deletion of failed residues and no automatic missing-loop reconstruction.
44
+ 3. Click **Find ligand chemistry from PDB** in the Reference ligand tab to retrieve the selected component's CCD SMILES, name, formula and formal charge. Review the molecular preview and side-by-side atom comparison. Manual SMILES entry remains editable. At the receptor preparation pH, PanDockLab can use Molscrub to enumerate ligand protonation/tautomer microstates; review and select the intended state before preparation. Mismatches show clear actions and block preparation; deposited atom-name comparisons can identify absent atoms when naming is consistent. Custom residue names may require manual chemistry. Bond orders are assigned to extracted crystal coordinates; CCD ideal coordinates never replace the crystal reference. Click **Continue to Validate docking**.
45
+ 4. Define a box, redock across seeds and inspect reference RMSD. RMSD uses RDKit CalcRMS, heavy atoms and symmetry handling in the fixed receptor coordinate frame. No independent ligand alignment is performed.
46
+ 5. Prepare candidate ligands from multi-record SDF or SMILES. By default, PanDockLab can enumerate pH-dependent protonation/tautomer microstates with Molscrub at the receptor preparation pH; review the generated states before docking. A maximum of 25 prepared ligand states is accepted per run. Run Vina jobs in a separate process, inspect poses and scores, and export the complete experiment.
47
+
48
+ ## Practical receptor quality gates
49
+
50
+ Reviewed profiles now distinguish **critical preparation errors** from
51
+ **documented limitations**. A valid receptor with only warnings is
52
+ `ready_with_warnings`, not an automatic failure. For example, the distant
53
+ AR 2AMA chain discontinuity and an audited PGR 1A28 A:932 Meeko fallback
54
+ remain visible as limitations, while severe overlaps, near-site deletions,
55
+ missing PDBQT, nonfinite charges or missing HEM/Fe atom-preservation audits
56
+ block preparation. CYP19A1 iron parameterization/metal-scoring uncertainty is
57
+ disclosed as a review warning, **not** silently certified.
58
+
59
+ A successful preparation is only **ready to attempt redocking**, never
60
+ automatically publication-validated. Redock each reference ligand (FYN H8H,
61
+ AR DHT, PGR STR, CYP19A1 ASD), inspect symmetry-aware RMSD and poses, then
62
+ decide whether the protocol is suitable for production docking.
63
+
64
+ Every reviewed-profile ZIP now includes `PROFILE_MANIFEST.json`, which
65
+ explicitly names requested, completed, failed and pending targets. If CYP19A1
66
+ is still running on Computer C, PanDockLab labels the ZIP **partial** rather than
67
+ implying that the missing target was prepared. Each prepared profile also
68
+ includes `15_quality_assessment.json` with its blockers, warnings and
69
+ required next validation step.
70
+
71
+ ## Scientific behavior and limits
72
+
73
+ - pH is an active preparation parameter. PanDockLab runs PROPKA on the receptor to obtain structure-dependent residue pKa predictions and proposes residue states for review. Predictions do not silently override expert judgment: residues near their pKa are flagged, neutral histidines require explicit HID/HIE review, and manual/curated assignments remain available. For ligands, PanDockLab can use Molscrub to enumerate protonation and tautomer microstates at the selected pH; users review/select the states used for docking.
74
+ - Missing-heavy-atom counts are preliminary heuristics. Meeko template matching is the actual chemical check. OXT, modified residues and chain boundaries require individual interpretation.
75
+ - PDBFixer repairs are modeled coordinates. Review pocket repairs; missing loops require a separate curated model.
76
+ - A curated receptor must remain in the original reference coordinate frame. Align the receptor externally if necessary; do not independently align ligand poses for RMSD.
77
+ - Alternate coordinates are selected consistently by residue. Only the first model is used. Verify chain IDs after mmCIF-to-PDB conversion, especially for large assemblies.
78
+ - Complex metal, covalent and specialized water docking are outside the first-version scope. Successful file preparation does not establish scoring-function suitability.
79
+ - Redocking summarizes top-ranked and best-pose recovery separately. The default 2 Å threshold is editable and is a screening convention, not evidence of affinity prediction.
80
+ - Validation fingerprints include receptor preparation, box, search settings, seeds and reference identity. A completed matching job indicates matching settings, not automatically satisfactory recovery.
81
+ - No interaction analysis or PANVIZ integration is implemented yet. Pose inspection and scientific downloads are implemented.
82
+ - Current jobs are session-scoped subprocesses, not a distributed queue. Cancellation is cooperative between searches. Server restarts interrupt jobs. Refresh status manually.
83
+ - Set `PANDOC_DATA_DIR` to a writable persistent directory if needed. Experiments are isolated by random IDs, but session reconnection and authentication are not implemented. Download the experiment before ending the session. A public multi-user deployment needs resource limits and a durable queue.
84
+ - 3D visualization loads the 3Dmol JavaScript viewer; the browser needs access to its CDN.
85
+ - PDB chemistry lookup uses the RCSB Data API and optionally the CCD CIF download for atom-name checks. It is cached for one day per component. Service failures are shown with retry/manual-entry guidance. CCD chemistry is not a pH prediction, and matching atom counts alone do not establish matching connectivity. Lookup provenance is saved with the experiment.
86
+
87
+
88
+ ## HEM and non-standard residue preparation
89
+
90
+ A retained `HEM` cofactor is **not** sent to Meeko's automatic CCD-template
91
+ builder: its iron coordination cannot be reliably reconstructed from an
92
+ ordinary ligand template. In **Prepare structures → Receptor**, explicitly
93
+ review the Fe-coordinating cysteine SG (including its Fe--SG distance) to use
94
+ the existing curated P450-like preparation. PanDockLab prepares the protein using
95
+ the reviewed protonation states, restores the **original crystallographic HEM
96
+ coordinates**, converts using **AutoDockTools prepare_receptor4.py** and checks
97
+ the proximal thiolate and Fe retention. This requires an AutoDockTools-equipped
98
+ backend. When `GITHUB_TOKEN` and `PANDOC_JOB_KEY` are configured, an uploaded
99
+ HEM receptor is automatically sent as an encrypted generic `prepare-heme` job
100
+ to Computer C (the same curated AutoDockTools runner used for reviewed
101
+ profiles), with a progress indicator and audited outputs loaded back into the
102
+ workbench. Without Computer C, an appropriately installed local AutoDockTools
103
+ environment is required. Arbitrary His/other
104
+ heme coordination environments are **not** represented as P450 thiolates;
105
+ those receptors require a separately validated curated route.
106
+
107
+ The API accepts an optional `heme_coordination_residue` form field (for
108
+ example `A:437`) for the same reviewed route. Without an explicit donor,
109
+ the preparation **fails safely**, preserves HEM and explains what review is
110
+ required. PanDockLab never automatically deletes cofactors to make Meeko pass.
111
+
112
+ For other **non-metal, noncovalent CCD components**, an explicit Meeko
113
+ CCD-template failure triggers at most **one** controlled retry, using an
114
+ RCSB `<CCD>_ideal.sdf` chemistry definition only when RDKit parses it as a
115
+ single chemical graph and its heavy-element inventory exactly matches the
116
+ deposited residue. The SDF does not replace deposited coordinates. The
117
+ original error, retry transcript and `cofactor_resolution.json` are saved
118
+ for review; the fallback does **not** establish charge accuracy, metal
119
+ coordination, or docking validity. RCSB discontinued `_model.sdf` in 2024,
120
+ so PanDockLab uses the still-supported `_ideal.sdf`.
121
+
122
+ To supply reviewed local residue templates, configure
123
+ `PANDOC_COF_TEMPLATE_DIR` pointing to a directory containing files such as
124
+ `ABC.json` (curated Meeko JSON) or `ABC.sdf` (validated CCD component SDF).
125
+ The resolver never silently substitutes metal-containing or linked cofactors
126
+ with generic organic chemistry. Failed downloads and chemistry mismatches
127
+ remain visible, and downstream redocking validation is still required.
128
+
129
+
130
+ ## Free GitHub Actions compute
131
+
132
+ PanDockLab can offload docking calculations from Streamlit Community Cloud to GitHub-hosted Actions runners without a paid API server.
133
+
134
+ The Streamlit app automatically uses this backend when both of these Streamlit secrets are present:
135
+
136
+ ```toml
137
+ GITHUB_TOKEN = "fine-grained GitHub token"
138
+ PANDOC_JOB_KEY = "Fernet key"
139
+ ```
140
+
141
+ The repository must also contain the same `PANDOC_JOB_KEY` as a GitHub Actions repository secret. The token should be limited to this repository and needs Contents read/write plus Actions read/write permissions so PanDockLab can create the encrypted temporary job branch, dispatch the workflow, inspect its status, download the result artifact, cancel jobs, and delete the temporary branch.
142
+
143
+ Generate a Fernet key with:
144
+
145
+ ```bash
146
+ python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
147
+ ```
148
+
149
+ Job inputs are compressed and encrypted before being committed to the temporary public branch. The workflow decrypts them only inside the GitHub runner. Docking logs and outputs are returned as a GitHub Actions artifact and are materialized back into the Streamlit session for the existing results UI. The temporary branch is deleted after successful result retrieval.
150
+
151
+ Workflow: `.github/workflows/pandoc-compute.yml`
152
+
153
+ ## REST API
154
+
155
+ PanDockLab includes a FastAPI service for programmatic access to the same scientific engine and the same shared compute service used by the Streamlit workbench. Docking compute is GitHub Actions only: `GITHUB_TOKEN` and `PANDOC_JOB_KEY` are required, and there is no local compute fallback.
156
+
157
+ Run locally:
158
+
159
+ ```bash
160
+ uvicorn api:app --host 0.0.0.0 --port 8000
161
+ ```
162
+
163
+ Interactive API documentation is available at `/docs` and `/redoc`.
164
+
165
+ Core endpoints:
166
+
167
+ - `GET /api/v1/health` — service health.
168
+ - `GET /api/v1/versions` — software provenance.
169
+ - `GET /api/v1/compute` — report the active compute backend.
170
+ - `POST /api/v1/structures/inspect` — inspect an uploaded PDB/mmCIF structure.
171
+ - `POST /api/v1/proteins/protonation` — run PDBFixer (optional) and PROPKA at a selected pH and return reviewable residue-state proposals.
172
+ - `POST /api/v1/ligands/microstates` — enumerate ligand protonation/tautomer microstates with Molscrub.
173
+ - `POST /api/v1/receptors/prepare` — prepare a receptor with reviewed Meeko template assignments.
174
+ - `POST /api/v1/ligands/prepare` — prepare a selected ligand state for docking.
175
+ - `POST /api/v1/jobs/dock` — submit a Vina job to GitHub Actions when configured.
176
+ - `GET /api/v1/jobs/{job_id}` — read GitHub/local job status and materialize a completed Actions artifact.
177
+ - `GET /api/v1/jobs/{job_id}/results` — read docking results returned by the compute backend.
178
+ - `POST /api/v1/jobs/{job_id}/cancel` — cancel the GitHub Actions run or local worker.
179
+ - `GET /api/v1/jobs/{job_id}/bundle` — download completed job outputs as ZIP.
180
+
181
+ For public deployments, set `PANDOC_API_KEY`; protected endpoints then require an `X-API-Key` header. Set `GITHUB_TOKEN` and the same `PANDOC_JOB_KEY` used by the GitHub repository Actions secret to activate the GitHub Actions compute backend. `PANDOC_GITHUB_REPOSITORY` optionally overrides the default repository. `PANDOC_API_DATA_DIR` controls API-side materialized result storage and `PANDOC_API_MAX_UPLOAD_MB` controls the per-file upload limit. Optional browser clients can be allowed with `PANDOC_CORS_ORIGINS`.
182
+
183
+ A separate API container is provided:
184
+
185
+ ```bash
186
+ docker build -f Dockerfile.api -t pandoc-api .
187
+ docker run --rm -p 8000:8000 \
188
+ -e PANDOC_API_KEY=change-me \
189
+ -e GITHUB_TOKEN=your-fine-grained-token \
190
+ -e PANDOC_JOB_KEY=the-same-fernet-key-as-github-actions \
191
+ -v pandoc-api-data:/data/pandoc_api \
192
+ pandoc-api
193
+ ```
194
+
195
+ `pandoc/compute.py` is the shared GitHub Actions compute gateway used by both Streamlit and FastAPI. Streamlit Community Cloud therefore remains a lightweight UI while docking compute runs remotely on GitHub Actions. A separately reachable FastAPI URL is only required when an external program needs HTTP endpoints.
196
+
197
+ ## Verification
198
+
199
+ ```bash
200
+ python -m compileall -q app.py pandoc
201
+ pip install pytest
202
+ python -m pytest -q
203
+ ```
204
+
205
+ Tests cover alternate conformations, incomplete residues, box calculation, invalid configurations, fixed-frame RMSD, atom reordering, preserved reference coordinates, Meeko ligand export/reconstruction, a real small Vina docking run, and Streamlit screens with empty and populated experiments. The small peptide/ethanol test checks software integration; it is not a biological docking benchmark. GitHub Actions installs dependencies and runs the checks on pushes and pull requests.
206
+
207
+ ## Layout
208
+
209
+ `app.py` contains the guided interface. `pandoc/compute.py` provides the GitHub Actions compute backend, `pandoc/core.py` handles inspection and chemistry, and `pandoc/worker.py` runs Vina and reconstructs SDF poses inside the Actions runner. `tests/` contains scientific regression checks.
210
+
211
+ Meeko: https://github.com/forlilab/Meeko
212
+
213
+ AutoDock Vina: https://github.com/ccsb-scripps/AutoDock-Vina
214
+
215
+ PDBFixer: https://github.com/openmm/pdbfixer
216
+
217
+ ### Publication redocking overlay
218
+ After redocking, use **Validate docking → Figure pose**, or **Explore results → Inspect pose**. The ligand-only interactive view shows crystallographic heavy atoms in cyan and the selected redocked pose in magenta. Coordinates remain in the receptor frame; rotating the camera moves both ligands together and never fits a pose onto the reference. The first reported pose is selected by default. Seed, pose rank, and independently recomputed symmetry-aware heavy-atom RMSD appear in the app outside the figure. The exported panel contains only the ligand overlay and a compact centered color legend. Shaded ball-and-stick is the default; users can choose sticks, adjust both ligand colors, and switch between white and dark backgrounds without changing coordinates or the camera.
219
+
220
+ Browser exports render at high resolution: PNG is 3996 × 2340 pixels with 600-DPI physical-resolution metadata; PDF is 6.66 × 3.90 inches and embeds the raster panel. Camera orientation is preserved. The publication viewer uses an orthographic projection of the original 3D coordinates, with depth-sorted shaded atoms and bonds. Preview and export use the same drawing scene and camera. Export renders on a separate 2D canvas without resizing the visible viewer, WebGL buffers, or loading any external script. This illustration uses painter-style depth sorting rather than a ray tracer; inspect crossing bonds and adjust the viewing angle where needed. PDF export runs locally in the browser with no external PDF library, embedding lossless RGB pixels. Export errors appear beside the controls. No protein appears in this publication figure, and no docking calculation is repeated. Review the figure against journal requirements before submission.
221
+
222
+ ### Search PDB within PanDockLab
223
+ Use **Load complex → Search PDB** to search experimental structures by keywords, deposited protein name, exact PDB ID, UniProt accession, or ligand name/three-character component ID. The initial method is X-ray diffraction; advanced filters support organism, method, maximum resolution, and nonpolymer presence. The latter includes ions, additives and cofactors and does not guarantee a redocking reference. Exact PDB IDs bypass search filters. Results are paginated in groups of ten and cached for one hour. Search relevance is not a suitability score.
224
+
225
+ Select a result and click **View structure details** to review chain-specific molecule identities, source organisms, reported mutations, nonpolymer components, unmodeled residue counts and the publication. Links open RCSB structure and ligand-quality pages; PanDockLab does not manufacture a quality score or treat missing validation as a pass. Click **Load this structure** to retrieve the deposited coordinate mmCIF (25-MB maximum), then inspect the 3D complex and explicitly select receptor chains and the reference ligand. Biological assemblies are not automatically substituted.
226
+
227
+ The experiment records the search criteria/query, chosen PDB ID, metadata, retrieval time, download URL, selection rationale and original-file SHA-256; the original mmCIF is included in the experiment archive. Changing the loaded complex clears previous preparation and active-result selections. Older calculation files remain in the experiment for provenance. API failures leave the currently loaded structure intact; file upload remains available.
228
+
229
+ For browser export regression checks, `?publication_demo=1` opens a clearly labelled synthetic ligand overlay using the production export component. It does not run docking or replace experiment data.
230
+
231
+ ### Scientific assistant
232
+
233
+ Open **Scientific assistant** below the workflow. Add `GROQ_API_KEY = "your-key"` in Streamlit **App settings → Secrets**, or in the ignored `.streamlit/secrets.toml` locally. Environment variables are also supported. The default model is `openai/gpt-oss-120b`; optionally set `GROQ_MODEL` in secrets. Ask “What does docking exhaustiveness mean?” to test the connection.
234
+
235
+ Answers remain visible across reruns within the same session. Requests occur only when a chat message is submitted. The quick conversation snapshot includes box settings and up to the first 50 anonymous result rows. With **Share experiment context** enabled, Groq may additionally call allowlisted **read-only scientific evidence tools** to summarize *all saved result rows*, retrieve bounded score/RMSD pages, inspect recorded structure issues or one residue's atom inventory, and read job/provenance settings. Context sharing off disables tool calls. The selected PanDockLab job/structure determines what can be inspected; the model cannot provide arbitrary filesystem paths. The tools exclude raw PDB/SDF/PDBQT coordinates, ligand labels and original filenames. The AI still cannot execute calculations, modify settings, determine uncomputed interactions or search literature. Verify model interpretations independently before using them for scientific conclusions. Model/account quotas apply.
236
+
237
+
238
+ ### Reviewed AI scientific task agent (pilot)
239
+
240
+ PanDockLab now includes an opt-in **AI task agent · Perform reviewed scientific work** panel alongside the Groq scientific assistant. It goes beyond explanations: natural-language requests can start a durable PDB retrieval/inspection task, present receptor/reference selection, suggest pKa assignments for review, prepare approved structures, run approved Vina redocking through GitHub Actions, and export an evidence/provenance bundle. The model **cannot** silently choose chemistry or authorize compute. Groq uses structured output for task planning, with a safe deterministic fallback.
241
+
242
+ **Setup:** the deployment administrator sets PANDOC_AGENT_ENABLED=true, GROQ_API_KEY (for model planning/conversation), and GITHUB_TOKEN/PANDOC_JOB_KEY for optional remote redocking **in Streamlit Secrets or server environment**, not in the user interface. PANDOC_AGENT_ACCESS_KEY is obsolete and is no longer used by the Streamlit agent; it may be deleted from secrets. Set PANDOC_AGENT_DATA_DIR to durable storage; temporary directories do not survive cloud instance replacement. The agent panel is directly usable without entering any key. A user can type **Prepare PDB 1LF2 at pH 5.0** in the existing assistant to start read-only retrieval; approval gates remain for scientific choices and compute. **Security:** enabling this on a public Streamlit URL permits visitors to request agent work using server-configured credentials. Before open multi-user compute, enforce owner isolation and server-side quotas/limits or keep the deployment private. The chemistry panel can suggest CCD identities and MolScrub states but never accepts them automatically.
243
+
244
+ See [Scientific Task Agent pilot guide](docs/SCIENTIFIC_TASK_AGENT.md) for the approval stages, REST endpoints, task recovery and deployment restrictions.
245
+
246
+ ### Automatic structure inspection
247
+
248
+ Loading a complex now runs coordinate screening before component cleanup. The
249
+ Structure details section shows the detected residue, explanation and next action;
250
+ Focus on selected residue highlights and focuses it in the molecular viewer.
251
+ Use selection and continue opens preparation directly. Prepare receptor rebuilds
252
+ missing heavy atoms by default, without an extra confirmation checkbox. Advanced
253
+ settings and diagnostic reports are collapsed until needed.
254
+ Standard amino-acid checks identify missing heavy atoms by name, unexpected atom
255
+ names, duplicate records, severe overlaps, terminal oxygen geometry, possible
256
+ chain breaks, alternate positions and zero occupancy. Waters, metals and other
257
+ components are flagged for review. LINK and SSBOND records are inventoried.
258
+
259
+ Alternate conformations are selected per residue. Suggested choices prefer the
260
+ more complete alternative, then higher mean occupancy; shared atoms are retained.
261
+ These are starting suggestions, not experimentally established best conformers.
262
+ Study binding-site alternatives in separate experiments when relevant.
263
+
264
+ Selection retains CONECT bonds between retained atoms and LINK/SSBOND records
265
+ whose two residues remain selected. Selection and preparation reports record
266
+ choices, detected issues, software versions and heavy-atom changes. Preparation
267
+ rejects unexpected heavy-atom loss or renaming rather than silently accepting it.
268
+ The assistant receives the selected issue and current preparation choices when
269
+ experiment context is enabled; molecular coordinates are not sent.
270
+
271
+ **Scope:** this is conservative coordinate and component screening, not a
272
+ MolProbity validation or electron-density assessment. Protonation is handled in
273
+ the preparation stage: PROPKA provides structure-dependent residue pKa
274
+ predictions, PanDockLab converts them into reviewable residue-state proposals, and
275
+ reviewed assignments are passed to Meeko. PROPKA output is not treated as an
276
+ unquestionable ground truth, and neutral histidines require explicit HID/HIE
277
+ selection. Ligand protonation/tautomer states can be enumerated with Molscrub at
278
+ the selected pH and must be reviewed before docking. Missing loops,
279
+ metalloproteins, covalent components and unsupported templates can require
280
+ curated preparation. Structural success does not establish docking accuracy.
281
+
282
+ Design references: [wwPDB validation](https://www.wwpdb.org/validation/2016/XrayValidationReportHelp),
283
+ [PDB2PQR algorithms](https://pdb2pqr.readthedocs.io/en/latest/using/algorithms.html),
284
+ [PROPKA](https://propka.readthedocs.io/en/stable/command.html),
285
+ [Vina zinc workflow](https://autodock-vina.readthedocs.io/en/latest/docking_zinc.html).
286
+
287
+
288
+ ## External browser automation contract
289
+
290
+ PanDockLab supports external browser automation with Playwright, Selenium, or similar tools without bundling a browser driver into the PanDockLab runtime.
291
+
292
+ The automation contract follows browser-testing best practice:
293
+
294
+ 1. **Control widgets through accessible locators first.** External clients should prefer Playwright role/label selectors such as `getByRole()`, `getByLabel()`, and exact accessible names. Examples include **Workflow**, **Compute**, **PDB or mmCIF complex**, **Prepare receptor**, **Prepare reference ligand**, **Run redocking**, **Run docking**, and **Download complete experiment**.
295
+ 2. **Do not target Streamlit's generated DOM classes or internal `data-testid` values.** They are framework implementation details and may change across Streamlit releases.
296
+ 3. **Streamlit widget `key=` values are application/session identity, not browser selectors.** They make reruns deterministic inside PanDockLab but are not promised to appear in the browser DOM.
297
+ 4. **Use PanDockLab-owned state markers only for synchronization.** PanDockLab emits its own `pandoc-*` markers as an explicit application contract. These markers indicate state; they are not substitutes for accessible control locators.
298
+ 5. **Wait on state, never arbitrary sleeps.** After an action that triggers a Streamlit rerun or remote calculation, wait for the expected PanDockLab state marker and/or the expected accessible control to become visible/enabled.
299
+ 6. **Use the browser download event for artifacts.** For Playwright, start `page.waitForEvent('download')` (or the equivalent `expect_download` API) before activating a PanDockLab download button, then validate the suggested filename and saved artifact.
300
+
301
+ PanDockLab-owned synchronization markers:
302
+
303
+ - `[data-testid="pandoc-app-ready"][data-state="ready"]`
304
+ - `[data-testid="pandoc-workflow-stage"]` with the current stage in `data-state`
305
+ - `[data-testid="pandoc-compute-node"]` with the selected compute node in `data-state`
306
+ - `[data-testid="pandoc-complex"]`, `pandoc-receptor`, and `pandoc-reference` with `pending` or `ready`
307
+ - `[data-testid="pandoc-job-status"]` with `queued`, `starting`, `running`, `completed`, `failed`, or `cancelled`; `data-value` contains the PanDockLab job identifier
308
+ - `[data-testid="pandoc-ligand-state-job"]` and `[data-testid="pandoc-candidate-preparation-job"]` for preparation tasks
309
+ - `[data-testid="pandoc-reference-prepared"]` after reference preparation
310
+ - `[data-testid="pandoc-experiment-bundle"][data-state="ready"]` when the complete experiment ZIP is ready
311
+
312
+ A robust Playwright flow should therefore look conceptually like:
313
+
314
+ ```javascript
315
+ await page.goto(PANDOC_URL);
316
+
317
+ await page.locator('[data-testid="pandoc-app-ready"][data-state="ready"]').waitFor();
318
+
319
+ await page.getByLabel('Workflow').getByText('1 · Load complex', { exact: true }).click();
320
+ // Operate the native upload control through its accessible label.
321
+ await page.getByLabel('PDB or mmCIF complex').setInputFiles('complex.pdb');
322
+
323
+ await page.locator('[data-testid="pandoc-complex"][data-state="ready"]').waitFor();
324
+
325
+ // Continue with role/label locators...
326
+ await page.getByRole('button', { name: 'Run redocking', exact: true }).click();
327
+
328
+ await page.locator('[data-testid="pandoc-job-status"][data-state="completed"]').waitFor({
329
+ timeout: 30 * 60 * 1000,
330
+ });
331
+
332
+ await page.locator('[data-testid="pandoc-experiment-bundle"][data-state="ready"]').waitFor();
333
+ const downloadPromise = page.waitForEvent('download');
334
+ await page.getByRole('button', { name: 'Download complete experiment', exact: true }).click();
335
+ const download = await downloadPromise;
336
+ ```
337
+
338
+ Because Streamlit reruns the application after many widget actions, external clients should reacquire locators after state-changing actions rather than caching element handles. Playwright locators are suitable because they are evaluated lazily and include auto-waiting/actionability checks.
339
+
340
+ For **PanDockLab's own repository tests**, Streamlit's native `st.testing.v1.AppTest` remains the preferred fast test layer for widget/state logic. Real Playwright is appropriate as a separate end-to-end/browser compatibility layer when the deployed DOM, downloads, iframes, or real browser behavior must be verified. Playwright is not a PanDockLab runtime dependency.
341
+
@@ -0,0 +1 @@
1
+ """PanDoc scientific workflow."""