Skip to main content

v -- A simple X11 molecular viewer

Project description

vmol: v – python binding

This package allows to

  • run v from python scripts and receive its output without calling subprocesses and
  • facilitate installation (especially if it is a dependency).

Inspired by @aligfellow's xyzrender.

Requirements

  • X11
  • numpy
  • cclib (optional, to read formats without native support)

Installation

PyPI has the wheels for CPython 10 through 14 @ manylinux. See install-other.md for other ways to build and install.

pip install vmol[all]       #  install cclib to parse unsupported file formats and open them with vmol2

pip install vmol            #  base version

pip install --no-deps vmol  #  vmol script and "capture the output" will work, 
                            #  but "pass a structure" feature won't work without numpy

For macOS, an X11 server like XQuartz is required:

brew install --cask xquartz

Usage

Scripts

The package provides two scripts to run from the command line

  • vmol, a simple wrapper around v
  • vmol2, a wrapper aroung v to view the file formats that are not supported natively (needs cclib (i.e., vmol[all] or vmol[cclib]))

Both have the same CLI interface as the original v (see the reference).

Native formats (xyz / Priroda):

vmol ../mol/MOL_3525.xyz cell:8.93,0.0,0.0,4.2,8.9,0.0,0.48,2.32,10
python -m vmol../mol/periodic.in bonds:0

Unsupported quantum-chemical outputs, e.g., Orca:

vmol2 ../mol/CEHZOF_1_SPE.out
python -m vmol.vmol2 ../mol/AJALIH_5_SPE.out

or Gaussian:

vmol2 mol/Cat1_TSOA_CfA_Cf0.log vib:0  #  geometry optimization
vmol2 mol/Cat1_TSOA_CfA_Cf0.log        #  normal modes (default for files containing both)

Library

Import the wrapper instance:

>>> from vmol import vmol

It provides the two wrapper functions capture and run along with the path to the shared library so, loaded library lib, and function namespace f.

>>> [*filter(lambda x: not str.startswith(x, '_'), dir(vmol))]
['capture', 'f', 'lib', 'run', 'so']

The shared library is automatically searched for in the current and installation directories:

>>> vmol.so
/home/xe/soft/miniconda3/lib/python3.13/site-packages/vmol/v.cpython-313-x86_64-linux-gnu.so

One can use a custom .so file by setting the attribute

>>> vmol.so = '../v.so'

or the VMOL_SO_PATH environment variable:

export VMOL_SO_PATH=`readlink -m ../v.so`

1. Simple wrapper

Analogous to running vmol script:

from vmol import vmol
vmol.run(['../mol/MOL_3525.xyz', 'cell:8.93,0.0,0.0,4.2,8.9,0.0,0.48,2.32,10'])

The arguments are the same as the CLI ones and should be an array of strings.

2. Capture the output

See example 1.

from vmol import vmol
out = vmol.capture(args=['../mol/MOL_3525.xyz', 'cell:8.93,0.0,0.0,4.2,8.9,0.0,0.48,2.32,10'])
# look at the molecule, press `x`/`z`/`p` to produce an output, close with `q`/`esc`
print(out)

The arguments args are the same as the CLI ones and should be an array of strings.

The return code can be captured as well:

ret, out = vmol.capture(args=['../mol/MOL_3525.xyz', 'cell:8.93,0.0,0.0,4.2,8.9,0.0,0.48,2.32,10'], return_code=True)

Headless mode also works:

>>> vmol.capture(args=['../mol/S8.qm.out', 'gui:0', 'com:.'])
'D8h'
>>> vmol.capture(args=['../mol/S8.qm.out', 'gui:0', 'com:.', 'frame:-1'])
'D4d'

Tell the viewer to automatically print the coordinates before exit:

>>> out = vmol.capture(args=['../mol/rotation1.in', 'exitcom:z'])
>>> print(out)

3. Pass a structure

One can pass a structure (or several structures) as an argument. See example 2.

from vmol import vmol
name = 'HF molecule'
q = [1, 'F']
r = [[0,0,0],[0.9,0,0]]
out = vmol.capture(mols={'q': q, 'r': r, 'name': name}, args=['shell:0.6,0.7'])
# look at the molecule, press `x`/`z`/`p` to produce an output, close with `q`/`esc`
print(out)

Without capturing the output:

vmol.run(args=['shell:0.6,0.7'], mols={'q': [1, 'F'], 'r': [[0,0,0],[0.9,0,0]], 'name': 'hydrogen fluoride'})

ASE Atoms (or anything with .numbers and .positions) are also supported:

import ase.io
mols = ase.io.read('../mol/mol0002.xyz', index=':')
out = vmol.capture(mols=mols)

File formats which are not supported natively can be read with cclib and passed (see example and vmol2 source).

One can also pass normal modes data with

from vmol import vmol
CO2 = {'q': [8, 6, 8], 'r': [(x,0,0) for x in [-1.16, 0, 1.16]], name='CO2'}
sym_stretch  = {'freq': [1480], 'ints': [0], 'mass': [16], 'disp': [[(dx,0,0) for dx in [-1, 0, 1]]]}
vmol.run(mols=CO2, vib=sym_stretch)

Press insert to play the animation. (See example and vmol2 source for more details.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vmol-3.0rc7.tar.gz (14.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vmol-3.0rc7-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (215.3 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vmol-3.0rc7-cp314-cp314t-macosx_15_0_arm64.whl (818.2 kB view details)

Uploaded CPython 3.14tmacOS 15.0+ ARM64

vmol-3.0rc7-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (215.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vmol-3.0rc7-cp314-cp314-macosx_15_0_arm64.whl (818.2 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

vmol-3.0rc7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (215.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vmol-3.0rc7-cp313-cp313-macosx_15_0_arm64.whl (818.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

vmol-3.0rc7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (215.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vmol-3.0rc7-cp312-cp312-macosx_15_0_arm64.whl (818.2 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

vmol-3.0rc7-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (215.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vmol-3.0rc7-cp311-cp311-macosx_15_0_arm64.whl (818.2 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

vmol-3.0rc7-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (215.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

vmol-3.0rc7-cp310-cp310-macosx_15_0_arm64.whl (818.2 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file vmol-3.0rc7.tar.gz.

File metadata

  • Download URL: vmol-3.0rc7.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vmol-3.0rc7.tar.gz
Algorithm Hash digest
SHA256 ed4d7ee51261c7501071144419aaaac7c813f8e4ddda7a99f4e78121b6709339
MD5 5462d6cd2bdc1a7717286a15eefba7ab
BLAKE2b-256 346b379cf34aa261a1e4112e83bfef9b9f4c93b0cb48c8a1a00fe124c1c1a0b2

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9d69abc976c917cfddec4569817482b47f5795be32e8e8e16eccb2fa8c9e12a6
MD5 a1146abf465f753b3c40e3197271cdea
BLAKE2b-256 c074be9e8a7ad7c8c9fc6c48bdea45ea5d691711783f5bd041bce492678acb2f

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp314-cp314t-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp314-cp314t-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 eef9139b632c3ca2f0d4c9c0d1a5403e10300efa89965644f1b36a703bcc9c74
MD5 5868601ea6be44b173bcfb9a7ab998b7
BLAKE2b-256 25bc943b395f31e5cf623f6fc45a97550fe5fa58190549862711a341697c315c

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cae7e754f318aa53ceae6ec0f4c73dc22e204d628dd9a9dfa1ed5347becdc964
MD5 13a86667fc8d2cdaed70cb481ca47c53
BLAKE2b-256 142992a510c689eea1ffbae47e9ee6c4aaaec248c69a3275dc61862524562ef1

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 92a394effb99d7d254ae09a9d5959606919c2a796cb0b076766d9e2ba2decd62
MD5 9434b36b1bff5245a18ac4f18165092f
BLAKE2b-256 513a2153ffe425b876e4244b27896179bb68d9418c080d1cae57e267a2c11a26

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 96af3785b9cd0ae1e7492c61d9cf3fed8e5edfbb4f01f065b79b1d2b1ba16373
MD5 41d050607b38c9cefdefbf15b80d13ec
BLAKE2b-256 786ec08c82dd57dbb8e0a21a7e0ffeb6a992c69650c4e9821a2a310f143a47cd

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 73f0269d6aa90b8f22fb5a861967a0d67b1507e663edac4b8d841addfe2d34d4
MD5 34d70a093e0e63c4efddbf0f921ab7bf
BLAKE2b-256 00f6d5e201413cf121257864bf9b382204b88fbbf129cb2546eb4af865b7c6df

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f296b518955ce4633379d2108d16c88dd9e3abf26993af0576122e6a750af011
MD5 6b6139212ce9cf2b3374ab4671b80d9e
BLAKE2b-256 6c29d39af8fc92bd9f5b52b916893473a17ddc1a13a7a49d467e98abbf36d6ae

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 65edd3f6ccc062e75598e67bc9c16b6ee29267bcda5cc4e4daf4c8b0aebece00
MD5 6028f9bbf102c87247aebe96e9c3e1a2
BLAKE2b-256 61cbcfd9b5a515cd869e0f5b626282a783d64fa98f14cd343af7dffba0f79157

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 be9e9cc37fb1c0906004e5f1facb81f5abdec250063d9395752e84bde8b89311
MD5 962704cc6ceb29f3b1c1084909635c7d
BLAKE2b-256 2f01e62a33fdbc55eca1d72e72d63fa21677026780b2852f48dc91178e58f774

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 213f166e44f8758cabe06a67f2b998034fd85ae17a86ff9e85bcdd6a5760aa46
MD5 79113604f3026465614497634f5f902a
BLAKE2b-256 748bbe67e83d7450919f3b067c208c019a5a88fac6b807ed902e28f111feecd5

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3dd07e2a65b8f1371d5daad66713a458d1028f49a0d110fada7b54ea52934343
MD5 a8e49acf587182227c43ccaf7e0a3b56
BLAKE2b-256 28eaea7a40b25a9062fb857f9443737ce1a5cfd85a012bc1addb85dc11ebbfe3

See more details on using hashes here.

File details

Details for the file vmol-3.0rc7-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for vmol-3.0rc7-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c2b8f83d53a6e0cb448cc0a3ea1f5e675f519dfed13acf6463dbbed0b4427463
MD5 51860d8afbf5d937097eb03efe35e1f8
BLAKE2b-256 830c59cbfc4a27b5d9f5f7e3779d6ce7a70d813c32609393d45d3710ee075f03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page