How to Convert Molecular File Formats with Open Babel (PDB to PDBQT, MOL2 and SDF): A Beginner's Guide - StemSkills Lab
Skip to content

How to Convert Molecular File Formats with Open Babel (PDB to PDBQT, MOL2 and SDF): A Beginner’s Guide

How to Convert Molecular File Formats with Open Babel (PDB to PDBQT, MOL2 and SDF): A Beginner's Guide

To convert a PDB to PDBQT for AutoDock Vina, install Open Babel and run obabel receptor.pdb -O receptor.pdbqt -xr for a rigid receptor, or obabel ligand.pdb -O ligand.pdbqt -p 7.4 for a ligand. The same tool interconverts PDB, PDBQT, MOL2, SDF and SMILES from a single command, adds hydrogens, and generates 3D coordinates, so your structure is docking-ready in minutes.

Almost every docking and molecular dynamics beginner hits the same wall on day one. You download a protein from the RCSB Protein Data Bank as a .pdb file. AutoDock Vina refuses to read it and demands .pdbqt. A force-field parameteriser wants .mol2 or .sdf. Your ligand came as a SMILES string with no 3D shape at all. One free tool clears all of it: Open Babel. This guide from the StemSkills Lab team, drawing on more than a decade in structural bioinformatics and drug design, shows you the exact commands that matter and how to fix the conversions that silently break.

What is Open Babel and why do you need it for docking?

Open Babel is a free, open-source chemistry toolbox that reads and writes chemical file formats and converts between them. Its developers describe it as “a chemical toolbox designed to speak the many languages of chemical data” (O’Boyle et al., 2011). The tool supports more than 110 chemical file formats, which is why it has become the default translator in computational chemistry pipelines (O’Boyle et al., Journal of Cheminformatics, 2011).

You need it because docking and simulation engines each speak a different dialect. AutoDock Vina reads only PDBQT, a PDB variant that stores partial charges (the Q) and AutoDock atom types (the T), as set out in the original Vina paper (Trott and Olson, 2010). GROMACS ligand parameterisation tools expect MOL2 or SDF because those formats record bond orders and charges that a plain PDB does not. Open Babel sits between them and converts on demand.

How do you install Open Babel?

The most reliable route for students is Conda, because it pulls a pre-built binary with no compilation:

  • Conda (Windows, macOS, Linux): conda install -c conda-forge openbabel
  • Ubuntu / Debian: sudo apt-get install openbabel
  • Graphical version: install the cross-platform Open Babel GUI, which wraps the same engine in a point-and-click window if you prefer not to use a terminal.

Confirm the install and check your version with obabel -V. The current stable release is Open Babel 3.1.1. Every command below uses the obabel executable; older tutorials that call babel refer to the legacy 2.x interface, so prefer obabel.

How do you convert a PDB to PDBQT for AutoDock Vina?

This is the conversion most people arrive for. Treat the receptor and the ligand differently.

Receptor (kept rigid):

  • obabel receptor.pdb -O receptor.pdbqt -xr

The -xr output option writes a rigid receptor with no rotatable bonds, which is what Vina expects for the target. Strip waters and any bound ligand from the PDB first, and make sure the structure has hydrogens.

Ligand (with rotatable bonds and charges):

  • obabel ligand.pdb -O ligand.pdbqt -p 7.4

The -p 7.4 flag adds hydrogens for a physiological pH of 7.4. When Open Babel writes a PDBQT ligand it computes Gasteiger partial charges and detects the rotatable-bond torsion tree automatically. If you want the charge model to be explicit, add it: obabel ligand.mol2 -O ligand.pdbqt --partialcharge gasteiger.

One honest caveat: for the receptor, many published protocols still prefer AutoDockTools (prepare_receptor4.py) because it handles chain breaks and alternate conformations more carefully. Open Babel is excellent for ligands and for fast batch conversion, and it is more than enough to get a beginner docking correctly.

Want the guided, hands-on version?

Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.

Join the waitlist (free) →

How do you convert between MOL2, SDF, PDB and SMILES?

Every conversion follows the same pattern: obabel INPUT -O OUTPUT. Open Babel picks the format from the file extension. A few you will use constantly:

  • PDB to MOL2: obabel ligand.pdb -O ligand.mol2
  • PDB to SDF: obabel ligand.pdb -O ligand.sdf
  • PDB to SMILES: obabel ligand.pdb -O ligand.smi
  • SMILES string straight to a file: obabel -:"CC(=O)Oc1ccccc1C(=O)O" -O aspirin.sdf --gen3d
  • MOL2 to PDBQT: obabel ligand.mol2 -O ligand.pdbqt

The -: prefix lets you pass a SMILES string directly on the command line instead of a file, which is handy when you are pulling structures from a database such as PubChem or ChEMBL.

Which molecular file format stores what?

Conversions break when a format cannot hold the information the next tool needs. This table shows what each format carries so you can predict when data will be lost.

Format3D coordinatesBond ordersPartial chargesBest used for
PDBYesNo (CONECT optional)NoDownloading proteins from the RCSB PDB
PDBQTYesNo (torsion tree)Yes (Gasteiger)Input for AutoDock Vina and AutoDock4
MOL2YesYesYes (Tripos/Gasteiger)Ligand parameterisation, force-field setup
SDFYes (if 3D)YesOptional (property block)Compound libraries, virtual screening
SMILESNoYes (implicit)NoStoring 2D identity, database queries

The pattern to remember: a plain PDB has no bond orders or charges, and SMILES has no 3D shape. Any time you go from one of those to a docking or simulation format, you must rebuild the missing information, which is what the next section covers.

When should you add hydrogens and 3D coordinates?

Two situations force an extra step.

Missing hydrogens. Crystallographic PDB files rarely include hydrogen atoms, yet docking and force fields need them. Add them one of two ways:

  • obabel in.pdb -O out.pdb -h adds all hydrogens.
  • obabel in.pdb -O out.pdb -p 7.4 adds hydrogens for a target pH, so acidic and basic groups get the correct protonation state. Use -p for anything you will dock or simulate.

Missing 3D coordinates. A SMILES or 2D structure has no geometry. Generate a 3D conformer with --gen3d:

  • obabel -:"CCO" -O ethanol.sdf --gen3d

Without --gen3d, converting a SMILES to SDF gives you a flat molecule with all atoms at coordinate zero, and docking will fail or return nonsense. Generating 3D coordinates once, then converting to PDBQT, is the correct order.

How do you split or join multi-molecule files?

Screening libraries arrive as one SDF holding thousands of compounds. Open Babel splits and merges them.

  • Split one file into many: obabel library.sdf -O ligand.sdf -m writes ligand1.sdf, ligand2.sdf and so on. The -m flag means “produce multiple output files”.
  • Join many files into one: obabel lig1.mol2 lig2.mol2 lig3.mol2 -O combined.sdf concatenates them into a single multi-molecule SDF.
  • Convert and split in one pass: obabel library.sdf -O ligand.pdbqt -m gives you a separate PDBQT per compound, ready for batch docking.

Troubleshooting: the Open Babel errors that stop beginners

These are the failures that actually cost students an afternoon, with the fix for each.

  • “Failed to kekulize aromatic bonds” or valence warnings. The input PDB has no bond-order information, so Open Babel guesses and sometimes gets aromatic rings wrong. Convert from a format that carries bond orders (MOL2 or SDF) where possible, or download the ligand as SDF rather than PDB.
  • Empty or suspiciously short PDBQT. Usually the input had no hydrogens, so the torsion tree could not be built. Re-run with -p 7.4 to add hydrogens before writing the PDBQT.
  • Charges are all zero. A PDB carries no charges, so a straight PDB-to-PDBQT can lose them. Force the charge model with --partialcharge gasteiger, or route through MOL2 first.
  • Wrong protonation state. Using bare -h ignores pH. For biological targets use -p 7.4 so histidines, carboxylates and amines are protonated realistically.
  • Flat molecule after SMILES conversion. You forgot --gen3d. Add it so the molecule gets real 3D coordinates before docking.

When a conversion looks wrong, open the output in a viewer such as PyMOL or the Open Babel GUI before you dock. A ten-second visual check catches missing hydrogens and broken rings that no error message will warn you about.

Once your receptor and ligand are clean PDBQT files, you are ready for the docking run itself. Work through the full path in our molecular docking learning hub, and see where structure preparation sits in the wider pipeline on the computational biology skills roadmap.

Frequently asked questions

Is Open Babel free to use?

Yes. Open Babel is open-source software released under the GNU GPL, free for academic and commercial use, and it runs on Windows, macOS and Linux.

What is the difference between PDB and PDBQT?

PDBQT is a PDB extended with partial charges (Q) and AutoDock atom types (T), plus a torsion tree that defines rotatable bonds. AutoDock Vina and AutoDock4 read PDBQT; they cannot use a plain PDB.

Do I need AutoDockTools if I have Open Babel?

Not for ligands, where Open Babel is fully sufficient and faster for batches. For receptors, AutoDockTools (prepare_receptor4.py) is often preferred because it handles chain breaks and alternate locations more carefully, but Open Babel with -xr works well for straightforward targets.

Why is my converted molecule flat or missing atoms?

A flat molecule means you converted from SMILES or 2D without --gen3d; add that flag. Missing atoms usually means missing hydrogens; add them with -p 7.4 before converting.

Can Open Babel add hydrogens at a specific pH?

Yes. Use -p followed by the pH, for example -p 7.4, and Open Babel assigns protonation states appropriate to that pH rather than simply saturating every atom.

Want the guided, hands-on version?

Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.

Join the waitlist (free) →

Written by the StemSkills Lab team, computational scientists with more than 10 years of combined experience in sequence and structural bioinformatics, drug discovery and multiscale molecular modeling.

Think you know Molecular Docking?
Take the free StemSkills assessment and earn a verifiable certificate you can download and add to your LinkedIn profile.
Start the free assessment

Keep going

AutoDock Vina Errors and How to Fix Them: The 10 That Stop Beginners Decode the 10 AutoDock Vina errors that stop beginners, from PDBQT parsing failures to grid box mistakes, with… How to Predict a Protein-Protein Complex with AlphaFold-Multimer in ColabFold (Step by Step) Learn how to model a protein-protein complex free in ColabFold, set the chain break correctly, and judge ipTM,… Discovery Studio Visualizer Tutorial: How to Analyse Docking Results and Make 2D Interaction Diagrams Load your docked pose, list every contact with its distance, and export the 2D interaction diagram your thesis…
See live workshops