Skip to main content

A molecular viewer for ASE (Atomic Simulation Environment) data

Project description

aseview

Molecular structure viewer for ASE (Atomic Simulation Environment).

Docs  ·  DeepWiki

Installation

pip install aseview

For development:

git clone https://github.com/kangmg/aseview.git
cd aseview
pip install -e .

CLI Usage

# Basic usage
aseview molecule.xyz

# View trajectory (all frames)
aseview trajectory.xyz -i :

# View specific frames
aseview trajectory.xyz -i 0:10    # frames 0-9
aseview trajectory.xyz -i -1      # last frame
aseview trajectory.xyz -i ::2     # every 2nd frame

# Specify file format
aseview POSCAR -f vasp

# Custom port
aseview molecule.xyz -p 9000

# Overlay multiple structures
aseview reactant.xyz product.xyz

# Overlay with colormap
aseview trajectory.xyz -v overlay --cmap viridis

# Normal mode visualization with ORCA Hessian
aseview molecule.xyz --hess orca.hess

# Save as HTML file
aseview molecule.xyz -o output.html

# Kill existing server on port
aseview molecule.xyz -k

# Help
aseview -h

SSH Port Forwarding

When running on a remote server (e.g., HPC cluster, Docker container):

# 1. On remote server
aseview molecule.xyz -p 8080

# 2. On local machine (separate terminal)
ssh -L 8080:localhost:8080 user@remote-server

# 3. Open in local browser
# http://localhost:8080

For Docker with custom SSH port:

# Connect with port forwarding
ssh user@localhost -p 10011 -L 8080:localhost:8080

# Then run aseview inside container
aseview molecule.xyz -p 8080

Jupyter Notebook

Quick Start

from ase.io import read
from aseview import MolecularViewer

atoms = read('molecule.xyz')
viewer = MolecularViewer(atoms)
viewer.show()

With Trajectory

from ase.io import read
from aseview import MolecularViewer

# Read all frames
trajectory = read('trajectory.xyz', index=':')
viewer = MolecularViewer(trajectory)
viewer.show()

Overlay Multiple Structures

from ase.io import read
from aseview import OverlayViewer

reactant = read('reactant.xyz')
product = read('product.xyz')
viewer = OverlayViewer([reactant, product])
viewer.show()

Overlay with Colormap

from ase.io import read
from aseview import OverlayViewer

trajectory = read('optimization.xyz', index=':')
viewer = OverlayViewer(
    trajectory,
    colorBy='Colormap',
    colormap='viridis'  # viridis, plasma, coolwarm, jet, rainbow, grayscale
)
viewer.show()

Align Molecules (RMSD Minimization)

from ase.io import read
from aseview import OverlayViewer

structures = [read(f'conf{i}.xyz') for i in range(5)]
viewer = OverlayViewer(
    structures,
    alignMolecules=True,  # Kabsch rotation + Hungarian reordering
    colorBy='Molecule'
)
viewer.show()

Normal Mode Visualization

From ASE Vibrations

from ase import Atoms
from ase.calculators.emt import EMT
from ase.optimize import BFGS
from ase.vibrations import Vibrations
from aseview import NormalViewer

# Create or load molecule
atoms = Atoms('H2O', positions=[[0, 0, 0], [0.96, 0, 0], [-0.24, 0.93, 0]])
atoms.calc = EMT()

# Optimize structure
opt = BFGS(atoms)
opt.run(fmax=0.01)

# Calculate vibrations
vib = Vibrations(atoms, name='vib')
vib.run()
vib.summary()

# Visualize normal modes
viewer = NormalViewer(atoms, vibrations=vib)
viewer.show()

From ORCA Hessian File

from ase.io import read
from aseview import NormalViewer

atoms = read('molecule.xyz')
viewer = NormalViewer.from_orca(atoms, 'orca.hess')
viewer.show()

Features:

  • Mode selector dropdown with frequencies
  • Sinusoidal animation of atomic displacements
  • Amplitude slider to control displacement magnitude
  • Show Vectors toggle to display mode displacement arrows
  • Imaginary frequencies (transition states) shown in red

Using view_molecule Helper

from aseview.jupyter import view_molecule
from ase.io import read

atoms = read('molecule.xyz')
view_molecule(atoms, viewer_type='molecular', height=600)

Custom Settings

from aseview import MolecularViewer

viewer = MolecularViewer(
    atoms,
    style='neon',           # default, cartoon, neon, glossy, metallic, rowan, grey
    bondThreshold=1.2,      # bond detection scale factor
    atomSize=0.5,
    showCell=False,
    backgroundColor='#000000',
    showPolyhedron=True,    # coordination polyhedra (solid-state, CN >= 4)
    polyhedronOpacity=0.25,
    showRings=True,         # ring face highlighting (molecules, 4-8 atom rings)
    ringOpacity=0.35,
)
viewer.show(width='100%', height=800)

Save to HTML

viewer.save_html('output.html')

Viewer Types

Viewer Description
MolecularViewer Single structure or trajectory animation
NormalViewer Normal mode vibration visualization
OverlayViewer Compare multiple structures overlaid

JavaScript Module

Use aseview in any web page without Python:

<div id="viewer" style="width:100%; height:500px;"></div>

<script src="https://raw.githack.com/kangmg/aseview/main/aseview/static/js/aseview.js"></script>
<script>
    const viewer = new ASEView.MolecularViewer('#viewer');
    viewer.setData({
        symbols: ['O', 'H', 'H'],
        positions: [
            [0.0, 0.0, 0.117],
            [0.0, 0.757, -0.469],
            [0.0, -0.757, -0.469]
        ]
    });
</script>

See the JavaScript Module documentation for full API reference.

Supported Formats

All formats supported by ASE: xyz, cif, pdb, POSCAR, extxyz, etc.

License

MIT

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

aseview-0.0.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

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

aseview-0.0.2-py3-none-any.whl (289.7 kB view details)

Uploaded Python 3

File details

Details for the file aseview-0.0.2.tar.gz.

File metadata

  • Download URL: aseview-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aseview-0.0.2.tar.gz
Algorithm Hash digest
SHA256 55f8dad21b0c08ca1b4c2a4cffc731b6728c1334c5b96f2e03aaff16acdeb7e6
MD5 2426ecd620b04ad8fa95fcde3f1622aa
BLAKE2b-256 defec2f6736998966773bad3671708e1c5fcf65f04361352b0e4746303eabcaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for aseview-0.0.2.tar.gz:

Publisher: publish.yml on kangmg/aseview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aseview-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: aseview-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 289.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aseview-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 970cee2d89e2df87c293daad9bb18bfde77413fdcd044b49d6fe7f0568c3a3ea
MD5 5242533b5afeac932e2c29f0c0aa3284
BLAKE2b-256 0bff6acc8414687159b443a4b9452b298a8291b8ea9acae5698e9933c833e2e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for aseview-0.0.2-py3-none-any.whl:

Publisher: publish.yml on kangmg/aseview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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