Tuesday, December 10, 2013

Beautiful rendereing of small molecules in Pymol


Getting ready to submit a publication of my FragBuilder paper to PeerJ, I had to make several pictures of peptides and pictures to illustrate dihedral angles in the proteins. 

Personally, a little bit of me dies whenever I see a screenshot from GaussView in a publication. I used Pymol to make the ray-traced 3D models. One example is shown below, and I think it came out pretty great. Note that I added the torsion angles in LibreOffice Draw manually.





 The Pymol commands to  make the above figure are:

load my_molecule.xyz
color grey05, elem c
bg_color white
preset.ball_and_stick(selection='all', mode=1)
set ray_trace_mode, 4

Once you have oritented the molecule to the position you want in your picture, type in the console:

ray

Then export the resulting image to a .png file.

Happy Pymol'ing

Thursday, December 5, 2013

Compiling Open Babel with Python bindings

Use the commands below to compile Open Babel with python bindings: 

git clone git://github.com/openbabel/openbabel.git
cd openbabel
mkdir build
cd build
cmake -DRUN_SWIG=ON -DPYTHON_BINDINGS=ON \
-DCMAKE_INSTALL_PREFIX=/opt/openbabel  -DENABLE_TESTS=ON ..
make
make test
sudo make install

Export these variables to use your newly compiled Open Babel:

export PYTHONPATH=/opt/openbabel/lib/python2.7/site-packages:\$PYTHONPATH
export LD_LIBRARY_PATH=/opt/openbabel/lib:\$LD_LIBRARY_PATH
export PATH=/opt/openbabel/bin:\$PATH

Wednesday, December 4, 2013

Constraint optimization in Python with Open Babel

This post is just a quick post to show, how you can optimize molecules with harmonic constraints in Python with Open Babel. This requires Open Babel to be compiled with Python SWIG-bindings.

There are three types of constraints, distances, angles and torsions. Here is a gist that might help get you started.



Acknowledgements: Kasper Thofte pretty much wrote the above gist back in the days.