Display and Edit Molecular Structures and Trajectories in the Browser.
Project description
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.
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 library, including support for formatters and different logging levels.
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.
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
Development
ZnDraw is developed using https://python-poetry.org/. Furthermore, the javascript packages have to be installed using https://www.npmjs.com/.
cd zndraw/static/
npm install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zndraw-0.3.0.tar.gz
.
File metadata
- Download URL: zndraw-0.3.0.tar.gz
- Upload date:
- Size: 17.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c101c8917132026ab51678b1584f7b2f99aeea6d365b97ce42e9a8779e4a0157 |
|
MD5 | e45e15b72f3f4a99b69adc0cac30a6c6 |
|
BLAKE2b-256 | 90a9dd8df75f67f5d6800459d94d10424b75a56f3ba813bf8d35323ed5755f87 |
File details
Details for the file zndraw-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: zndraw-0.3.0-py3-none-any.whl
- Upload date:
- Size: 20.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b56bd363ef3b359b0b26993e4b59361537f26bf41b3863d52da2c96d9f507ee1 |
|
MD5 | 468e1e64937f680db60d33afb3e5c36a |
|
BLAKE2b-256 | 28096e41490dc503a6ad6205625ee59c5903ae96c09fed46bd0df4a4a899cfec |