zndraw


Namezndraw JSON
Version 0.3.0 PyPI version JSON
download
home_page
SummaryDisplay and Edit Molecular Structures and Trajectories in the Browser.
upload_time2024-02-13 18:31:29
maintainer
docs_urlNone
authorzincwarecode
requires_python>=3.10,<4.0
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![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
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "zndraw",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "zincwarecode",
    "author_email": "zincwarecode@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/90/a9/dd8df75f67f5d6800459d94d10424b75a56f3ba813bf8d35323ed5755f87/zndraw-0.3.0.tar.gz",
    "platform": null,
    "description": "[![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://zenodo.org/badge/DOI/10.5281/zenodo.8304530.svg)](https://doi.org/10.5281/zenodo.8304530)\n[![codecov](https://codecov.io/gh/zincware/ZnDraw/graph/badge.svg?token=3GPCKH1BBX)](https://codecov.io/gh/zincware/ZnDraw)\n!['Threejs](https://img.shields.io/badge/threejs-black?style=for-the-badge&logo=three.js&logoColor=white)\n\n# ZnDraw\n\nInstall via `pip install zndraw`. If you have `pip install pywebview` installed,\nZnDraw will open in a dedicated window.\n\n> [!IMPORTANT]\n> 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.\n\n## CLI\n\nYou can use ZnDraw to view a file using the CLI `zndraw traj.xyz`. Supported\nfile formats include everything that `ase.io` can read and additionally `h5`\nfiles in the H5MD standard.\n\nIf you want to view the frames while they are added to the scene you can use\n`zndraw -mp traj.xyz`. See `zndraw --help` for more CLI options.\n\n## Python\n\nZnDraw provides a Python interface. The `zndraw.ZnDraw` object offers `append`,\n`extend` as well as assignment operations. More information is available in the\nexample notebook.\n\n```python\nfrom zndraw import ZnDraw\nimport ase\n\nvis = ZnDraw()\n\nvis.socket.sleep(2) # give it some time to fully connect\nvis[0] = ase.Atoms(\n  \"H2O\", positions=[[0.75, -0.75, 0], [0.75, 0.75, 0], [0, 0, 0]]\n  )\n```\n\nZnDraw also provides an interface to the Python\n[logging](https://docs.python.org/3/library/logging.html) library, including\nsupport for formatters and different logging levels.\n\n```python\nimport logging\n\nlog = logging.getLogger(__name__)\nlog.addHandler(vis.get_logging_handler())\nlog.critical(\"Critical Message\")\n```\n\n## Modifier\n\nYou can register `modifier` to change the scene via the interactions menu.\n\n```python\nimport typing as t\n\nfrom zndraw import ZnDraw\nfrom zndraw.modify import UpdateScene\nimport ase\n\nvis = ZnDraw()\n\nclass MyModifier(UpdateScene):\n  discriminator: t.Literal[\"MyModifier\"] = \"MyModifier\"\n\n  def run(self, vis: ZnDraw, **kwargs) -> None:\n    vis.append(molecule(\"H2O\"))\n\nvis.register_modifier(\n  MyModifier, default=True, run_kwargs={}\n)\n```\n\n## User Interface\n\n![ZnDraw UI](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/zndraw_ui.png \"ZnDraw UI\")\n\n![ZnDraw UI3](https://raw.githubusercontent.com/zincware/ZnDraw/main/misc/zndraw_draw.png \"ZnDraw UI3\")\n\n# Development\n\nZnDraw is developed using https://python-poetry.org/. Furthermore, the\njavascript packages have to be installed using https://www.npmjs.com/.\n\n```bash\ncd zndraw/static/\nnpm install\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Display and Edit Molecular Structures and Trajectories in the Browser.",
    "version": "0.3.0",
    "project_urls": {
        "repository": "https://github.com/zincware/ZnDraw"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28096e41490dc503a6ad6205625ee59c5903ae96c09fed46bd0df4a4a899cfec",
                "md5": "468e1e64937f680db60d33afb3e5c36a",
                "sha256": "b56bd363ef3b359b0b26993e4b59361537f26bf41b3863d52da2c96d9f507ee1"
            },
            "downloads": -1,
            "filename": "zndraw-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "468e1e64937f680db60d33afb3e5c36a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 20611604,
            "upload_time": "2024-02-13T18:31:20",
            "upload_time_iso_8601": "2024-02-13T18:31:20.292506Z",
            "url": "https://files.pythonhosted.org/packages/28/09/6e41490dc503a6ad6205625ee59c5903ae96c09fed46bd0df4a4a899cfec/zndraw-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90a9dd8df75f67f5d6800459d94d10424b75a56f3ba813bf8d35323ed5755f87",
                "md5": "e45e15b72f3f4a99b69adc0cac30a6c6",
                "sha256": "c101c8917132026ab51678b1584f7b2f99aeea6d365b97ce42e9a8779e4a0157"
            },
            "downloads": -1,
            "filename": "zndraw-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e45e15b72f3f4a99b69adc0cac30a6c6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 17323669,
            "upload_time": "2024-02-13T18:31:29",
            "upload_time_iso_8601": "2024-02-13T18:31:29.992967Z",
            "url": "https://files.pythonhosted.org/packages/90/a9/dd8df75f67f5d6800459d94d10424b75a56f3ba813bf8d35323ed5755f87/zndraw-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-13 18:31:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zincware",
    "github_project": "ZnDraw",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "zndraw"
}
        
Elapsed time: 0.17895s