Skip to main content

v -- A simple X11 molecular viewer

Reason this release was yanked:

critical bug

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.0rc6.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.0rc6-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.0rc6-cp314-cp314t-macosx_15_0_arm64.whl (818.1 kB view details)

Uploaded CPython 3.14tmacOS 15.0+ ARM64

vmol-3.0rc6-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.0rc6-cp314-cp314-macosx_15_0_arm64.whl (818.1 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

vmol-3.0rc6-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.0rc6-cp313-cp313-macosx_15_0_arm64.whl (818.1 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

vmol-3.0rc6-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.0rc6-cp312-cp312-macosx_15_0_arm64.whl (818.1 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

vmol-3.0rc6-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.0rc6-cp311-cp311-macosx_15_0_arm64.whl (818.1 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

vmol-3.0rc6-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.0rc6-cp310-cp310-macosx_15_0_arm64.whl (818.1 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

  • Download URL: vmol-3.0rc6.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.0rc6.tar.gz
Algorithm Hash digest
SHA256 7e52dd6adaaa8edd47b9ea71148c9c9f669608cfc0b3e631b649916c0a7022ad
MD5 588e329a0c2b29af01dbbfd366717529
BLAKE2b-256 025824bb52044a2749a6eb28bf517301c1faf21404aa68d370efea5ca38c576f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5002f3402738aee7e1527ac3a5a7e35e4f36bf75a3e38997acccd155fa77548b
MD5 02c7987cfeb359ff72e49b5690a29605
BLAKE2b-256 a05128132c6172b0f076d423b8444085b209a3f177b0be8879883a69182dc019

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp314-cp314t-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ef95449d355b6e6ae87b524c7d085da475e8091c54b511b7e44ccdf8420effe8
MD5 41c60293826a550e2f2fe004e1da4639
BLAKE2b-256 fbde1238106d6ed216984f03e9b59f5f790aa5a5eaeb8b37dc3f37704026a262

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b4c763bd857ef6cf95b188fe28ba9a141767c86763aa37b3243cdec565685fd1
MD5 2db4c56f7fb10d9617015a9a29edf1a4
BLAKE2b-256 3746e4d26c6effd9539bfebcfa6c73b75e376675a6150629c3fbfc1c420c3155

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d17291a58d8018f019e389bc9ce73d34e801b5e3e6d92eb91a1a26b8b35dfa3b
MD5 1fc281430931bfdfffb8a197bffba779
BLAKE2b-256 12caa5b8d119e98892a3382137a6f25283a8c6b0fe25abc06b18ed351748ed82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2c72efd7757f40629859f4def0a690950c071dcd752ba14cc5c2a44adc85308f
MD5 db2e945081d70af19b8a013b743f1e97
BLAKE2b-256 d49dbf7665b559f3dc8e784f6f5c1dedaf3d6f394a50a7b6abbeb37161431208

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4b1fd67f6be76b641d34e0d68ca9b15d8e16c7dd99c6c4f1c1ef8b263f6b622a
MD5 ed9b04756e55f579f11810904f386fa8
BLAKE2b-256 a16cc8eade7202aacd7aa13768c19c4b4a95fe373a36e1fdadf88b6de84cea7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a0733ffefe297c3ae87f67d822733fecbfb6571f4824eb7e0ec4609b2119fcd4
MD5 2533cd10c6ac458b44eccfa25e639d05
BLAKE2b-256 67e4b93e8f4393ed9e2728b0ab2dfd535527ae04678cb104864a2dcec8e4eedf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 11b60c7afb3189704f039094fb62cf52ff668d2d3f1720a7d1777f958f0ae5d5
MD5 ad959322d4168135ad78845ecf388395
BLAKE2b-256 7744be774200ba4c453bf0cb29a9b05cce28f4211c3f2f773694665ec1b29679

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 af880a1ebade85c2d6cc6d34ff15121da7bcd37dd198aa2e9e1e552b2327a47e
MD5 21ef7fb4a8048812b31b1e6aa801f972
BLAKE2b-256 892c28ba2e4ee6c93c022e22e8866a6eb53ced768bd9fdaceaccd0a5804cb3e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c9ca1afec084d2da6f32bb73f45ddda0d0b0f39d61e7edc1ff0656cf7c1bd298
MD5 485f700cc7e6e2d3113e9c04e065ecfb
BLAKE2b-256 75a5818ea129b8da9ec59af1fb19d6f5486e596b18ab0e3f2241cc4b491179d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 36e92ec4332ddf1f390fac0eb632e561f3b35fca52b2fabfb5da1c1e54975347
MD5 950ee44702faad212d2fe8805df7c3c1
BLAKE2b-256 93b217db0e26764ac7a11b050cc4feea879452af52f28635cc6b952dfd9f7ba4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vmol-3.0rc6-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cc2ba84bbdebe3bce80bea645af9fa4d3cb3210d3532b2be51c63440dca750b2
MD5 89cd98b885ad74f0aea4fe65f08515ea
BLAKE2b-256 725516bf0b2357148f270028672d690aa40394a139621db0503d5d53ec8c7921

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