Skip to content

Repository files navigation

Virtual-Screening

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.

Main pipeline: vs_vina_pipeline.py

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:

  1. Prepares the receptor (prepare_receptor4.py, pdb → pdbqt)
  2. 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/.pdb files (prepare_ligand4.py)
  3. Writes a Vina conf.txt for the configured binding site (see BINDING_SITES in the script)
  4. Runs Vina per ligand
  5. Converts docked poses to SDF and extracts the first (best) pose per ligand
  6. Extracts docking energies into a results CSV (utilities/vina_results.py)

Local vs. HPC mode

Set HPC = True/False near the top of the script.

  • Local (HPC = False): run directly, no arguments. Set checkpoint_start to 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, start and end (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.csv so concurrent tasks don't collide. See submit_vina_sge_array.sh for an example array-job submission script (adjust BATCH_SIZE and the qsub -t range to match your ligand count).

Configuration

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

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.

Evaluating against a benchmark (optional)

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:

  1. python evaluation/split_results_for_roc.py results.csv known_actives.txt actives.csv decoys.csv -- known_actives.txt is one active compound name per line (matching the name column of results.csv); everything else in results.csv is treated as a decoy. Converts to the semicolon-separated format the R scripts below expect.
  2. evaluation/roc_curve_enrichment.R (R, needs the ROCR and enrichvs packages) -- edit working_dir/actives_file/ decoys_file/header at the top (header names the score column(s) to evaluate, e.g. c("energy") -- not the name id 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.
  3. evaluation/roc_curve_multi_target.R -- the same idea across several targets at once, overlaid on one ROC plot; edit the targets list 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.

Other scripts

  • parallel_autodock_vs.py — a separate pipeline using AutoDock4 (grid/GA-based, via prepare_gpf4.py/prepare_dpf42.py/Autogrid4/ Autodock4), parallelized locally with multiprocessing.Pool. Not related to the Vina pipeline above — different docking engine entirely.
  • parallel_vina_vs.py — Vina docking parallelized locally across cores with multiprocessing.Pool, for machines without cluster access (as opposed to vs_vina_pipeline.py's HPC array-job mode).
  • submit_vina_sge_array.sh — SGE array-job submission script for vs_vina_pipeline.py's HPC mode.

utilities/

  • vina_results.py — shared extraction()/is_number()/makefile() helpers used by vs_vina_pipeline.py (parses Vina .pdbqt output into a results CSV, writes Vina config files).
  • select_top_compounds.py — copies ligand files whose ID appears in a results.csv into a Top-Selection folder (post-hoc shortlisting).
  • set_mol2_titles_from_filename.py — sets each mol2 file's title to its filename via babel.
  • 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 replaces 0.000 Zn/ 0.000 Ca occupancy values with 2.000 in 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 — removes ROOT/TORSDOF lines from a receptor PDBQT file, in place (for treating it as rigid).
  • batch_convert_pdbqt_results.py — for each subdirectory of a project folder, converts results/*.pdbqt to .mol2 and re-exports each molecule individually with --title set to its filename.
  • set_vina_priority_high.bat / set_vina_priority_low.bat — Windows only: set the running vina.exe process to high or idle CPU priority (via wmic ... setpriority), to speed up docking or let it run in the background without slowing down other programs.

Installing prerequisites

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 the python on your PATH, set python_path to its directory (with a trailing slash, e.g. "/home/you/miniconda3/envs/vina/bin/"); if it is on PATH, leave python_path = "".
  • OpenBabelconda install -c conda-forge openbabel, or openbabel.org. The script calls obabel directly assuming it's on PATH — there's no separate config variable for it, so make sure obabel/babel resolve in whatever shell/environment you run the script from.
  • AutoDock Vinavina.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). Set vina_path to the directory containing the vina executable (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. Set script_path to 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 of vs_vina_pipeline.py for what this looks like on a real install.

About

Scripts for running and parallelizing AutoDock Vina virtual screening (Linux/Windows/SGE cluster)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages