Visualize molecular orbital is one of the good way for understating molecular reactivity. Opensource quantum chemistry package ‘Psi4’ can generate cube file for MO rendering and psikit has function for rendering MO with pymol. Here is an example notebook.
https://github.com/Mishima-syk/psikit/tree/master/examples/Rendering_Orbital_in_PyMol
And recently I found new tool for cube file rendering named fortecubeview package. The license of the package is MIT ;).
So I tried to use it with psikit. Because it is easy to generate cubefiles with psikit. And fortecubeview can render cubefiles only calling plot function.
Ok, let’s install the package at first.
$ mamba install -c conda-forge pythreejs
$ pip install fortecubeview
# install the extension for jupyter notebooks
$ jupyter nbextension install --py --symlink --sys-prefix pythreejs
$ jupyter nbextension enable --py --sys-prefix pythreejs
# Next launch jupyter-notebook
$ jupyter-notebook
I changed tempdir from default setting to other place. All cube files will be stored in my defined path. First molecule is nitro benzene. (scf/6-31** level)
from psikit import Psikit
import fortecubeview
import os
pk = Psikit()
pk.tempdir ='/home/iwatobipen/dev/sandbox/rdk/psi4test/tmp1'
os.mkdir(pk.tempdir)
pk.read_from_smiles('c1ccccc1N(=O)=O')
pk.optimize()
pk.create_cube_files(gridspace=0.5)
fortecubeview.plot(path=pk.tempdir, width=600, height=300, colorscheme='national', sumlevel=0.7)

Fortecubeveiw provides select box for cubefiles and user can interactively change drawing target.

Next, draw metoxy benzene.
pk = Psikit()
pk.tempdir ='/home/iwatobipen/dev/sandbox/rdk/psi4test/tmp2'
os.mkdir(pk.tempdir)
pk.read_from_smiles('c1cc(O)ccc1')
pk.optimize()
pk.create_cube_files(gridspace=0.5)
fortecubeview.plot(path=pk.tempdir, width=600, height=300, colorscheme='national', sumlevel=0.7)

There is a difference the shape of HOMO orbital between nitro-benzene and methoxy-benzene. HOMO lobe of nitro-benzene can see on metha and ortho positions. Nitoro benzene has an ortho orientation for electrophilic substitution reaction. On the other hand, HOMO lobe of methoxy benzene can see on ortho and para positions. It means that methoxy-benzene has ortho- para- orientations for electrophilic substitution reaction.
In summary, fortecubeveiw is a convenient tool for cube file visualization. If we run psi4 against more large biological system such as X-ray crystal structure, can we visualize protein-ligand interaction? It seems interesting.
I uploaded today’s notebook on my gist.