<div align="center">
![Logo](https://raw.githubusercontent.com/zincware/ZnDraw/refs/heads/main/docs/source/_static/zndraw-light.svg#gh-light-mode-only)
![Logo](https://raw.githubusercontent.com/zincware/ZnDraw/refs/heads/main/docs/source/_static/zndraw-dark.svg#gh-dark-mode-only)
[![zincware](https://img.shields.io/badge/Powered%20by-zincware-darkcyan)](https://github.com/zincware)
[![PyPI version](https://badge.fury.io/py/zndraw.svg)](https://badge.fury.io/py/zndraw)
[![DOI](https://img.shields.io/badge/arXiv-2402.08708-red)](https://arxiv.org/abs/2402.08708)
[![codecov](https://codecov.io/gh/zincware/ZnDraw/graph/badge.svg?token=3GPCKH1BBX)](https://codecov.io/gh/zincware/ZnDraw)
[![Discord](https://img.shields.io/discord/1034511611802689557)](https://discord.gg/7ncfwhsnm4)
[![Documentation Status](https://readthedocs.org/projects/zndraw/badge/?version=latest)](https://zndraw.readthedocs.io/en/latest/?badge=latest)
!['Threejs](https://img.shields.io/badge/threejs-black?style=for-the-badge&logo=three.js&logoColor=white)
</div>
# ZnDraw - Display and Edit Molecules
Welcome to ZnDraw, a powerful tool for visualizing and interacting with your trajectories.
## Installation
You can install ZnDraw directly from PyPi via:
```bash
pip install zndraw
```
## Quick Start
Visualize your trajectories with a single command:
```bash
zndraw <file>
```
> [!NOTE]
> ZnDraw's webapp-based approach allows you to use port forwarding to work with trajectories on remote systems.
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/overview.png#gh-dark-mode-only "ZnDraw UI")
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/overview.png#gh-light-mode-only "ZnDraw UI")
## Multi-User and Multi-Client Support
ZnDraw supports multiple users and clients. Connect one or more Python clients to your ZnDraw instance:
1. Click on `Python access` in the ZnDraw UI.
2. Connect using the following code:
```python
from zndraw import ZnDraw
vis = ZnDraw(url="http://localhost:1234", token="<your-token>")
```
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/python.png#gh-dark-mode-only "ZnDraw Python Client")
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/python.png#gh-light-mode-only "ZnDraw Python Client")
The `vis` object provides direct access to your visualized scene. It inherits from `abc.MutableSequence`, so any changes you make are reflected for all connected clients.
```python
from ase.collections import s22
vis.extend(list(s22))
```
## Additional Features
You can modify various aspects of the visualization:
- `vis.camera`
- `vis.points`
- `vis.selection`
- `vis.step`
- `vis.figures`
- `vis.bookmarks`
- `vis.geometries`
For example, to add a geometry:
```python
from zndraw import Box
vis.geometries = [Box(position=[0, 1, 2])]
```
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/box.png#gh-dark-mode-only "ZnDraw Geometries")
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/box.png#gh-light-mode-only "ZnDraw Geometries")
## Analyzing Data
ZnDraw enables you to analyze your data and generate plots using [Plotly](https://plotly.com/). It automatically detects available properties and offers a convenient drop-down menu for selection.
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/analysis.png#gh-dark-mode-only "ZnDraw Analysis")
![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/analysis.png#gh-light-mode-only "ZnDraw Analysis")
ZnDraw will look for the `step` and `atom` index in the [customdata](https://plotly.com/python/reference/scatter/#scatter-customdata)`[0]` and `[1]` respectively to highlight the steps and atoms.
## Writing Extensions
Make your tools accessible via the ZnDraw UI by writing an extension:
```python
from zndraw import Extension
class AddMolecule(Extension):
name: str
def run(self, vis, **kwargs) -> None:
structures = kwargs["structures"]
vis.append(structures[self.name])
vis.step = len(vis) - 1
vis.register(AddMolecule, run_kwargs={"structures": s22}, public=True)
vis.socket.wait() # This can be ignored when using Jupyter
```
The `AddMolecule` extension will appear for all `tokens` and can be used by any client.
# Hosted Version
A hosted version of ZnDraw is available at https://zndraw.icp.uni-stuttgart.de . To upload data, use:
```bash
zndraw <file> --url https://zndraw.icp.uni-stuttgart.de
```
## Self-Hosting
To host your own version of ZnDraw, use the following `docker-compose.yaml` setup:
```yaml
version: "3.9"
services:
zndraw:
image: pythonf/zndraw:latest
command: --no-standalone /src/file.xyz
volumes:
- /path/to/files:/src
restart: unless-stopped
ports:
- 5003:5003
depends_on:
- redis
- worker
environment:
- FLASK_STORAGE=redis://redis:6379/0
- FLASK_AUTH_TOKEN=super-secret-token
worker:
image: pythonf/zndraw:latest
entrypoint: celery -A zndraw_app.make_celery worker --loglevel=info -P eventlet
volumes:
- /path/to/files:/src
restart: unless-stopped
depends_on:
- redis
environment:
- FLASK_STORAGE=redis://redis:6379/0
- FLASK_SERVER_URL="http://zndraw:5003"
- FLASK_AUTH_TOKEN=super-secret-token
redis:
image: redis:latest
restart: always
environment:
- REDIS_PORT=6379
```
If you want to host zndraw as subdirectory `domain.com/zndraw` you need to adjust the environmental variables as well as update `base: "/",` in the `app/vite.config.ts` before building the ap..
# References
If you use ZnDraw in your research and find it helpful please cite us.
```bibtex
@misc{elijosiusZeroShotMolecular2024,
title = {Zero {{Shot Molecular Generation}} via {{Similarity Kernels}}},
author = {Elijo{\v s}ius, Rokas and Zills, Fabian and Batatia, Ilyes and Norwood, Sam Walton and Kov{\'a}cs, D{\'a}vid P{\'e}ter and Holm, Christian and Cs{\'a}nyi, G{\'a}bor},
year = {2024},
eprint = {2402.08708},
archiveprefix = {arxiv},
}
```
# Acknowledgements
The creation of ZnDraw was supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in the framework of the priority program SPP 2363, “Utilization and Development of Machine Learning for Molecular Applications - Molecular Machine Learning” Project No. 497249646. Further funding though the DFG under Germany's Excellence Strategy - EXC 2075 - 390740016 and the Stuttgart Center for Simulation Science (SimTech) was provided.
Raw data
{
"_id": null,
"home_page": null,
"name": "zndraw",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "zincwarecode",
"author_email": "zincwarecode@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5f/19/e78c780a380b3abc3370f93037671042a3735d3845b82ca0b635b32adacf/zndraw-0.5.7.tar.gz",
"platform": null,
"description": "\n\n\n\n<div align=\"center\">\n\n![Logo](https://raw.githubusercontent.com/zincware/ZnDraw/refs/heads/main/docs/source/_static/zndraw-light.svg#gh-light-mode-only)\n![Logo](https://raw.githubusercontent.com/zincware/ZnDraw/refs/heads/main/docs/source/_static/zndraw-dark.svg#gh-dark-mode-only)\n\n[![zincware](https://img.shields.io/badge/Powered%20by-zincware-darkcyan)](https://github.com/zincware)\n[![PyPI version](https://badge.fury.io/py/zndraw.svg)](https://badge.fury.io/py/zndraw)\n[![DOI](https://img.shields.io/badge/arXiv-2402.08708-red)](https://arxiv.org/abs/2402.08708)\n[![codecov](https://codecov.io/gh/zincware/ZnDraw/graph/badge.svg?token=3GPCKH1BBX)](https://codecov.io/gh/zincware/ZnDraw)\n[![Discord](https://img.shields.io/discord/1034511611802689557)](https://discord.gg/7ncfwhsnm4)\n[![Documentation Status](https://readthedocs.org/projects/zndraw/badge/?version=latest)](https://zndraw.readthedocs.io/en/latest/?badge=latest)\n!['Threejs](https://img.shields.io/badge/threejs-black?style=for-the-badge&logo=three.js&logoColor=white)\n\n</div>\n\n# ZnDraw - Display and Edit Molecules\nWelcome to ZnDraw, a powerful tool for visualizing and interacting with your trajectories.\n\n## Installation\n\nYou can install ZnDraw directly from PyPi via:\n\n```bash\npip install zndraw\n```\n\n## Quick Start\n\nVisualize your trajectories with a single command:\n\n```bash\nzndraw <file>\n```\n\n> [!NOTE]\n> ZnDraw's webapp-based approach allows you to use port forwarding to work with trajectories on remote systems.\n\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/overview.png#gh-dark-mode-only \"ZnDraw UI\")\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/overview.png#gh-light-mode-only \"ZnDraw UI\")\n\n## Multi-User and Multi-Client Support\n\nZnDraw supports multiple users and clients. Connect one or more Python clients to your ZnDraw instance:\n\n1. Click on `Python access` in the ZnDraw UI.\n2. Connect using the following code:\n\n```python\nfrom zndraw import ZnDraw\n\nvis = ZnDraw(url=\"http://localhost:1234\", token=\"<your-token>\")\n```\n\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/python.png#gh-dark-mode-only \"ZnDraw Python Client\")\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/python.png#gh-light-mode-only \"ZnDraw Python Client\")\n\nThe `vis` object provides direct access to your visualized scene. It inherits from `abc.MutableSequence`, so any changes you make are reflected for all connected clients.\n\n```python\nfrom ase.collections import s22\nvis.extend(list(s22))\n```\n\n## Additional Features\n\nYou can modify various aspects of the visualization:\n\n- `vis.camera`\n- `vis.points`\n- `vis.selection`\n- `vis.step`\n- `vis.figures`\n- `vis.bookmarks`\n- `vis.geometries`\n\nFor example, to add a geometry:\n\n```python\nfrom zndraw import Box\n\nvis.geometries = [Box(position=[0, 1, 2])]\n```\n\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/box.png#gh-dark-mode-only \"ZnDraw Geometries\")\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/box.png#gh-light-mode-only \"ZnDraw Geometries\")\n\n## Analyzing Data\n\nZnDraw enables you to analyze your data and generate plots using [Plotly](https://plotly.com/). It automatically detects available properties and offers a convenient drop-down menu for selection.\n\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/darkmode/analysis.png#gh-dark-mode-only \"ZnDraw Analysis\")\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/lightmode/analysis.png#gh-light-mode-only \"ZnDraw Analysis\")\n\nZnDraw will look for the `step` and `atom` index in the [customdata](https://plotly.com/python/reference/scatter/#scatter-customdata)`[0]` and `[1]` respectively to highlight the steps and atoms.\n\n## Writing Extensions\n\nMake your tools accessible via the ZnDraw UI by writing an extension:\n\n```python\nfrom zndraw import Extension\n\nclass AddMolecule(Extension):\n name: str\n\n def run(self, vis, **kwargs) -> None:\n structures = kwargs[\"structures\"]\n vis.append(structures[self.name])\n vis.step = len(vis) - 1\n\nvis.register(AddMolecule, run_kwargs={\"structures\": s22}, public=True)\nvis.socket.wait() # This can be ignored when using Jupyter\n```\n\nThe `AddMolecule` extension will appear for all `tokens` and can be used by any client.\n\n# Hosted Version\n\nA hosted version of ZnDraw is available at https://zndraw.icp.uni-stuttgart.de . To upload data, use:\n\n```bash\nzndraw <file> --url https://zndraw.icp.uni-stuttgart.de\n```\n\n## Self-Hosting\n\nTo host your own version of ZnDraw, use the following `docker-compose.yaml` setup:\n\n```yaml\nversion: \"3.9\"\n\nservices:\n zndraw:\n image: pythonf/zndraw:latest\n command: --no-standalone /src/file.xyz\n volumes:\n - /path/to/files:/src\n restart: unless-stopped\n ports:\n - 5003:5003\n depends_on:\n - redis\n - worker\n environment:\n - FLASK_STORAGE=redis://redis:6379/0\n - FLASK_AUTH_TOKEN=super-secret-token\n\n worker:\n image: pythonf/zndraw:latest\n entrypoint: celery -A zndraw_app.make_celery worker --loglevel=info -P eventlet\n volumes:\n - /path/to/files:/src\n restart: unless-stopped\n depends_on:\n - redis\n environment:\n - FLASK_STORAGE=redis://redis:6379/0\n - FLASK_SERVER_URL=\"http://zndraw:5003\"\n - FLASK_AUTH_TOKEN=super-secret-token\n\n redis:\n image: redis:latest\n restart: always\n environment:\n - REDIS_PORT=6379\n```\n\nIf you want to host zndraw as subdirectory `domain.com/zndraw` you need to adjust the environmental variables as well as update `base: \"/\",` in the `app/vite.config.ts` before building the ap..\n\n# References\n\nIf you use ZnDraw in your research and find it helpful please cite us.\n\n```bibtex\n@misc{elijosiusZeroShotMolecular2024,\n title = {Zero {{Shot Molecular Generation}} via {{Similarity Kernels}}},\n author = {Elijo{\\v s}ius, Rokas and Zills, Fabian and Batatia, Ilyes and Norwood, Sam Walton and Kov{\\'a}cs, D{\\'a}vid P{\\'e}ter and Holm, Christian and Cs{\\'a}nyi, G{\\'a}bor},\n year = {2024},\n eprint = {2402.08708},\n archiveprefix = {arxiv},\n}\n```\n\n# Acknowledgements\n\nThe creation of ZnDraw was supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in the framework of the priority program SPP 2363, \u201cUtilization and Development of Machine Learning for Molecular Applications - Molecular Machine Learning\u201d Project No. 497249646. Further funding though the DFG under Germany's Excellence Strategy - EXC 2075 - 390740016 and the Stuttgart Center for Simulation Science (SimTech) was provided.\n",
"bugtrack_url": null,
"license": "License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)",
"summary": "Display and Edit Molecular Structures and Trajectories in the Browser.",
"version": "0.5.7",
"project_urls": {
"repository": "https://github.com/zincware/ZnDraw"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0d417499576f3960fa9d9d9226fbacd354983fd227b5f3fd1915c93a92016362",
"md5": "c22fb3849cacdda49fc3eae78735c224",
"sha256": "312be4bf3d9d6898fad6b4d7b24b38aa61b39d29daf7300801331fbd1fcea305"
},
"downloads": -1,
"filename": "zndraw-0.5.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c22fb3849cacdda49fc3eae78735c224",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 3441648,
"upload_time": "2024-12-13T13:30:51",
"upload_time_iso_8601": "2024-12-13T13:30:51.634302Z",
"url": "https://files.pythonhosted.org/packages/0d/41/7499576f3960fa9d9d9226fbacd354983fd227b5f3fd1915c93a92016362/zndraw-0.5.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5f19e78c780a380b3abc3370f93037671042a3735d3845b82ca0b635b32adacf",
"md5": "90277048bb678e75891d694982680439",
"sha256": "8c3c98e362bb6025ca12ff250c6ed2c89a8bfff171ed6220c1b38c37dc9ffd96"
},
"downloads": -1,
"filename": "zndraw-0.5.7.tar.gz",
"has_sig": false,
"md5_digest": "90277048bb678e75891d694982680439",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 3396538,
"upload_time": "2024-12-13T13:30:54",
"upload_time_iso_8601": "2024-12-13T13:30:54.120167Z",
"url": "https://files.pythonhosted.org/packages/5f/19/e78c780a380b3abc3370f93037671042a3735d3845b82ca0b635b32adacf/zndraw-0.5.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-13 13:30:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zincware",
"github_project": "ZnDraw",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "zndraw"
}