Visualizing Protein Structures in Jupyter Notebook

The Jupyter Notebook is best suited for doing as well as documenting empirical research. It can contain text, code images, videos, interactive content, and also nicely typesetting equations. This makes anyone doing simulations or empirical research prototype their work and share it with their colleagues. The same Jupyter notebook can be used to visualize protein structure.

In this blog post, I am going to show how to use the plus points of the Jupyter notebook to visualize and export protein three-dimensional structures. The protein’s 3D structure is an important factor in deciding their behaviors. Estimating and visualizing 3D structure is used extensively in drug design and allied fields.

The analysis, prediction, and even possible synthesis of 3D protein structures are the requirement for a Computational Biologist. The protein databank contains the 3D structures of various proteins known. The database is freely available for researchers to download and do various types of research on it.

There is a lot of paid software are there to do the 3D visualization. But on the other side, like in every domain, open-source software makes its mark in achieving the requirement needed for a Computational Biologist. This example shows how to visualize the 3D structures of protein data downloaded from PDB and export it into an image using Jupyter Notebook.

The NGLView Library

The key part is to use a library called NGLView to do the visualization. Ideally, we want to generate PNG images for various protein structures. The structures can be downloaded as ‘.pdb’ file from the protein data bank. As an added advantage, we want to automate the conversion to PNG image also. To do that In addition to the NGLview, we need a couple of libraries also. The following code block shows the libraries we needed to import.

Visualize Protein Structure

visualize protein structure

The next step is to get a list of all the PDB files which we downloaded into a folder of our choice.

Once these steps are done we can simply use the NGLview library to visualize the structure of any PDB file. Here I am improvising little bit by using the interact feature in jupyter notebook to change the files as we select from a drop down menu.

To do this we write the visualization part as a function. The arguement of the function becomes the name of the protein file we would like to visualize.

visualize protein structure

The last step is to call the interact function with plotting function we created and list of file names as arguements.

This will launch a drop down menu to select input file and upon selection the 3D structure will be displayed. You can actually rotate the file 360 degree to set the view to desired angle.

visualize protein structure

The selected protein and visualization will be asked to download to the default download location of the browser by the download function. By this was we get to a semi-automated method of converting PDB files to its respective 2D images.

More article on computational biology and bioinformatics can be found here.

Leave a Comment

Your email address will not be published. Required fields are marked *