feat(viz): expand MolStar visualization for docking and structures#585
Merged
Conversation
Add MolStar HTML helpers and surface them on protein/ligand/docking show paths, with tests, catalog notebook updates, and design/ADR notes.
Encode fixture via read_text so base64 matches Path.read_text newline translation used by render_ligand_html.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the in-client hosted Mol* (molstarLib) HTML visualization builders and wires them through the protein/ligand/docking notebook “show” entry points, reducing reliance on the legacy deeporigin-molstar package while documenting the remaining gaps (multi-molecule SDF splitting, Box3D export).
Changes:
- Add new Mol* HTML builders for ligand-only, protein+poses, protein+pockets+poses, docking box, and box+poses; plus JS-safe ligand payload helpers.
- Rewire
Protein.show,Ligand.show, andDocking.show_box/ConstrainedDocking.show_boxto use the hosted molstarLib paths (keepingLigandSet.showon the legacy viewer). - Expand and update tests and docs (catalog notebook, tutorial, design-doc inventory, and a new ADR for duck-typed Box3D).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_molstar_html.py | Adds coverage for new molstarLib HTML builders, ligand payloads, script-escape behavior, and docking box geometry HTML. |
| tests/test_ligand_set.py | Asserts LigandSet.show() remains on legacy MoleculeViewer and returns rendered HTML. |
| tests/test_docking.py | Updates Docking.show_box() tests to mock new HTML builder functions; adds poses= overlay case. |
| src/viz/molstar_html.py | Implements new HTML builder functions and docking-box geometry validation; changes pocket alpha default. |
| src/viz/init.py | Re-exports new visualization helpers from molstar_html. |
| src/drug_discovery/structures/protein.py | Reworks Protein.show() to compose new molstarLib builders for protein/pockets/poses combinations. |
| src/drug_discovery/structures/ligand.py | Switches single-ligand rendering to hosted molstarLib; documents LigandSet.show() as legacy due to multi-mol SDF. |
| src/drug_discovery/docking.py | Replaces legacy docking viewer usage with molstarLib HTML builders; adds optional poses= overlay support. |
| src/drug_discovery/docking_common.py | Adds shared pose normalization + payload construction helpers for docking-family visualizations. |
| src/drug_discovery/constrained_docking.py | Mirrors Docking.show_box() migration to molstarLib + optional poses= overlay. |
| docs/notebooks/clean/molstar-visualization-catalog.ipynb | Updates catalog status/sections to reflect new migrations and remaining legacy pieces. |
| docs/dd/tutorial/docking.md | Documents show_box(poses=...) and pose navigation behavior. |
| docs/adr/0001-docking-box-without-exported-box3d.md | New ADR documenting duck-typed {min,max} box until platform exports Box3D/createBox3D. |
| design-docs/README.md | Updates migration status table and links the new ADR. |
| design-docs/01-molstar-visualization-inventory.md | Updates inventory phases, API mapping, and test coverage notes for new visualizations. |
| CONTEXT.md | Adds terminology guidance for “docking search box” naming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Validate empty pose collections and box color at runtime, reuse the shared pose-label helper, tighten docking-box ValueError paths, and drop inaccurate show_box return annotations.
Avoid ModuleNotFoundError when importing ligand without the optional tools extra; MoleculeViewer is only needed for multi-ligand sets.
Drop inaccurate -> str | None annotations; docstrings now match render_html Jupyter None vs marimo mo.Html behavior.
Lock in ValueError from ligand_payloads_for_viewer when poses=[].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mainontomolstar-viz-2Box3DMerge-ready status
Auto-updated — cycle 7 complete, last updated: 2026-07-08T16:51:28Z
main19ab0d04bcf525Recent activity
4bcf525with no new comments.Test plan
uv run ruff format . && uv run ruff check --select I . --fixuv run pytest --env local -x -k molstarshow()paths render expected MolStar views