Python 2 scripts for AutoDock Vina (and, separately, AutoDock4) virtual screening: receptor/ligand preparation, docking, and result extraction. Each script has a hardcoded config block at the top that needs editing for your project before running.
The primary, actively-used Vina pipeline. For a project working directory
(path in the script) containing receptor/ and either a ligands folder
or a (mol_id, SMILES) CSV, it:
- Prepares the receptor (
prepare_receptor4.py, pdb → pdbqt) - Prepares ligands — from a CSV it also generates 3D mol2 files from
SMILES at one or more pH values (
obabel --gen3D), otherwise from an existing folder of.mol2/.pdbfiles (prepare_ligand4.py) - Writes a Vina
conf.txtfor the configured binding site (seeBINDING_SITESin the script) - Runs Vina per ligand
- Converts docked poses to SDF and extracts the first (best) pose per ligand
- Extracts docking energies into a results CSV (
utilities/vina_results.py)
Set HPC = True/False near the top of the script.
- Local (
HPC = False): run directly, no arguments. Setcheckpoint_startto resume from a specific ligand index if a previous run was interrupted; it processes through to the end of the list. - HPC (
HPC = True): intended for an SGE array job. Takes two positional CLI arguments,startandend(python vs_vina_pipeline.py start end), and processes only ligands with index in[start, end)— each array task handles one slice, writing its own<end>_results.csvso concurrent tasks don't collide. Seesubmit_vina_sge_array.shfor an example array-job submission script (adjustBATCH_SIZEand theqsub -trange to match your ligand count).
The script ships configured for the example below by default. For your
own project, edit near the top of the script: path (project directory),
recfile_name, binding_site_name (must be a key in BINDING_SITES, or
add a new one), script_path/vina_path/python_path for your
environment.
example/ has a minimal runnable example (a small public-domain receptor
and a few simple SMILES) that the script points at out of the box — see
example/README.md for the walkthrough.
Before trusting the pipeline on a real prospective screen, it's worth
validating it against a benchmark set of known actives and decoys for a
similar target, to see how well the docking scores actually separate
them. evaluation/ has the tools for that, run after results.csv from
a benchmark run:
python evaluation/split_results_for_roc.py results.csv known_actives.txt actives.csv decoys.csv--known_actives.txtis one active compound name per line (matching thenamecolumn ofresults.csv); everything else inresults.csvis treated as a decoy. Converts to the semicolon-separated format the R scripts below expect.evaluation/roc_curve_enrichment.R(R, needs theROCRandenrichvspackages) -- editworking_dir/actives_file/decoys_file/headerat the top (headernames the score column(s) to evaluate, e.g.c("energy")-- not thenameid column), then source it. Computes AUC and enrichment factors (EF at 100%/20%/10%/2%/1%/0.2%/0.1%) and plots a ROC curve per score column.evaluation/roc_curve_multi_target.R-- the same idea across several targets at once, overlaid on one ROC plot; edit thetargetslist at the top.
These two R scripts were originally a separate repo (Visualisation, now archived); moved here since this is what actually produces their input.
parallel_autodock_vs.py— a separate pipeline using AutoDock4 (grid/GA-based, viaprepare_gpf4.py/prepare_dpf42.py/Autogrid4/Autodock4), parallelized locally withmultiprocessing.Pool. Not related to the Vina pipeline above — different docking engine entirely.parallel_vina_vs.py— Vina docking parallelized locally across cores withmultiprocessing.Pool, for machines without cluster access (as opposed tovs_vina_pipeline.py's HPC array-job mode).submit_vina_sge_array.sh— SGE array-job submission script forvs_vina_pipeline.py's HPC mode.
vina_results.py— sharedextraction()/is_number()/makefile()helpers used byvs_vina_pipeline.py(parses Vina.pdbqtoutput into a results CSV, writes Vina config files).select_top_compounds.py— copies ligand files whose ID appears in aresults.csvinto aTop-Selectionfolder (post-hoc shortlisting).set_mol2_titles_from_filename.py— sets each mol2 file's title to its filename viababel.zinc15script.py— bulk-extracts and converts a downloaded ZINC15 tranche (.gz→.pdbqt), organizing outputs by ZINC ID.fix_ion_occupancy.py— walks a folder and replaces0.000 Zn/0.000 Caoccupancy values with2.000in every file, in place (a fix AutoDockTools-prepared receptors with those ions often need before they'll dock correctly in Vina; moved from the standalone Utilities repo since it belongs with the receptor-prep step here).strip_pdbqt_root_torsdof_lines.py— removesROOT/TORSDOFlines from a receptor PDBQT file, in place (for treating it as rigid).batch_convert_pdbqt_results.py— for each subdirectory of a project folder, convertsresults/*.pdbqtto.mol2and re-exports each molecule individually with--titleset to its filename.set_vina_priority_high.bat/set_vina_priority_low.bat— Windows only: set the runningvina.exeprocess to high or idle CPU priority (viawmic ... setpriority), to speed up docking or let it run in the background without slowing down other programs.
None of these are bundled in this repo (see the licensing note in the CrossDocker README re: MGLTools specifically) — install each separately, then point the script's config variables at them:
- Python 2.7 — e.g.
conda create -n vina python=2.7(also a convenient place to install OpenBabel and Vina below into the same environment). If it's not thepythonon your PATH, setpython_pathto its directory (with a trailing slash, e.g."/home/you/miniconda3/envs/vina/bin/"); if it is on PATH, leavepython_path = "". - OpenBabel —
conda install -c conda-forge openbabel, or openbabel.org. The script callsobabeldirectly assuming it's on PATH — there's no separate config variable for it, so make sureobabel/babelresolve in whatever shell/environment you run the script from. - AutoDock Vina — vina.scripps.edu or
the AutoDock-Vina GitHub releases
(older 1.1.x releases match this script's
vina --ligand ... --config ... --out ...CLI; newer 1.2.x is a superset and should also work). Setvina_pathto the directory containing thevinaexecutable (with a trailing slash), or""if it's on PATH. - MGLTools/AutoDockTools (
prepare_receptor4.py,prepare_ligand4.py) — ccsb.scripps.edu/mgltools. These are Python 2-only tools bundled inside an MGLTools install. Setscript_pathto the.../MGLToolsPckgs/AutoDockTools/Utilities24/subdirectory of wherever you installed it (with a trailing slash) — see the two example values already commented in/out near the top ofvs_vina_pipeline.pyfor what this looks like on a real install.