From PyMOLWiki
Jump to: navigation, search


Vina is a new, very fast, molecular docking program, written by Oleg Trott. In order to run Vina, you should have MGLTools1.5.4 installed (you need and But, you don't need MGLTools for this script to run.

To run Vina it needs to know the center of the protein and also its extents (size in XYZ directions). We can easily do this with PyMOL.


  • COM -- simple script to get the center of mass of a selection


  • Commandline options
  • Robustness to vagaries of input
  • Usage & Help


pymol -cq ./ proteinFile ligandFile

For high-throughput screening, where we compare each ligand to each protein, I typically wrap the script in a for-loop like:

# foreach protein in my proteins directory
for protein in proteinsDir/*; do

  # foreach ligand in my ligands directory
  for ligand in ligandsDir/*; do;

    # make a Vina command to run the protein vs the ligand.
    # note the backticks to run the output
    `pymol -cq ./ $protein $ligand | grep vina`;


The Code

# -*- coding: utf-8 -*-
# -- automatically make a valid Vina command from a PDB file and a ligand (name)
# Author: Jason Vertrees
# Date  : 2/2009
from pymol import cmd
from sys import argv
from os import path

# try to keep PyMOL quiet"disable","all","actions")"disable","all","results")

# prepare some output names
protName= path.basename(argv[-2])
ligName = path.basename(argv[-1])
outName = protName.split(".")[0] + "." + ligName.split(".")[0] + ".docked.pdbqt"
logName = protName.split(".")[0] + "." + ligName.split(".")[0] + ".log"

# very unsafe commandline checking; needs updating
cmd.load(argv[-2], protName)
cmd.load(argv[-1], ligName)

# remove the ligand before calculating the center of mass

# load center of mass script"run /home/path/to/")

# calculate the center of mass and extents
(comX, comY, comZ) = COM(protName)
((maxX, maxY, maxZ), (minX, minY, minZ)) = cmd.get_extent(protName)

# print the command line
print "vina --receptor "+protName"qt --ligand "+ligName+"qt --center_x ", str(comX), " --center_y ", str(comY),\
" --center_z ", str(comZ), " --size_x ", str(abs(maxX-minX)), " --size_y ", str(abs(maxY-minY)), " --size_z ", \
str(abs(maxZ-minZ)), " --all ", outName , " --exhaustiveness 200 --log ", logName, " \n"


# execute the script
> pymol -cq ./ 1ia6_gh09.pdb glucose.pdb | grep vina

# the output
vina --receptor  1ia6_gh09.pdbqt  --ligand  glucose_dimer.pdbqt --center_x  1.86797851457  --center_y  17.7951449088  --center_z  65.2250072289  --size_x  55.9499988556  --size_y  49.7459993362  --size_z  58.1769981384  --all  1ia6_gh09.glucose_dimer.docked.pdbqt  --exhaustiveness 100 --log  1ia6_gh09.glucose_dimer.log

See Also

  • COM -- you need this script
  • Vina -- the docking software