Molecular visualization in the Jupyter Notebook with nglview

nglview is a Python package that makes it easy to visualize molecular systems, including trajectories, directly in the Jupyter Notebook. The recent 0.4.0 release of nglview brings a convenient interface for visualizing MDAnalysis Universe and AtomGroup objects directly:

import MDAnalysis as mda
import nglview as nv
from nglview.datafiles import PDB, XTC

u = mda.Universe(PDB, XTC)

protein = u.select_atoms('protein')

Although we could use the full Universe, selecting a subset of the atoms as an AtomGroup will give better performance when viewing the trajectory interactively. We can feed this directly to the nglview.show_mdanalysis function to produce the Jupyter widget:

w = nv.show_mdanalysis(protein)

This will give something like this in the notebook itself:

The notebook widget (you’ll have to try it yourself to see — what you see above is a limited view but you can still rotate and zoom the molecule) also lets you select atoms by clicking on the molecule, add custom representations to atom selections, and interactively view different frames of the trajectory, both programmatically and with a graphical slider. Be sure to double-click the notebook viewer widget to have a look at everything in a lovely full-screen view, too!

nglview is just a pip install away:

pip install nglview

Give it a try, and be sure to thank Alexander Rose (@arose) and Hai Nguyen (@hainm) for pushing this project forward!


Google Summer of Code 2016

Google Summer of Code 2016

MDAnalysis has been accepted as a sub-org of the Python software foundation, PSF, for Google Summer of Code 2016. If you are interested in working with us this summer as a student read the advice and links below and write to us on the mailing list.

We are looking forward to all applications from interested students (undergraduates and graduates).

The application window deadline is March 25, 2016 at 12:00 (MST). As part of the application process you must complete all the steps listed under Information for Students and familiarize yourself with Google Summer of Code 2016. Apply as soon as possible.

Project Ideas

We have listed several possible projects for you to work on on our wiki. Each project is rated with a difficulty and lists the possible mentors for it.

Alternatively, if you have another idea about a project please write to us on the developer list and we can discuss it there.

Information for Students

You must meet our own requirements and the PSF requirements if you want to be a student with MDAnalysis this year (read all the docs behind these links!). You must also meet the eligibility criteria.

As a start to get familiar with MDAnalysis and open source development you should follow these steps:

Complete the Tutorial

We have a tutorial explaining the basics of MDAnalysis. You should go through the tutorial at least once to understand how MDAnalysis is used.

Introduce yourself to us

Introduce yourself on the mailing list. Tell us what you plan to work on during the summer or what you have already done with MDAnalysis

Close an issue of MDAnalysis

You must have at least one commit in the development branch of MDAnalysis in order to be eligible, i.e.. you must demonstrate that you have been seriously engaged with the MDAnalysis project.

We have a list of easy bugs to work on in our issue tracker on GitHub. We also appreciate if you write more tests or update/improve our documentation. To start developing for MDAnalysis have a look at our guide for developers and write us on the mailing list if you have more questions about setting up a development environment.


Release 0.14.0

We have just released MDAnalysis version 0.14.0. This release contains a large number of new features and bug fixes. The highlights are listed below but for more details see the release notes.


You can upgrade with pip install --upgrade MDAnalysis

Noticable Changes

Implicit OR in selections

Many long selection strings used in select_atoms have been simplified through allowing implicit OR in the arguments. For example to select all atoms with one of a few names previous required lots of ORs

u.select_atoms('name Ca or name N or name Ch')

u.select_atoms('name Ca N Ch')

The new syntax allows multiple arguments after the keyword name. The selection will keep eating arguments till it hits a keyword. The use of wildcards is still possible too, making the selection of all atoms with a type beginning with ‘C’ or ‘N’ as simple as:

u.select_atoms('type C* N*')

Similarly, for selecting ranges of resids

u.select_atoms('resid 1:10 or resid 40:50 or resid 56 or resid 67')

u.select_atoms('resid 1:10 40:50 56 67')

This new behaviour works for name, type, resname, segid, altLoc, resid, resnum and bynum selections! The old behaviour will still work, but we feel this should save a lot of typing!

Boolean indexing of trajectories

You can now treat trajectories like numpy arrays in a fully pythonic fashion: You could already do fancy indexing and now you can also do boolean indexing. One application is building simple re-usable trajectory filters with ease, e.g., in order to slice data.

# build a filter array for re-use: only frames where the centroids
# of groups A and B are closer than 3 A
idx = [np.linalg.norm(A.centroid() - B.centroid()) < 3.0 for ts in u.trajectory]

for ts in u.trajectory[idx]:
   # analyze the frames where |A - B| distance < 3

for ts in u.trajectory[np.logical_not(idx)]:
   # do analysis on the other frames, |A - B| >= 3

New analysis module to calculate linear densities

The MDAnalysis.analysis.lineardensity module contains the class LinearDensity that simplifies calculation of mass and charge densities profiles along the primary axes of a simulation cell.

Rewrite of TRR and XTC file handling

Our wrapper of the Gromacs library xdrlib has been completely rewritten in cython. This changes brings us one step closer towards supporting Python 3. The only user facing API change is that we don’t save persistent frame offsets with the pickle module anymore but with numpy’s ‘npz’ format. This improves reopening of xtc/trr files.

Experimental Python 3 Support

With this release it is possible to run MDAnalysis under Python 3. We have ported most of our coordinate readers, DCD is still missing, and topology readers to be python2/3 compatible. Most features should already work but expect there to be some minor glitches.


This release contains other performance enhancements and fixes. For a detailed list see the release notes.