Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmbuhr/quarto-molstar
Shortcode to embed proteins and trajectories with Mol*
https://github.com/jmbuhr/quarto-molstar
quarto quarto-extension
Last synced: 2 months ago
JSON representation
Shortcode to embed proteins and trajectories with Mol*
- Host: GitHub
- URL: https://github.com/jmbuhr/quarto-molstar
- Owner: jmbuhr
- License: mit
- Created: 2022-07-31T16:06:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-06T14:12:04.000Z (9 months ago)
- Last Synced: 2024-08-04T22:14:59.913Z (6 months ago)
- Topics: quarto, quarto-extension
- Language: JavaScript
- Homepage: https://jmbuhr.de/quarto-molstar/
- Size: 7.91 MB
- Stars: 40
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Molstar (Mol*) Extension for Quarto
This extension provides shortcodes for [molstar](https://github.com/molstar/molstar) in quarto.
Molstar can display macro-molecules such as proteins as well as molcular dynamics trajectories in an interactive viewer.
You can see it in action e.g. in the RCSB Protein Data Base: , where it provides the 3d view for entries.
Follow me, if you want this right in your quarto reports (html only).## Installing
```sh
quarto install extension jmbuhr/quarto-molstar
```This will install the extension under the `_extensions` subdirectory.
If you're using version control, you will want to check in this directory.## Using
Usage examples are in `index.qmd`, which you can see rendered locally and served with GitHub pages here:
Likewise, the example rendered as a revealjs presentation (`presentation.qmd`) is served here:
## Limitations
- Self-contained htmls:
Molstar viewers for local files are empty when the file is **not** served by a webserver such as `quarto preview` or GitHub pages.
This means it will not display your molecule when you simply open the rendered html with a browser,
even if you set the html to be self-contained.
The reason for this is the [Same-origin Policy](https://developer.mozilla.org/en-US/docs/Glossary/Same-origin_policy), a security measure in web browsers.
It and similar policies prevent that one document can access resources it is not supposed to access.
For example, an html document you downloaded is not allowed to execute code that reads personal files on your computer.
This also prevents it from loading your molecules from local paths.For plain text formats in the `mol-url` shortcode, such as `pdb` and `xyz`, you can enable a custom option that circumvents this limitation
by embedding them straight into the html as a string.
Add `molstar: embed` to your yml frontmatter to use this.
- Resources like local structures that have to be loaded need to be added manually via in order to be copied to the publish directory until support for automatic resource discovery ().
- revealjs presentations now use iframes instead of a normal div to work around https://github.com/jmbuhr/quarto-molstar/issues/1,
which is why you might have to address those differently for custom styling if you plan to use the same source for html and revealjs output.## Update Mol* (extension developement)
The js and css files where downloaded from the [molstar web viewer](https://molstar.org/viewer/) in order to be up to date but also self-contained and functional without an internet connection.
```bash
cd _extensions/molstar/assets
rm molstar.js
wget https://cdn.jsdelivr.net/npm/molstar@latest/build/viewer/molstar.js
rm molstar.css
wget https://cdn.jsdelivr.net/npm/molstar@latest/build/viewer/molstar.css
```