Metadata-Version: 2.1
Name: zndraw
Version: 0.3.0
Summary: Display and Edit Molecular Structures and Trajectories in the Browser.
License: Apache-2.0
Author: zincwarecode
Author-email: zincwarecode@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: all
Provides-Extra: rdkit
Requires-Dist: ase (>=3,<4)
Requires-Dist: celery (>=5,<6)
Requires-Dist: datamodel-code-generator (>=0.22,<0.23)
Requires-Dist: decorator (>=5,<6)
Requires-Dist: eventlet (>=0.35,<0.36)
Requires-Dist: flask (>=2,<3)
Requires-Dist: flask-socketio (>=5,<6)
Requires-Dist: mdanalysis (>=2,<3) ; extra == "all"
Requires-Dist: networkx (>=3,<4)
Requires-Dist: pandas (>=2,<3)
Requires-Dist: plotly (>=5,<6)
Requires-Dist: psycopg2-binary (>=2,<3)
Requires-Dist: pydantic (>=2,<3)
Requires-Dist: python-socketio[client] (>=5,<6)
Requires-Dist: rdkit2ase (>=0.1,<0.2) ; extra == "all" or extra == "rdkit"
Requires-Dist: redis (>=5,<6)
Requires-Dist: splines (>=0.3,<0.4)
Requires-Dist: sqlalchemy (>=2,<3)
Requires-Dist: tidynamics (>=1,<2) ; extra == "all"
Requires-Dist: tqdm (>=4,<5)
Requires-Dist: typer[all] (>=0.7,<0.8)
Requires-Dist: znframe (>=0.1,<0.2)
Requires-Dist: znh5md (>=0.1,<0.2)
Project-URL: repository, https://github.com/zincware/ZnDraw
Description-Content-Type: text/markdown

[![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://zenodo.org/badge/DOI/10.5281/zenodo.8304530.svg)](https://doi.org/10.5281/zenodo.8304530)
[![codecov](https://codecov.io/gh/zincware/ZnDraw/graph/badge.svg?token=3GPCKH1BBX)](https://codecov.io/gh/zincware/ZnDraw)
!['Threejs](https://img.shields.io/badge/threejs-black?style=for-the-badge&logo=three.js&logoColor=white)

# ZnDraw

Install via `pip install zndraw`. If you have `pip install pywebview` installed,
ZnDraw will open in a dedicated window.

> [!IMPORTANT]
> ZnDraw has undergone a major change with version 0.3.0. The current version is not fully compatible with Windows. We are investigating solutions to make it work again. Furthermore, if you encounter ZnDraw 0.3.0 to be slower at times, this issue will also be mitigated in future releases.

## CLI

You can use ZnDraw to view a file using the CLI `zndraw traj.xyz`. Supported
file formats include everything that `ase.io` can read and additionally `h5`
files in the H5MD standard.

If you want to view the frames while they are added to the scene you can use
`zndraw -mp traj.xyz`. See `zndraw --help` for more CLI options.

## Python

ZnDraw provides a Python interface. The `zndraw.ZnDraw` object offers `append`,
`extend` as well as assignment operations. More information is available in the
example notebook.

```python
from zndraw import ZnDraw
import ase

vis = ZnDraw()

vis.socket.sleep(2) # give it some time to fully connect
vis[0] = ase.Atoms(
  "H2O", positions=[[0.75, -0.75, 0], [0.75, 0.75, 0], [0, 0, 0]]
  )
```

ZnDraw also provides an interface to the Python
[logging](https://docs.python.org/3/library/logging.html) library, including
support for formatters and different logging levels.

```python
import logging

log = logging.getLogger(__name__)
log.addHandler(vis.get_logging_handler())
log.critical("Critical Message")
```

## Modifier

You can register `modifier` to change the scene via the interactions menu.

```python
import typing as t

from zndraw import ZnDraw
from zndraw.modify import UpdateScene
import ase

vis = ZnDraw()

class MyModifier(UpdateScene):
  discriminator: t.Literal["MyModifier"] = "MyModifier"

  def run(self, vis: ZnDraw, **kwargs) -> None:
    vis.append(molecule("H2O"))

vis.register_modifier(
  MyModifier, default=True, run_kwargs={}
)
```

## User Interface

![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/zndraw_ui.png "ZnDraw UI")

![ZnDraw UI3](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/zndraw_draw.png "ZnDraw UI3")

# Development

ZnDraw is developed using https://python-poetry.org/. Furthermore, the
javascript packages have to be installed using https://www.npmjs.com/.

```bash
cd zndraw/static/
npm install
```

