Installation and Quick Start

Installing chemview with conda is fairly easy. First download anaconda (or miniconda):

To install chemview using conda you can first create an environment (optional):

$ conda create -p /path/to/new/environment python
$ source activate /path/to/new/environment

then, you can install chemview directly from the binstar channel.

$ conda install -c

or, for the development version you can manually install the dependencies:

$ conda install notebook numpy numba
$ git clone
$ cd chemview
$ pip install .

It is also possible to install chemview using pip:

pip install notebook numpy numba # Jupyter 4.x

# Download and install chemview
git clone
cd chemview
pip install .

Chemview has an optional <povray>_ backend for rendering high quality images. For this you’ll need to install the povray software and the vapory bindings:

pip install vapory

Quick Start

In this section we’ll see how to visualize a benzene molecule with chemview. To start, let’s launch IPython notebook and start a new notebook.

To import chemview you can write and execute the following code in a cell:

from chemview import MolecularViewer

The function enable_notebook will load the necessary files to display the molecular viewer in the browser. To display a benzene molecule we need at least two pieces of information:

  1. The atomic types
  2. The atomic coordinates
  3. The bonds between atoms

For the scope of this tutorial, the information were extracted from here. You can use chemical package (like mdtraj or chemlab) to read the coordinates of your molecules.

We define the coordinates as a numpy array, the atomic types as a list of strings and the bonds as a list of start, end tuples.

import numpy as np
coordinates = np.array([[0.00, 0.13, 0.00], [0.12, 0.07, 0.00], [0.12,-0.07, 0.00],
                       [0.00,-0.14, 0.00], [-0.12,-0.07, 0.00],[-0.12, 0.07, 0.00],
                       [ 0.00, 0.24, 0.00], [ 0.21, 0.12, 0.00], [ 0.21,-0.12, 0.00],
                       [ 0.00,-0.24, 0.00], [-0.21,-0.12, 0.00],[-0.21, 0.12, 0.00]])
atomic_types = ['C', 'C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H']
bonds = [(0, 6), (1, 7), (2, 8), (3, 9), (4, 10), (5, 11),
         (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 0)]

We can pass those to the class MolecularViewer and call the method lines to render the molecule as a wireframe:

mv = MolecularViewer(coordinates, topology={'atom_types': atomic_types,
                                            'bonds': bonds})

You can rotate (left click), pan(right click) and zoom (wheel) to visualize your molecules.

Congratulation for finishing the first tutorial! You can now move on more advanced topics: