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.
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.0a0.tar.gz
.
File metadata
- Download URL: zndraw-0.3.0a0.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 | 8c064d44f1a62803b0e2e81b21d88b0acaf7504c33c9977e0cbbfa26d87d938a |
|
MD5 | b25bbdbe28c549eb7297c3e9c2c37374 |
|
BLAKE2b-256 | 7865673d011645d76df32cf210ff016567707916774cba50015e68f5461aaa10 |
File details
Details for the file zndraw-0.3.0a0-py3-none-any.whl
.
File metadata
- Download URL: zndraw-0.3.0a0-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 | 86f04db9c56f4b93f065abd07d8c3163da91c2cfa93a4d46599efc365a3c44d6 |
|
MD5 | 1fac9b61df0b9026baa14b8535f9b755 |
|
BLAKE2b-256 | 297946f1e4083ea2ef453ca87bd86b5f0402e9d9d51aeb01c7e85a3355d52665 |