How to Remove Water Molecules From a PDB File for Docking - StemSkills Lab
Skip to content

How to Remove Water Molecules From a PDB File for Docking

How to Remove Water Molecules From a PDB File for Docking

Open the structure in PyMOL and run remove solvent, or in ChimeraX run delete solvent, then delete crystallisation additives such as glycerol and sulfate while keeping catalytic metals and cofactors. Save the result as a new PDB file. Delete a water only after checking it is not a conserved, buried bridge inside the binding site.

This is the first thing you will ever do to a structure you downloaded, and it is also the step most likely to make everything downstream quietly wrong. The RCSB Protein Data Bank holds more than 200,000 experimentally determined structures, and almost none of them are ready to dock into as they come. A crystallographic file is a record of what was in the crystal: the protein, the ligand if there was one, catalytic metals, and also several hundred ordered water molecules plus whatever glycerol, sulfate, buffer and cryoprotectant happened to be ordered enough to model.

Deleting all of that is usually correct. Sometimes it is a mistake that costs you the whole result. This guide, written by the StemSkills Lab team from 10+ years in sequence and structural bioinformatics, drug discovery and design, and multiscale molecular modeling, gives you the exact commands in three environments, plus the decision rule for the waters you should not touch. If you have not run a docking job yet, start with our molecular docking pillar guide and come back to this page when you have a structure open.

What exactly are you deleting when you clean a PDB file?

A PDB coordinate file has two coordinate record types. ATOM lines hold the standard polymer: the 20 standard amino acids and the standard nucleotides. HETATM lines hold everything else. The wwPDB PDB File Format Contents Guide defines those records as holding “the atomic coordinate records for atoms within ‘non-standard’ groups”.

That single category is doing a lot of work. It contains four very different kinds of thing, and the reason beginners break their own receptors is that they treat all four the same way:

  • Water. Residue name HOH (and DOD for deuterated water in neutron structures). Usually the largest group of HETATM records in the file.
  • Crystallisation and cryoprotection junk. Glycerol, ethylene glycol, sulfate, acetate, buffer components. Present because of how the crystal was grown, not because of biology.
  • Functional groups you must keep. Catalytic zinc, magnesium, heme, NAD, FAD, SAM. Delete these and you are docking into a protein that cannot work.
  • Modified residues that are part of the backbone. Selenomethionine (MSE) is the common one. It sits on HETATM lines but it is a residue in the chain. Delete it and you punch holes in the protein.

Before you delete anything, look at what is actually in your file. This one line counts every HETATM residue type by its three-letter code, reading columns 18 to 20 where the residue name lives:

grep '^HETATM' 1hvr.pdb | cut -c18-20 | sort | uniq -c | sort -rn

Run it on every new structure. Thirty seconds here saves you from a silent failure two days later.

How do you remove water molecules from a PDB file in PyMOL?

PyMOL has a built-in selection keyword, solvent, which resolves to waters. The whole cleanup is four lines:

fetch 1hvr, async=0
remove solvent
remove not polymer
save receptor_clean.pdb

remove solvent deletes only waters and is identical to remove resn HOH. remove not polymer is the aggressive follow-up: it strips every non-polymer heteroatom, which means the co-crystallised ligand, the ions, the glycerol and the cofactors all go at once. That is the right move for a straightforward soluble enzyme with no metal, and the wrong move for a zinc protease. Use the targeted form instead when you need to keep something:

remove solvent
remove resn GOL+EDO+SO4+PO4+ACT+MPD+DMS+TRS+FMT+PEG

To keep a specific water, name it in a selection first and subtract it. This keeps every water within 3.5 A of the bound ligand and deletes the rest:

select keep_wat, solvent within 3.5 of organic
remove solvent and not keep_wat

PyMOL scripts run headless, so once the sequence works you can put it in clean.pml and call pymol -cq clean.pml from a shell loop over a hundred structures. The PyMOL documentation for the remove command lists the full selection algebra.

How do you do it in ChimeraX or UCSF Chimera?

ChimeraX has the same idea with different vocabulary. solvent and ligand are built-in classifications, so you rarely need residue names at all:

open 1hvr
delete solvent
delete ligand
save receptor_clean.pdb

To keep one water, subtract its atom specification. Chain A residue 301 is written /A:301:

delete solvent & ~/A:301

The ChimeraX delete command documentation and the atom specification page cover the zone syntax if you want distance-based selections instead. The older UCSF Chimera accepts delete solvent and delete ligand as well, so a workflow written for one usually transfers.

ChimeraX is the better choice when you want to see what you are deleting. Colour the heteroatoms first, orbit the binding site, then decide. That habit is worth more than any command in this article.

What is the fastest command line way to strip waters and heteroatoms?

For scripted pipelines, use pdb-tools, a set of single-purpose command line utilities from the Bonvin lab published by Rodrigues and colleagues in F1000Research. Each tool does one thing and reads from standard input, so you chain them:

pip install pdb-tools
pdb_fetch 1hvr | pdb_delresname -HOH | pdb_tidy > 1hvr_nowat.pdb

Swap in pdb_delhetatm to drop every HETATM record at once, or list several codes to delete: pdb_delresname -HOH,GOL,SO4.

If you cannot install anything, awk on the fixed columns is exact and dependency free. Columns 18 to 20 hold the residue name:

awk '!(substr($0,1,6)=="HETATM" && substr($0,18,3)=="HOH")' 1hvr.pdb > 1hvr_nowat.pdb

Do not use a bare grep -v HOH. The string HOH also appears in FORMUL, HETNAM and REMARK lines, and in rare cases inside a sequence record, so you will strip header information you did not intend to touch. The column-aware form above cannot make that mistake.

The one shortcut to avoid entirely is grep '^ATOM' as a cleanup step. It keeps only standard polymer atoms, which sounds right and is fine for a plain soluble protein, but it silently deletes selenomethionine residues in a SeMet-phased structure and leaves you with gaps in the backbone.

Which method should you use?

MethodCommand to strip all watersCan keep chosen watersRuns without a GUIBest for
PyMOLremove solventYes, via a named selectionYes, pymol -cq script.pmlInspect visually, then script the same commands in bulk
ChimeraXdelete solventYes, via an atom specificationYes, --noguiVisual triage of an unfamiliar structure
pdb-toolspdb_delresname -HOHNo, it works by residue nameYesReproducible shell pipelines and batch jobs
awk on columnssubstr($0,18,3)=="HOH"Only with extra conditionsYesClusters with nothing installed, very large files
prepare_receptor4.py-U nphs_lps_waters_nonstdresYes, drop waters from the listYesDoing the cleanup inside PDBQT conversion

That last row matters more than students expect. In AutoDockTools, prepare_receptor4.py already applies a cleanup while it writes the PDBQT, and its default is nphs_lps_waters_nonstdres: merge non-polar hydrogens, merge lone pairs, remove waters, remove chains made entirely of non-standard residues. So the standard receptor preparation command deletes waters whether or not you asked:

prepare_receptor4.py -r receptor_clean.pdb -o receptor.pdbqt \
  -U nphs_lps_waters_nonstdres

If you deliberately kept a structural water in the PDB, you have to drop waters from that string or the conversion will throw it away again:

prepare_receptor4.py -r receptor_with_w301.pdb -o receptor.pdbqt \
  -U nphs_lps_nonstdres

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) →

Which heteroatoms must you keep?

Sort every code your uniq -c command printed into three buckets. The codes below are real PDB Chemical Component Dictionary identifiers, and you can look any of them up at rcsb.org/ligand/<code>.

BucketTypical codesWhat to do
Delete almost alwaysHOH, GOL (glycerol), EDO (ethylene glycol), PEG and PGE, SO4, PO4, ACT (acetate), FMT (formate), MPD, DMS, TRS (Tris), EPE (HEPES), IMD (imidazole), CIT (citrate)Artefacts of crystallisation and cryoprotection. Remove before docking.
Keep, they are part of the targetZN, MG, MN, FE, CA, HEM, NAD and NAP, FAD and FMN, SAM and SAH, ANP, PLPCatalytic metals and cofactors. Deleting them changes the pocket shape and its charge.
Keep, but move to a separate fileThe co-crystallised ligand codeDelete from the receptor, save separately. You need it to place the grid box and to redock as a positive control.
Judgement callMSE, NAG and other glycans, lipids, second-site ionsMSE is backbone, always keep. Glycans and lipids only matter if they touch your site.

A practical warning about metals. Because prepare_receptor4.py also removes chains composed entirely of non-standard residues, an ion deposited on its own chain can disappear during PDBQT conversion even though you kept it in the PDB. Always confirm afterwards:

grep -E 'ZN|MG|MN' receptor.pdbqt

When should you keep a water molecule instead of deleting it?

The textbook case is HIV-1 protease. A single water, conventionally numbered 301, sits between the two flaps and bridges the Ile50 and Ile50′ backbone amides to the carbonyl groups of bound peptidomimetic inhibitors. It is not solvent noise, it is part of the binding site. The DuPont Merck team designed cyclic urea inhibitors specifically to displace it, replacing that bridging water with a urea carbonyl built into the ligand itself, reported by Lam and colleagues in Science in 1994. Dock into an HIV protease structure with water 301 stripped out and you are docking into a pocket that is roughly one water molecule too large in exactly the place that matters.

Ladbury reviewed this class of behaviour in Chemistry & Biology in 1996, and the same pattern shows up in thrombin, scytalone dehydratase and the oligopeptide-binding protein OppA. Bridging waters are common enough that “delete them all” is a default, not a rule.

Use this checklist on any water sitting inside your binding site. Keep it only if the answer is yes to most of these:

  1. Is the structure good enough? Individual water positions only mean something when the resolution supports them. Below roughly 2.5 A, treat modelled waters with suspicion. Check the resolution and the per-residue fit in the wwPDB validation report linked from the entry page.
  2. Is it buried? A water in a closed cavity with little solvent exposure behaves like part of the protein. One on the surface does not.
  3. Does it hydrogen bond to the protein, not just to the ligand? Three or more contacts to protein donors and acceptors is the signal you want. A water held only by the ligand will not be there before the ligand arrives.
  4. Is it conserved? This is the strongest test. Superpose three or four independent structures of the same protein, ideally with different ligands and from different groups, and see whether a water recurs in the same position. Recurrence across unrelated experiments is hard to fake.
  5. Is its B-factor reasonable? Compare it with nearby protein atoms. A water with a much higher B-factor than its neighbours is poorly ordered.

When you do keep one, remember what AutoDock Vina will do with it. Vina treats the receptor as rigid, so a retained water becomes a fixed obstacle with fixed hydrogen bonding geometry. That helps when the water really is conserved and hurts when it is not, which is why the honest answer for a thesis chapter is to run both versions and report the difference. See the official AutoDock Vina documentation for the receptor preparation steps that follow.

One more distinction that trips people up: cleaning for docking and cleaning for MD are not the same job. For a molecular dynamics run you are going to solvate the system anyway, and bulk water added by a solvation tool is poor at filling small buried cavities. So for MD you delete the crystallisation additives but usually keep the crystallographic waters, letting the simulation decide which ones stay. For rigid receptor docking you strip them, with the deliberate exceptions above.

Troubleshooting: real failures and their fixes

  • Your receptor has gaps in the backbone after cleanup. You used grep '^ATOM' or pdb_delhetatm on a selenomethionine structure and deleted every MSE residue. Redo the cleanup with remove solvent or pdb_delresname -HOH, which target waters by name instead of deleting the whole HETATM class.
  • Waters are still in the PDBQT after you deleted them. You cleaned one copy of the file and converted a different one. Check that the -r path in prepare_receptor4.py points at the cleaned file, then grep -c HOH receptor.pdbqt to confirm.
  • The water you deliberately kept vanished. The default -U nphs_lps_waters_nonstdres removed it during conversion. Use -U nphs_lps_nonstdres instead.
  • Vina stops with a parse error pointing at a line in the PDBQT. A frequent cause is alternate conformations: residues modelled in two positions with altLoc indicators A and B produce duplicated atoms. Keep one before converting, with remove not alt ''+A in PyMOL or pdb_selaltloc -A in pdb-tools.
  • Your best pose sits exactly where a water used to be. That is the failure mode this whole article exists to prevent. Superpose two or three other structures of the same target and check whether a conserved water occupies that spot. If it does, rebuild the receptor with the water kept and redock.

Where this fits in your training

File cleanup sits between structure selection and receptor preparation, and it is the step that most often decides whether a docking result is defensible in a viva. The full sequence, from choosing a structure to validating poses, is laid out in our computational biology skills roadmap, and the docking-specific parts are covered in the molecular docking guide.

Frequently asked questions

Should I remove all water molecules before docking?

As a default, yes. Remove all waters for a first rigid receptor docking run, because a crystallographic water not present in your system of interest will block poses that should be allowed. The exception is a buried, conserved, protein-bridging water in the binding site, which behaves as part of the receptor and should be kept.

What is the difference between ATOM and HETATM in a PDB file?

ATOM records hold standard polymer residues, the 20 standard amino acids and standard nucleotides. HETATM records hold everything else: water, ligands, ions, cofactors and modified residues such as selenomethionine. Deleting all HETATM records is not the same as deleting water, and on a SeMet structure it damages the protein chain.

Does removing waters change the docking score?

Yes, and often substantially. Waters occupy volume inside the pocket, so removing them enlarges the accessible site and lets ligands adopt poses that the real, hydrated protein would not allow. Scores from a stripped receptor and a water-retained receptor are not comparable, so state which you used in any report.

How do I remove waters from a mmCIF file instead of a PDB file?

The same logic applies to the atom_site category, where the residue name is label_comp_id. Both PyMOL and ChimeraX read mmCIF directly, so remove solvent and delete solvent work unchanged, and pdb-tools provides pdb_fromcif if you need to convert first.

Should I keep the co-crystallised ligand in the receptor file?

No. Delete it from the receptor, but save it to its own file first. You need its coordinates to centre the grid box, and redocking it to see whether you can reproduce the crystallographic pose is the standard positive control for your whole protocol.

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) →

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

How to Dock a Ligand to a GPCR or Membrane Protein with AutoDock Vina (Step by Step) Dock a ligand into a GPCR with AutoDock Vina: pick the right activation state, strip BRIL and T4… 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,…
See live workshops