Monday, November 30, 2026

DNA and Protein Language Models (DNABERT, ESM, Enformer): What They Actually Do

 

If you follow bioinformatics news, you've seen the headlines: "A language model for proteins." "An AI that reads DNA." "A foundation model for the genome."

The names are everywhere: ESM, DNABERT, Nucleotide Transformer, Enformer, AlphaGenome, AlphaFold. But very few explain, in simple words, what these models actually do, what they're good at, and where they fall short.

In the last posts, we looked at structure: docking and molecular dynamics. Those methods start from a 3D structure. This post goes one level earlier, to the sequence itself. Can a model learn useful biology just by reading millions of DNA or protein sequences?

By the end, you'll know:

  • what a "language model" is, without the jargon
  • why DNA and proteins are called "languages"
  • what ESM, DNABERT, Enformer and AlphaGenome actually do (and how they differ)
  • how these models connect to AlphaFold and protein structure
  • what they're good at, and where they fail
  • how to try a protein language model yourself with a few lines of Python
  • how to judge any new model critically

No machine learning background is needed.


Part 1: The Basics

What is a language model?

A language model is a program trained to predict missing or next pieces of a sequence.

You already use one. When your phone suggests the next word while typing, it's guessing which word is most likely to come next, based on patterns it learned from lots of text.

There are two common training styles:

StyleThe taskSimple example
Masked language modelFill in the hidden piece"The cat sat on the ___"
Autoregressive modelPredict the next piece"The cat sat on the" → "mat"

To get good at this, the model has to learn the patterns and rules of the data. It is never told these rules. It discovers them from the examples. This is called self-supervised learning: the data itself provides the "answers" (the hidden pieces), so no human labeling is needed.

Why call DNA and proteins "languages"?

It's an analogy, but a useful one:

LanguageDNAProtein
Alphabet4 letters (A, C, G, T)20 amino acids
WordsMotifs, regulatory elementsMotifs, domains
GrammarRules for gene regulation, splicingRules for folding and function
MeaningWhat the sequence doesWhat the protein does

Sequences are not random. Evolution has kept patterns that work and removed ones that don't. A protein that folds and functions has a "grammar" that real sequences follow. A model that reads millions of real protein sequences can learn this grammar.

A word of caution: the analogy has limits. DNA and proteins aren't human languages, and a model that predicts the next letter well hasn't necessarily "understood" biology. We'll come back to this.

What does "training" and "using" a model mean?

TermSimple meaning
TokenOne piece of input (a nucleotide, a k-mer, an amino acid)
EmbeddingA list of numbers that represents a sequence (or a position)
Pre-trainingLearning general patterns from a huge amount of unlabeled data
Fine-tuningFurther training on a small, labeled dataset for a specific task
Zero-shotUsing the model as-is, with no extra training
ProbingTraining a small, simple model on top of the frozen model's embeddings
ParametersThe numbers a model learns (more parameters = bigger model)

If you read the last newsletter on foundation models, these ideas will feel familiar: a foundation model is pre-trained on lots of data, then reused for many tasks.


Part 2: Protein Language Models (the ESM Family)

What is ESM?

ESM (Evolutionary Scale Modeling) is a family of protein language models. They read protein sequences, hide some amino acids, and learn to predict the hidden ones.

The family has grown over time:

  • ESM-1b: a 650-million-parameter model trained on 250 million protein sequences from across all organisms. nih
  • ESM-1v: focused on predicting the effect of mutations without extra training.
  • ESM-2: a larger and improved family that also powers ESMFold, a model that predicts structure directly from a single sequence.
  • ESM-3: a multimodal generative model that can reason over protein sequences, structures and functions. arxiv

(Model versions and releases change quickly, so check the official repositories for the latest.)

What does it actually learn?

To predict a hidden amino acid well, the model has to know which amino acids tend to appear in which contexts: which residues sit together, which positions are conserved, which substitutions are tolerated. This reflects evolutionary constraints.

The model turns each protein into embeddings, numbers that capture patterns useful for many tasks.

What can you do with it?

1. Get embeddings for any protein
Use them as input for your own classifier (for example, predicting function, localization or stability).

2. Predict the effect of mutations (zero-shot)
Mask a position and compare how likely the model finds the original amino acid versus the mutant. If the mutant is much less likely, the change may be damaging. This "masked marginals" approach lets models predict variant effects without task-specific training.

At scale, researchers used ESM-1b to predict the effects of about 450 million possible missense variants in the human genome.

3. Predict structure (ESMFold)
ESMFold predicts 3D structure from a single sequence, without the multiple sequence alignment (MSA) step that AlphaFold-style methods rely on, making it much faster.

4. Design proteins
Newer, generative models can propose new sequences with desired properties.

How it connects to AlphaFold

This is where the series connects:

AlphaFold (family)ESMFold
Main inputSequence plus evolutionary information (MSAs)A single sequence
ApproachDedicated structure prediction architectureLanguage model embeddings feed a folding head
SpeedSlower (needs alignments)Much faster
AccuracyGenerally higherGenerally lower, especially for proteins with few relatives
Best forHigh-accuracy structureFast, large-scale screening, orphan proteins

Both start from sequence, and both end with a structure you can then use for docking and molecular dynamics, the topics of the last two posts.

What are the limits of protein language models?

  • They may not have learned physics. Analysis of ESM-2 found that its structure prediction performance correlates strongly with the number of similar sequences in the training data. In other words, proteins with many relatives are predicted better, and rare or novel proteins are harder.
  • Input length limits. For example, ESM-1b is limited to 1,022 amino acids, which excludes around 12% of human protein isoforms. Workarounds exist, but you must know the limit of the model you use.
  • A score is not a diagnosis. A mutation score says the change is unusual for the model, not that it causes disease.
  • Bias from training data. Well-studied protein families dominate training sets.
  • Poor at some questions. Effects that depend on interactions, conditions or cellular context aren't captured by sequence alone.

Part 3: DNA Language Models (DNABERT and Friends)

Why is DNA harder?

DNA has a few big differences from proteins:

  • The human genome has 3 billion letters, and most of it doesn't code for protein.
  • Regulatory signals can be far from the gene they control (tens or hundreds of thousands of bases away).
  • There's a lot of repetitive sequence.
  • The "meaning" of a regulatory sequence depends on the cell type.

So DNA language models have to handle long sequences, and learning what matters is harder.

The main DNA language models

ModelKey idea
DNABERTThe first pre-trained foundation model for genome sequences, trained on the human genome using overlapping k-mer tokens.
DNABERT-2Uses a smarter tokenization method and is trained on multiple species. It has about 117 million parameters.
Nucleotide TransformerA family of larger models trained on many genomes. Its biggest variants are many times larger than DNABERT.
HyenaDNAHandles very long inputs. The large version supports up to 1 million base pairs of context, using single-nucleotide tokens.
CaduceusDesigned to handle both DNA strands (reverse complement).
Evo / Evo 2Very large, newer genomic models trained across many organisms, able to both score and generate sequences.

What does "tokenization" mean for DNA?

A model can't read raw text, so it splits the sequence into tokens. Different models choose differently:

  • Single nucleotides (A, C, G, T): simple, precise, but long
  • k-mers (for example, 6-letter chunks): shorter inputs, but chunks can overlap or hide small changes
  • Byte-pair encoding (BPE): the model learns its own "words" from frequent patterns

The choice affects what the model can do, especially for single-letter variants.

What can you do with DNA language models?

  • Classify sequences: promoters, enhancers, splice sites, transcription factor binding
  • Generate embeddings for downstream models
  • Score variants (some models)
  • Study conservation and regulatory patterns

The honest picture: they're not always better than simple models

This is the most important message of this section. Independent benchmarks have compared DNA language models against simpler, task-specific models. For example, DART-Eval is a benchmark that evaluates DNA language models on regulatory DNA across zero-shot, probed and fine-tuned settings, against contemporary ab initio (trained-from-scratch) baselines. 

The results depend heavily on the task and the setup. Other benchmarks show that how you use the model matters too. In one study, averaging token embeddings gave better classification performance than using a summary token in 41 of 52 datasets for DNABERT-2. 

What this means in practice:

  • Pre-trained models can help, especially when you have little labeled data
  • A simple model trained directly on your task is often a strong competitor
  • Always include a simple baseline when you test a DNA language model

Part 4: Enformer and AlphaGenome (Not Exactly Language Models)

People often group Enformer with DNABERT, but they are different in an important way.

Language model vs sequence-to-function model

DNA language modelSequence-to-function model
Trained onSequence only (self-supervised)Sequence plus experimental measurements (supervised)
Learns toPredict missing/next lettersPredict real molecular readouts
OutputEmbeddings, likelihoodsPredicted tracks (expression, chromatin accessibility, histone marks, etc.)
ExamplesDNABERT-2, Nucleotide TransformerEnformer, AlphaGenome

Enformer

Enformer takes a DNA sequence of roughly 200,000 letters and predicts thousands of experimental tracks, such as gene expression and chromatin signals, across many cell types. It combines convolutional layers with transformer layers so it can use information from far away. It's trained on real experimental data, which is why it's called a sequence-to-function model.

AlphaGenome

AlphaGenome is a newer model from the same research line. According to its Nature paper, it takes 1 Mb of DNA sequence as input and predicts thousands of functional genomic tracks at up to single-base-pair resolution, and matches or exceeds the strongest available external models in 25 of 26 variant effect prediction evaluations. It builds on Enformer. The model is available through an API for non-commercial research.

Why it matters: you can give it a sequence with and without a variant, and compare the predicted tracks to estimate how the variant might change gene regulation, splicing or expression. That's powerful for studying non-coding variants, which make up most of the genome.

Remember the caveat: these are predictions. Predicting the direction of an effect is generally easier than predicting its exact size, and any prediction still needs experimental follow-up.


Part 5: Putting It All Together

Three families of models, three questions

Model typeExamplesThe question it answers
Language models (sequence only)ESM-2, DNABERT-2, Nucleotide Transformer"What patterns does this sequence follow?"
Sequence-to-function modelsEnformer, AlphaGenome"What molecular activity does this DNA produce?"
Structure predictorsAlphaFold, ESMFold"What 3D shape does this protein take?"

Quick comparison

ModelReadsTrained howTypical use
ESM-2Protein sequenceSelf-supervisedEmbeddings, variant scoring, structure (ESMFold)
DNABERT-2DNA sequenceSelf-supervisedSequence classification, embeddings
Nucleotide TransformerDNA sequenceSelf-supervisedEmbeddings, classification
HyenaDNALong DNA sequenceSelf-supervisedVery long context tasks
Enformer~200 kb DNASupervised on experimental dataPredicting expression and chromatin tracks
AlphaGenomeUp to 1 Mb DNASupervised on experimental dataRegulatory variant effect prediction
AlphaFold / ESMFoldProtein sequenceTrained on structures (ESMFold: language model plus folding head)Predicting 3D structure

A modern workflow that connects the whole series

  1. Take a gene or protein of interest
  2. Use a protein language model to score possible mutations
  3. Use AlphaFold or ESMFold to get a 3D structure
  4. Dock a candidate ligand to the structure
  5. Run molecular dynamics to check stability
  6. Test the best candidates in the lab

Each step gives a hypothesis that the next step refines.


Part 6: Try It Yourself (Hands-On)

The best way to understand these models is to use one. This example uses a small ESM-2 model (8 million parameters) that runs on a normal laptop.

Step 1: Install

bash
mamba create -n plm python=3.11 -c conda-forge
conda activate plm
pip install torch transformers

Step 2: Get an embedding for a protein

python
import torch
from transformers import AutoTokenizer, EsmForMaskedLM

model_name = "facebook/esm2_t6_8M_UR50D"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = EsmForMaskedLM.from_pretrained(model_name)
model.eval()

# A short toy sequence. Replace with a real protein sequence.
seq = "MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ"

inputs = tokenizer(seq, return_tensors="pt")
with torch.no_grad():
    out = model(**inputs, output_hidden_states=True)

# Last layer, one vector per residue (skip the start and end tokens)
residue_embeddings = out.hidden_states[-1][0, 1:-1]

# One vector for the whole protein: average over residues
protein_embedding = residue_embeddings.mean(dim=0)
print(protein_embedding.shape)  # a list of numbers describing this protein

This protein_embedding can be used as input features for your own classifier.

Step 3: Score a mutation (zero-shot)

python
def mutation_score(seq, pos, wt, mt):
    """pos is 1-based. Returns log P(mutant) - log P(wild type)."""
    assert seq[pos - 1] == wt, "Wild-type residue doesn't match the sequence"
    masked_seq = seq[:pos - 1] + tokenizer.mask_token + seq[pos:]
    inputs = tokenizer(masked_seq, return_tensors="pt")
    with torch.no_grad():
        logits = model(**inputs).logits
    # Index pos works because index 0 is the start token
    log_probs = torch.log_softmax(logits[0, pos], dim=-1)
    wt_id = tokenizer.convert_tokens_to_ids(wt)
    mt_id = tokenizer.convert_tokens_to_ids(mt)
    return (log_probs[mt_id] - log_probs[wt_id]).item()

# Example: change residue 5 (Y) to A
print(mutation_score(seq, 5, "Y", "A"))

How to read the score:

  • Negative: the model finds the mutant less likely than the original. The change may be less tolerated.
  • Close to zero or positive: the model finds the mutant about as likely, or more likely.

Remember: this is a hint, not a diagnosis. A tiny 8M model is for learning. Larger ESM-2 models (650M and above) give better results, but need more memory.

A great first project: test it critically

  1. Pick a well-studied protein with known disease-causing (pathogenic) and harmless (benign) variants, for example from ClinVar.
  2. Compute zero-shot scores for each variant using an ESM-2 model.
  3. Compare the scores with the known labels (for example, compute ROC AUC).
  4. Compare with a simple baseline, such as a BLOSUM62 substitution score.
  5. Report honestly: does the language model beat the baseline? By how much? Where does it fail?
  6. Put the code and results on GitHub with a clear README.

This project teaches model use, evaluation and critical thinking, which is exactly the skill employers look for.


Part 7: What These Models Can and Can't Do

What they're good at

  • Capturing patterns learned from huge datasets that would be hard to code by hand
  • Giving quick first-pass predictions at scale (for example, scoring millions of variants)
  • Providing useful features when you have little labeled data
  • Speeding up structure prediction and screening
  • Generating hypotheses to test

What they are NOT good at (yet)

  • Understanding causation. They find patterns, not mechanisms.
  • Novel or rare cases. Performance often drops when training data has few similar examples.
  • Cell-specific context. Sequence alone doesn't capture everything about a cell's state.
  • Replacing experiments. Predictions need validation.
  • Always beating simple baselines. Sometimes a simple model does just as well.

A healthy way to think about it

A language model learns what is typical in the sequences it has seen. Whether that matches what is true for your question is something you still have to check.


Part 8: Common Beginner Mistakes

  1. Treating a model score as a diagnosis. A score is a prediction, not a clinical result.
  2. Skipping the baseline. Without comparing to a simple method, you can't tell if the big model helps.
  3. Ignoring the model's input limits. Long sequences may need to be split or may not be supported.
  4. Using the wrong model for the task. A language model is not an expression predictor, and vice versa.
  5. Not checking what the model was trained on. Species, genome version and data type all matter.
  6. Data leakage. Testing on sequences similar to the training data makes results look better than they are.
  7. Not recording versions. Models and weights change, so note the exact model name and version.
  8. Believing the hype. Read the evaluation, not just the headline.
  9. Using huge models when a small one is enough. Start small and scale only if needed.
  10. Forgetting biology. Always ask whether the result makes biological sense.

Part 9: A Checklist for Any New Sequence Model

Before trusting a model's output, ask:

  • What data was it trained on (species, data type, version)?
  • Is it a language model or a sequence-to-function model?
  • What is its input length limit?
  • Was it compared against simple baselines on tasks like mine?
  • Was it tested on data truly separate from training?
  • Has it been independently evaluated?
  • What are its known failure cases?
  • Can I check the output against known biology or experiments?

Part 10: Your Learning Roadmap

Week 1: Basics. Learn what tokens, embeddings, masked prediction and fine-tuning mean. Revisit protein and DNA basics if needed.

Week 2: Hands-on with a protein model. Run the code above, get embeddings, and score a few mutations.

Week 3: Try structure prediction. Explore AlphaFold-predicted structures from the AlphaFold Database, and try ESMFold on a sequence you know.

Week 4: Evaluate critically. Do the ClinVar baseline project described above.

Week 5 and beyond:

  • Explore a DNA language model (for example, DNABERT-2) on a small classification task
  • Read the original papers for the models you use
  • Try a sequence-to-function model through its public tools
  • Learn the basics of fine-tuning
  • Combine tools into a pipeline (and make it reproducible, which is the topic of our next post)

Quick Recap

  • Language models learn patterns by predicting missing parts of sequences. DNA and proteins are sequences with "grammar" shaped by evolution.
  • ESM models read proteins and can give embeddings, score mutations and predict structure (ESMFold).
  • DNA language models (DNABERT, Nucleotide Transformer, HyenaDNA) learn from genomes, but face harder challenges and do not always beat simple models.
  • Enformer and AlphaGenome are sequence-to-function models. They're trained on experimental data to predict molecular activity, which is different from language models.
  • AlphaFold and ESMFold predict structure, linking sequence models to docking and molecular dynamics.
  • Always compare against a simple baseline, check input limits and treat outputs as predictions.

Final Thoughts

It's easy to feel overwhelmed by the pace of new models. But you don't need to know every architecture. You need to understand the core ideas: what the model reads, how it was trained, what it predicts, and how to check whether it's right.

Try one model, test it on a small problem, compare it with a simple method and write down what you find. That habit will serve you far longer than any single model name.

If you get stuck on the code, drop your error message in the comments and I'll help. And tell me: would you like a full hands-on post on running ESMFold or AlphaFold predictions and using them for docking?

In the next post, we'll look at Docker and Singularity for Bioinformatics: Why Containers Make Your Analysis Reproducible, which is how you package everything from this series so it runs the same on any computer.

Molecular Docking Step by Step with AutoDock Vina (Beginner Hands-On Guide)


In the last post, we learned what docking is: a computer method that tries many ways of fitting a small molecule (the ligand) into a protein (the receptor) and ranks them with a score.

Now it's time to actually run one. 

In this guide, you'll dock a real drug molecule into a real protein, from the first command to reading the results. No prior docking experience is needed, but basic Linux commands will help.

By the end, you'll know how to:

  • set up the tools you need
  • prepare a protein and a ligand for docking
  • define the search box
  • run AutoDock Vina
  • read the output and view the poses in 3D
  • validate your setup with a redocking test
  • fix the most common problems

What we'll dock

We'll use the standard example from the official AutoDock Vina tutorial: the cancer drug imatinib (Gleevec) docked into the protein c-Abl kinase (PDB ID: 1IEP).

Why this example?

  • The official tutorial provides ready-made input files, so you can focus on learning the workflow.
  • The structure already has the drug bound, so you can compare your result with the real, experimental pose.
  • You can check your output against the tutorial's expected result.

One honest note: the official documentation says imatinib is a challenging ligand, and Vina will occasionally not find the correct pose with default parameters. That's why we'll raise the search effort (exhaustiveness) later. It also teaches you an important lesson early: docking results always need checking. readthedocs


Step 0: What you need

Operating system: Linux, macOS, or Windows with WSL (the tutorial can be done on macOS, Linux and Windows Subsystem for Linux). readthedocs

Tools:

ToolWhat it does
AutoDock VinaThe docking program
MeekoPython package that prepares receptor and ligand files (converts them to PDBQT)
PyMOL or UCSF ChimeraXViewing the 3D poses
Open Babel (optional)File conversion, and RMSD calculation

Step 1: Install the tools

Create a clean environment

This is where your conda knowledge from the Nextflow and Snakemake post helps. A separate environment keeps everything tidy.

bash
mamba create -n docking python=3.10 -c conda-forge
conda activate docking

Install Vina

The simplest route is conda-forge:

bash
mamba install -c conda-forge vina
vina --version

If that doesn't work on your system, you can download the Vina binary for your operating system from the official AutoDock Vina GitHub releases page. Packaging changes over time, so check the official Vina installation docs if something differs.

Install Meeko

bash
pip install meeko
mk_prepare_receptor.py --help
mk_prepare_ligand.py --help

If both help messages appear, Meeko is working.

Install a viewer

Install UCSF ChimeraX or PyMOL from their official websites. Either works for this tutorial. ChimeraX is free for academic use, and open-source PyMOL builds are available as well.


Step 2: Download the tutorial files

The official Vina repository includes the example data.

bash
mkdir docking_practice
cd docking_practice
git clone https://github.com/ccsb-scripps/AutoDock-Vina.git
cp AutoDock-Vina/example/basic_docking/data/* .
ls

You should see files such as:

  • 1iep_receptorH.pdb: the protein (c-Abl), with hydrogens already added
  • 1iep_ligand.sdf: the ligand (imatinib)

If the folder names differ when you read this, browse the repository's example/basic_docking folder on GitHub and download the files from there.

What are these files?

  • PDB format stores 3D coordinates of atoms. You can open it in any text editor and you'll see lines for each atom.
  • SDF format stores small molecules, including their bonds.
  • Vina needs both molecules in PDBQT format, which adds partial charges and atom types. That's what Meeko will create for us.

Step 3: Prepare the receptor (the protein)

The key point: docking programs need a clean, hydrogen-containing protein in PDBQT format.

Run:

bash
mk_prepare_receptor.py -i 1iep_receptorH.pdb -o 1iep_receptor -p -v \
  --box_size 20 20 20 --box_center 15.190 53.903 16.917

This follows the official tutorial command. Let's break it down:

PartMeaning
-i 1iep_receptorH.pdbInput protein file
-o 1iep_receptorBase name for output files
-pWrite the receptor as a PDBQT file
-vWrite the Vina box configuration file
--box_size 20 20 20Size of the search box in angstroms (x, y, z)
--box_center ...Center of the search box (x, y, z coordinates)

After this step, you'll have a receptor PDBQT file and a box config file. The tutorial's config file holds the box center and size values, and a PDB file of the box can be loaded in PyMOL to visualize it. readthedocs

Open the box file to see what it contains:

bash
cat 1iep_receptor.box.txt

It should look like this:

center_x = 15.190
center_y = 53.903
center_z = 16.917
size_x = 20.0
size_y = 20.0
size_z = 20.0

Where did those box numbers come from?

They're the center of the ligand in the original crystal structure. This is the easiest way to place the box when you know where the drug binds. You'll learn to find your own box in Step 4.

What if I start from a raw PDB file?

The tutorial files are already cleaned. If you download a structure yourself from the RCSB PDB, you need to prepare it first:

  1. Remove water molecules, extra chains, ions and the bound ligand (unless a specific one matters).
  2. Add hydrogen atoms. Meeko expects hydrogens to be present in the input. Tools such as Reduce or PDBFixer can add them.
  3. Fix missing atoms or residues near the binding site if needed.

For example, a simple way to strip waters and ligands from a downloaded file is:

bash
grep -v HETATM 1iep.pdb > 1iep_protein.pdb

Then add hydrogens with your preferred tool before running Meeko. For your first run, use the provided files so you don't get stuck on preparation problems.


Step 4: Understand the search box

The search box (also called the grid box) is the 3D region where Vina looks for poses.

        ┌───────────────────────┐
        │                       │
        │     ┌───────────┐     │
        │     │  protein  │     │
        │     │  pocket   │ ← box covers the pocket
        │     └───────────┘     │
        │                       │
        └───────────────────────┘

How to choose it

  • Center: on the binding pocket. If a ligand is already in the structure, use its center.
  • Size: big enough for the ligand to move and rotate, but not much bigger. A box of about 20 to 25 Ã… per side is a common starting point for a drug-sized molecule.

Why size matters

BoxWhat happens
Too smallLigand can't fit or rotate, so you get poor or forced poses
Too largeSearch becomes slow and less accurate
Wrong locationResults are meaningless, because Vina never looks at the real pocket

How to find your own box center (for any protein)

In PyMOL, if the ligand is loaded as an object called lig:

centerofmass lig

(Some PyMOL versions need the centerofmass helper script. Alternatively, in ChimeraX, use measure center #2 for the ligand model.) Use the printed x, y and z coordinates as your box center.

Always look at your box in 3D before docking. Load the receptor and the box PDB file produced by Meeko, and check that the box covers the pocket.


Step 5: Prepare the ligand

Now convert the ligand from SDF to PDBQT:

bash
mk_prepare_ligand.py -i 1iep_ligand.sdf -o 1iep_ligand.pdbqt

What happens here:

  • Meeko reads the molecule, including its bond orders and charges.
  • It assigns atom types and partial charges.
  • It marks which bonds can rotate. This is what makes the ligand flexible during docking.

Meeko also stores the ligand's SMILES string in the PDBQT header, so the original chemistry can be restored later when exporting results. readthedocs

Important: ligands need correct hydrogens and charges

Your success can depend on one hydrogen atom. The official tutorial points out that if your starting ligand has no hydrogens, you can use scrub.py from the Molscrub package to add hydrogens and handle protonation states. Wrong protonation (for example, a group that should be charged at pH 7.4 but isn't) can change hydrogen bonding and give misleading results.

If you're getting ligands from databases like PubChem or ZINC, check their hydrogens and charge states before docking.


Step 6: Run the docking

Now the main step. Here's the command from the official tutorial:

bash
vina --receptor 1iep_receptor.pdbqt --ligand 1iep_ligand.pdbqt \
     --config 1iep_receptor.box.txt \
     --exhaustiveness=32 --out 1iep_ligand_vina_out.pdbqt

What each part means

OptionMeaning
--receptorThe prepared protein (PDBQT)
--ligandThe prepared ligand (PDBQT)
--configThe box center and size file
--exhaustiveness=32How thorough the search is
--outOutput file with the predicted poses

About exhaustiveness

Exhaustiveness controls how much effort Vina spends searching. Higher values give a more thorough search, but take longer. The default is lower (8), and the tutorial uses 32 because imatinib is a tricky ligand. A higher value is also a good idea for larger, more flexible ligands.

Other options you may use later

  • --num_modes 9 sets how many poses to report (default 9).
  • --energy_range 3 limits poses to those within a given score range from the best.
  • --cpu 4 sets how many CPU cores to use.
  • --seed 42 fixes the random seed so you can repeat the same run.
  • --scoring vinardo switches to the Vinardo scoring function instead of the default Vina one.

What you'll see

Vina prints its settings, computes the grid, then runs the search. When it finishes, you'll get a table like this (the numbers below are only an example of the layout):

mode |   affinity | dist from best mode
     | (kcal/mol) | rmsd l.b.| rmsd u.b.
-----+------------+----------+----------
   1       -13.0      0.000      0.000
   2       -11.8      1.842      3.105
   3       -11.2      2.310      4.027

The official tutorial notes that, for this system with the default Vina scoring, the best score should be around -13 kcal/mol. If yours is in that region, your setup is working as expected. readthedocs


Step 7: Read the results

The affinity column

This is Vina's predicted binding energy in kcal/mol. More negative = better predicted binding. So -13 is predicted to be stronger than -8.

But remember from the last post: these are estimates. Use them to compare and rank, not as exact measurements of real binding strength.

The RMSD columns

These show how different each pose is from the best pose (mode 1), not from the real crystal pose. They tell you whether the top poses are similar or spread across different binding modes.

  • Small RMSD between top poses: Vina is converging on one binding mode.
  • Large RMSD between top poses: there are several different possible modes.

The output file

1iep_ligand_vina_out.pdbqt contains all poses, ranked. To use them in other tools, convert them to SDF with Meeko:

bash
mk_export.py 1iep_ligand_vina_out.pdbqt -s 1iep_ligand_vina_out.sdf

Step 8: View the poses in 3D

Numbers alone are not enough. You need to look at the pose.

In PyMOL

load 1iep_receptorH.pdb
load 1iep_ligand_vina_out.sdf, docked
show cartoon, 1iep_receptorH
show sticks, docked

In ChimeraX

open 1iep_receptorH.pdb
open 1iep_ligand_vina_out.sdf

What to look for

  • Is the ligand inside the pocket, not sitting on the surface?
  • Are there hydrogen bonds between the ligand and protein residues? (In PyMOL, use the Wizard > Measurement tool or the find polar contacts action. In ChimeraX, use the hbonds command.)
  • Are there clashes, meaning atoms overlapping unrealistically?
  • Does the orientation make chemical sense? For example, polar groups near polar residues and oily groups in oily regions.

A good pose is one that fits the pocket well, makes sensible interactions and agrees with what's known about the protein.


Step 9: Validate with a redocking test

This is the most important step, and the one most beginners skip.

Redocking means docking the ligand back into the protein it came from, and checking whether your setup can reproduce the known experimental pose.

How to do it

  1. Take the crystal pose of the ligand (the original 1iep_ligand.sdf).
  2. Compare it with your top docked pose by calculating RMSD (root-mean-square deviation).

With Open Babel:

bash
obrms 1iep_ligand.sdf 1iep_ligand_vina_out.sdf

Or in PyMOL, load both ligands and use the rms_cur command to compare matching atoms.

How to interpret the RMSD

RMSD (Ã…)Meaning
Below about 2.0Good. Your setup can reproduce the known pose
2.0 to 3.0Borderline, so check the pose visually
Above 3.0Poor. Re-check box, preparation and settings

If your redocking fails, don't trust results for new ligands until you fix it. If you're not sure why, try increasing exhaustiveness, checking the box position or revisiting protein and ligand preparation.


Step 10: Dock more than one ligand (next level)

Once the first run works, you can dock several ligands. Vina supports multiple ligands in one run, which makes small virtual screening possible:

bash
vina --receptor receptor.pdbqt \
     --ligand ligand1.pdbqt ligand2.pdbqt ligand3.pdbqt \
     --config receptor.box.txt \
     --exhaustiveness=32 --out results.pdbqt

The official documentation also has tutorials for multiple ligands, batch docking and other features, so check it when you're ready.

Caution: scores from different scoring functions (for example, Vina vs AutoDock4) are not comparable with each other. Only compare scores that come from the same method and settings.


Common problems and how to fix them

ProblemLikely causeFix
command not found: vinaEnvironment not active, or Vina not installedRun conda activate docking and check installation
mk_prepare_receptor.py: command not foundMeeko not installed in this environmentpip install meeko
Meeko fails on receptorMissing hydrogens or odd residuesAdd hydrogens; remove unusual residues
Ligand outside the pocketBox in the wrong placeRe-check box center in 3D
All scores look poorBox too small, or bad preparationEnlarge the box slightly, re-prepare files
Results change each runVina uses a random seedSet --seed for repeatable runs
Redocking RMSD is highSearch too short, wrong box or protonation issueRaise exhaustiveness, check box and ligand charges
Run is very slowHuge box or high exhaustivenessShrink the box, or use more CPU cores

Common beginner mistakes (quick checklist)

  1. Trusting the score alone. Always inspect the pose.
  2. Skipping redocking. Without it, you don't know if your setup works.
  3. Wrong box location. Verify it visually.
  4. Leaving waters, ions or extra ligands in by accident.
  5. Not adding hydrogens to the protein.
  6. Wrong ligand protonation.
  7. Comparing scores across different tools or settings.
  8. Using too low an exhaustiveness for flexible ligands.
  9. Not recording versions and settings. Write down the Vina version, Meeko version, box and exhaustiveness, so your work is reproducible. (This connects to our upcoming Docker post!)
  10. Reporting docking as proof. It's a prediction.

Make it reproducible: a simple project structure

Since you're building a portfolio, organize your work like this:

docking_project/
├── README.md              # what you did, versions, results, limitations
├── data/
│   ├── 1iep_receptorH.pdb
│   └── 1iep_ligand.sdf
├── prep/
│   ├── 1iep_receptor.pdbqt
│   ├── 1iep_receptor.box.txt
│   └── 1iep_ligand.pdbqt
├── results/
│   ├── 1iep_ligand_vina_out.pdbqt
│   └── 1iep_ligand_vina_out.sdf
└── commands.sh            # all commands you ran, in order

Put your commands in commands.sh so anyone can repeat your work. In your README, note the software versions, the box values, the exhaustiveness, the best score, the redocking RMSD, and a short interpretation including limitations.


What docking can and can't tell you (again, because it matters)

It can:

  • Suggest how a molecule might bind
  • Help rank molecules to decide which to test first
  • Give you hypotheses to explore

It can't:

  • Give exact binding strength
  • Capture full protein movement
  • Replace lab experiments

Docking helps you decide what to test. It doesn't prove what is true.

When you write up your results, always say "predicted" and mention the limits.


Quick recap

  1. Install Vina, Meeko and a molecular viewer in a conda environment.
  2. Get the tutorial files (protein and ligand).
  3. Prepare the receptor with mk_prepare_receptor.py and define the box.
  4. Prepare the ligand with mk_prepare_ligand.py.
  5. Run vina with a high enough exhaustiveness.
  6. Read the scores, but look at the poses in 3D.
  7. Validate with a redocking test (RMSD under about 2 Ã… is a good sign).
  8. Document everything so it's reproducible.

Final thoughts

The first docking run always feels like magic and confusion at the same time. Once you've done it, you'll see that the workflow is just a series of careful, repeatable steps: prepare, define the box, run, check, validate.

Now try it yourself. Change one thing (the box size, the exhaustiveness, or a different ligand) and see what happens. That's how it sticks.

If you get stuck on any step, drop your error message in the comments and I'll help. And tell me: which target would you like to dock next?

In the next post, we'll go one step further with Molecular Dynamics for Beginners, to see how a docked complex behaves when the molecules move.

Molecular Dynamics for Beginners: What It Is and a First GROMACS Run

 

In the last two posts, we learned what docking is and ran it with AutoDock Vina. Docking gives you a snapshot: one frozen picture of how a molecule might sit in a protein.

But real proteins are never frozen. They wiggle, bend, breathe and interact with water all the time. To see that motion, scientists use molecular dynamics (MD).

In this guide, you'll learn what MD is in simple words, and then run your first simulation with GROMACS, one of the most widely used MD programs. 

No prior MD experience is needed, but basic Linux commands will help.

By the end, you'll know:

  • what molecular dynamics is and why it's useful
  • the key ideas behind it (force fields, time steps, trajectories)
  • how to install GROMACS
  • how to run a full simulation of a protein in water, step by step
  • how to check that your simulation is healthy
  • how to analyze the results (RMSD, radius of gyration)
  • the limits of MD and the mistakes to avoid
  • how to keep learning

Part 1: The Basics

What is molecular dynamics?

Molecular dynamics is a computer method that simulates how atoms and molecules move over time.

You give the computer:

  1. the starting positions of all the atoms (for example, a protein in water)
  2. rules for how atoms push and pull on each other (called a force field)

The computer then calculates the forces on every atom, moves the atoms a tiny step forward in time, and repeats this millions of times. The result is a trajectory: a movie of your molecules in motion.

Photo vs movie

MethodLike a...What you get
DockingPhotoA single predicted pose, mostly static
Molecular dynamicsMovieHow the system moves and changes over time

Docking asks, "Where might this molecule bind?" MD asks, "Does it stay there, and how does everything move around it?"

Why does MD matter?

A static structure from the PDB hides a lot:

  • Proteins are flexible and change shape
  • Water molecules and ions play important roles
  • A docked ligand might be unstable and drift out of the pocket
  • Some binding sites only appear when the protein moves

MD helps you see these things.

Where is MD used?

  • Checking docked poses: does the ligand stay in the pocket, or leave?
  • Protein stability and folding studies
  • Effect of mutations: how does a change in one amino acid alter motion?
  • Understanding how proteins work: enzymes, channels, receptors
  • Drug discovery: studying binding and unbinding
  • Membrane protein research: simulating proteins inside lipid membranes
  • Protein-protein and protein-DNA interactions

Part 2: How MD Works (Simple Version)

You don't need to be a physicist. Here are the core ideas.

1. Newton's laws, for atoms

If you know the force on an atom, you can work out how it will accelerate and move. MD does this for every atom, again and again.

2. The force field

A force field is a set of rules and numbers that describes the forces between atoms. It covers:

  • Bonds: atoms connected by springs
  • Angles: how bonds bend
  • Dihedrals: how groups twist
  • Non-bonded forces: electrostatics (charges) and van der Waals (atoms attracting and repelling)

Popular force fields for proteins include AMBER, CHARMM, OPLS-AA and GROMOS. Each has its own strengths, and which you use should match your system and published practice.

3. The time step

Each step moves the atoms forward by a very small time, usually 2 femtoseconds (fs), which is 0.000000000000002 seconds. To simulate even 1 nanosecond, you need about 500,000 steps.

4. The trajectory

At regular intervals, the program saves the positions of all atoms. Together, these snapshots form the trajectory, which you can watch in a viewer and analyze with numbers.

5. Water and the box

Proteins live in water, so we put the protein in a box of water molecules (this is called explicit solvent). To avoid edge effects, MD uses periodic boundary conditions (PBC): the box is treated as if it repeats infinitely in all directions, so a molecule leaving one side re-enters from the opposite side.

6. Temperature and pressure control

Real cells have a constant temperature and pressure, so MD uses algorithms called thermostats and barostats to keep these steady. The standard process is:

  • NVT (constant Number of particles, Volume, Temperature): the system warms up to the target temperature
  • NPT (constant Number of particles, Pressure, Temperature): the system adjusts its density to the target pressure

Key terms (mini dictionary)

TermSimple meaning
Force fieldThe rulebook for forces between atoms
TopologyA file describing atoms, bonds and parameters of your system
Time stepHow far in time each simulation step moves (about 2 fs)
TrajectoryThe saved "movie" of atom positions over time
Energy minimizationRelaxing the structure to remove bad contacts before the run
EquilibrationLetting temperature and pressure settle before the real run
Production runThe main simulation you analyze
PBCPeriodic boundary conditions (the box repeats in space)
RMSDHow much the structure has changed from a reference
RMSFHow much each residue moves (flexibility)
RgRadius of gyration (how compact the protein is)

Part 3: The Typical MD Workflow

Every MD project follows a similar path:

1. Get structure (PDB)
        ↓
2. Clean the structure
        ↓
3. Choose force field → generate topology
        ↓
4. Put protein in a box
        ↓
5. Add water (solvate)
        ↓
6. Add ions (neutralize the system)
        ↓
7. Energy minimization
        ↓
8. Equilibration (NVT, then NPT)
        ↓
9. Production run
        ↓
10. Analysis

We'll do each of these in the hands-on part.


Part 4: Before You Start

What you need

  • Linux, macOS or Windows with WSL
  • A computer with a few CPU cores and at least 8 GB of RAM (more is better). A GPU speeds things up but isn't required for this tutorial.
  • GROMACS
  • A molecule viewer (VMD, PyMOL or ChimeraX)
  • A plotting tool (Python with matplotlib, or Grace/xmgrace)

What to know first

  • Basic Linux commands
  • What a protein structure and a PDB file are
  • A little biochemistry (amino acids, charge, water)

Install GROMACS

Create an environment and install from conda-forge:

bash
mamba create -n md -c conda-forge gromacs python=3.11 matplotlib numpy
conda activate md
gmx --version

If you prefer, you can install GROMACS through your system's package manager (for example, sudo apt install gromacs on Ubuntu) or compile it from source. The official GROMACS installation guide has instructions for each option, and versions change over time, so check it if something differs from what you see here.

All GROMACS tools run through one command called gmx, followed by a tool name. To see help for any tool, use gmx help <tool>, for example gmx help editconf.


Part 5: Your First Simulation (Hands-On)

We'll simulate hen egg-white lysozyme (PDB ID 1AKI), a small, stable, well-studied protein. This follows the classic "Lysozyme in Water" tutorial by Justin Lemkul, which is the standard starting point for GROMACS beginners and is the basis for several other tutorials, including a BioExcel Building Blocks workflow. Once you've finished this post, the original tutorial is the best place to go deeper. irbbarcelona

Step 1: Make a project folder and get the structure

bash
mkdir lysozyme_md
cd lysozyme_md
wget https://files.rcsb.org/download/1AKI.pdb

If wget isn't available, download 1AKI.pdb from the RCSB PDB website and place it in this folder.

Take a quick look at the file in a viewer to see what the protein looks like.

Step 2: Clean the structure

Crystal structures include crystal water (HOH). For this simple run, we remove it, because the simulation will add its own water:

bash
grep -v HOH 1AKI.pdb > 1AKI_clean.pdb

Always check your own structures for other things to handle: missing residues, alternate locations, ligands, ions and non-standard residues. 1AKI is simple, which is why it's a good first example.

Step 3: Create the topology (choose a force field)

bash
gmx pdb2gmx -f 1AKI_clean.pdb -o 1AKI_processed.gro -water spce -ff oplsaa

What this does:

  • pdb2gmx reads your protein and builds the topology (topol.top), which describes all atoms, bonds and parameters
  • -ff oplsaa selects the OPLS-AA force field, as used in the tutorial
  • -water spce chooses the SPC/E water model
  • -o writes the processed structure in GROMACS format (.gro)

It also adds hydrogen atoms and writes a position-restraint file (posre.itp), which we'll use in equilibration.

Without the -ff option, GROMACS shows an interactive menu of force fields. Pick the one by name, since menu numbers can differ between versions.

Step 4: Define the simulation box

bash
gmx editconf -f 1AKI_processed.gro -o 1AKI_newbox.gro -c -d 1.0 -bt cubic
  • -bt cubic makes a cubic box
  • -c centers the protein in the box
  • -d 1.0 keeps the protein at least 1.0 nm from every box edge

Why the distance matters: because of PBC, the protein would otherwise "see" its own copy in the neighboring box. A gap of 1.0 nm or more prevents that.

Step 4b: Fill the box with water

bash
gmx solvate -cp 1AKI_newbox.gro -cs spc216.gro -o 1AKI_solv.gro -p topol.top
  • -cp is the protein in the box
  • -cs spc216.gro is a pre-made water box that GROMACS uses as a template (it works for SPC, SPC/E and similar 3-point water models)
  • -p topol.top updates your topology with the number of water molecules added

You'll see that thousands of water molecules were added, so your system now has tens of thousands of atoms.

Step 5: Add ions to neutralize the system

A system with a net electric charge behaves badly under the electrostatic methods MD uses. Lysozyme carries a net charge at neutral pH, so we add counter-ions.

First, you need a small parameter file called ions.mdp. Create it:

bash
cat > ions.mdp << 'EOF'
integrator  = steep
emtol       = 1000.0
emstep      = 0.01
nsteps      = 50000
nstlist     = 1
cutoff-scheme = Verlet
ns_type     = grid
coulombtype = cutoff
rcoulomb    = 1.0
rvdw        = 1.0
pbc         = xyz
EOF

Then run:

bash
gmx grompp -f ions.mdp -c 1AKI_solv.gro -p topol.top -o ions.tpr
gmx genion -s ions.tpr -o 1AKI_solv_ions.gro -p topol.top -pname NA -nname CL -neutral
  • grompp is the pre-processor: it combines the parameters (.mdp), structure (.gro) and topology (.top) into one run-input file (.tpr)
  • genion replaces some water molecules with ions. -neutral adds just enough to make the total charge zero.

When genion asks which group to replace, choose SOL (the solvent). Type SOL and press Enter.

Step 6: Energy minimization

Even a good crystal structure has small steric clashes after adding hydrogens and water. Energy minimization relaxes the system to a stable starting point.

Create minim.mdp:

bash
cat > minim.mdp << 'EOF'
integrator  = steep
emtol       = 1000.0
emstep      = 0.01
nsteps      = 50000
nstlist     = 1
cutoff-scheme = Verlet
ns_type     = grid
coulombtype = PME
rcoulomb    = 1.0
rvdw        = 1.0
pbc         = xyz
EOF

Run it:

bash
gmx grompp -f minim.mdp -c 1AKI_solv_ions.gro -p topol.top -o em.tpr
gmx mdrun -v -deffnm em
  • -deffnm em names all output files em.*
  • -v prints progress

When it finishes, you should see that it converged (the maximum force dropped below the tolerance, 1000 kJ/mol/nm). Now check the energy:

bash
gmx energy -f em.edr -o potential.xvg

When prompted, select Potential (type its number or name, then press Enter, then 0 to finish).

Plot it. The potential energy should drop steeply and then level off at a large negative value. If it's not decreasing or ends up positive, something is wrong with your setup.

Step 7: Equilibration, part 1 (NVT: temperature)

Now we warm the system to 300 K while holding the protein in place with position restraints, so the water can settle around it.

Create nvt.mdp:

bash
cat > nvt.mdp << 'EOF'
title       = Lysozyme NVT equilibration
define      = -DPOSRES
integrator  = md
nsteps      = 50000
dt          = 0.002
nstxout     = 500
nstvout     = 500
nstenergy   = 500
nstlog      = 500
continuation = no
constraint_algorithm = lincs
constraints = h-bonds
lincs_iter  = 1
lincs_order = 4
cutoff-scheme = Verlet
ns_type     = grid
nstlist     = 10
rcoulomb    = 1.0
rvdw        = 1.0
coulombtype = PME
pme_order   = 4
fourierspacing = 0.16
tcoupl      = V-rescale
tc-grps     = Protein Non-Protein
tau_t       = 0.1 0.1
ref_t       = 300 300
pcoupl      = no
pbc         = xyz
DispCorr    = EnerPres
gen_vel     = yes
gen_temp    = 300
gen_seed    = -1
EOF

Key settings:

  • define = -DPOSRES turns on the position restraints
  • dt = 0.002 is a 2 fs time step, and nsteps = 50000 makes this a 100 ps run
  • constraints = h-bonds fixes bonds to hydrogens, which allows the 2 fs time step
  • tcoupl = V-rescale is the thermostat, and ref_t = 300 300 sets the target temperature
  • gen_vel = yes assigns starting velocities for 300 K
  • coulombtype = PME handles long-range electrostatics

Run:

bash
gmx grompp -f nvt.mdp -c em.gro -r em.gro -p topol.top -o nvt.tpr
gmx mdrun -deffnm nvt

This takes from several minutes to a couple of hours, depending on your hardware. Then check the temperature:

bash
gmx energy -f nvt.edr -o temperature.xvg

Select Temperature, then 0. The temperature should rise quickly to about 300 K and stay there, fluctuating around it.

Step 8: Equilibration, part 2 (NPT: pressure and density)

Next we let the box adjust to 1 bar of pressure. Create npt.mdp by copying nvt.mdp and changing these lines:

bash
cp nvt.mdp npt.mdp

Edit npt.mdp:

  • Change the title to Lysozyme NPT equilibration
  • Set continuation = yes (we're continuing from NVT)
  • Set gen_vel = no (we keep the velocities from NVT)
  • Remove the three lines gen_vel, gen_temp and gen_seed if present, and add the pressure-coupling block:
pcoupl           = Parrinello-Rahman
pcoupltype       = isotropic
tau_p            = 2.0
ref_p            = 1.0
compressibility  = 4.5e-5
refcoord_scaling = com

(refcoord_scaling = com is needed because the box size is now allowed to change while position restraints are active.)

Run:

bash
gmx grompp -f npt.mdp -c nvt.gro -t nvt.cpt -r nvt.gro -p topol.top -o npt.tpr
gmx mdrun -deffnm npt

The -t nvt.cpt option passes along the checkpoint, so velocities carry over exactly. Check pressure and density:

bash
gmx energy -f npt.edr -o pressure.xvg
gmx energy -f npt.edr -o density.xvg

For pressure, select Pressure; for density, select Density (then 0 each time).

What to expect:

  • Pressure: fluctuates a lot, often by hundreds of bar, around the target of 1 bar. That's normal for a small system, so look at the average and don't worry about the noise.
  • Density: should settle near the density of water, around 1000 kg/m³.

Step 9: Production run

Now we release the restraints and let the protein move freely. Create md.mdp from npt.mdp:

bash
cp npt.mdp md.mdp

Edit md.mdp:

  • Remove the line define = -DPOSRES
  • Change the title to Lysozyme production MD
  • Set nsteps (we'll use 50000 for a quick 100 ps first run; 500000 would be 1 ns)
  • Set how often to save the trajectory by adding:
nstxout-compressed = 5000
compressed-x-grps  = System

Note: nstxout-compressed = 5000 saves a frame every 10 ps with a 2 fs step.

Run:

bash
gmx grompp -f md.mdp -c npt.gro -t npt.cpt -p topol.top -o md_0_1.tpr
gmx mdrun -deffnm md_0_1

For a first run, 100 ps is perfect for learning the workflow. Real scientific conclusions need much longer simulations (typically hundreds of nanoseconds or more) and repeats, but you don't need that to learn the process.

If you have a GPU and your GROMACS build supports it, mdrun will usually detect and use it automatically.


Part 6: Analyzing Your Trajectory

Step 10: Fix the periodic boundary effects

Because of PBC, the protein may appear to jump across the box or be split in the saved trajectory. Fix it first:

bash
gmx trjconv -s md_0_1.tpr -f md_0_1.xtc -o md_0_1_center.xtc -center -pbc mol -ur compact

When asked:

  • For the group to center, choose Protein
  • For the group to output, choose System

Step 11: Watch the movie

Open the trajectory in VMD, PyMOL or ChimeraX. For example, in VMD:

bash
vmd md_0_1.gro md_0_1_center.xtc

(If you only have md_0_1.tpr, you can write a .gro structure file with gmx trjconv -s md_0_1.tpr -f md_0_1_center.xtc -o first_frame.gro -dump 0.) Watching the trajectory teaches you a lot. Does the protein stay folded? Does it look reasonable?

Step 12: RMSD (is the structure stable?)

RMSD measures how far the protein has moved from its starting structure.

bash
gmx rms -s md_0_1.tpr -f md_0_1_center.xtc -o rmsd.xvg -tu ns

Select Backbone for both the fit and the calculation.

How to read it:

  • RMSD rises at first, then levels off (plateaus): the structure has settled and looks stable
  • RMSD keeps rising steadily: the protein is still changing, or possibly unfolding, or your run is too short
  • For a stable folded protein, RMSD typically plateaus at roughly 0.1 to 0.3 nm, but the right value depends on the system

Step 13: Radius of gyration (is it compact?)

bash
gmx gyrate -s md_0_1.tpr -f md_0_1_center.xtc -o gyrate.xvg

Select Protein. A fairly flat Rg means the protein stays compact. A steady increase suggests unfolding.

Step 14: RMSF (which parts move most?)

bash
gmx rmsf -s md_0_1.tpr -f md_0_1_center.xtc -o rmsf.xvg -res

Select C-alpha. High peaks mark flexible regions (often loops and termini). Low values mark rigid regions.

Plot the results with Python

GROMACS writes .xvg files. This short script plots any of them:

python
import numpy as np
import matplotlib.pyplot as plt

def read_xvg(path):
    x, y = [], []
    with open(path) as f:
        for line in f:
            if line.startswith(("#", "@")):
                continue
            parts = line.split()
            x.append(float(parts[0]))
            y.append(float(parts[1]))
    return np.array(x), np.array(y)

x, y = read_xvg("rmsd.xvg")
plt.plot(x, y)
plt.xlabel("Time (ns)")
plt.ylabel("RMSD (nm)")
plt.title("Lysozyme backbone RMSD")
plt.savefig("rmsd.png", dpi=300, bbox_inches="tight")
plt.show()

Change the file name and labels for the other plots.


Part 7: Is My Simulation Healthy? (A Quick Checklist)

CheckWhat good looks like
Energy minimizationConverged, potential energy large and negative
TemperatureStable around 300 K
PressureFluctuates around 1 bar (large noise is normal)
DensityClose to that of water (about 1000 kg/m³)
RMSDLevels off, no steady drift
RgFairly stable
Visual checkProtein intact, no strange stretching or breaking
grompp warningsRead every warning and understand it before moving on

If something is off, go back to the step before it. Problems in equilibration usually start earlier in preparation.


Part 8: What MD Can and Can't Do

What MD is good at

  • Showing how a system moves, not just how it looks
  • Checking whether a structure or docked pose is stable
  • Revealing flexible regions and conformational changes
  • Providing detailed, atom-level views of interactions over time
  • Generating hypotheses about mechanism

What MD is NOT good at (yet)

  • Long timescales. Most routine simulations cover nanoseconds to microseconds, while many biological events (folding, large conformational changes) are slower.
  • Perfect accuracy. Force fields are approximations, and results depend on which one you use.
  • Sampling everything. One trajectory shows only a small part of what's possible, so serious studies use multiple replicates.
  • Chemical reactions. Standard MD doesn't break or form bonds.
  • Being a replacement for experiments. Results are predictions that need support from experimental data.

A healthy way to think about it

MD shows you what is possible and plausible under a given model. It doesn't automatically show what is true in a cell.

When you report MD results, state the force field, water model, simulation length, number of replicates and software version, and be honest about limits.


Part 9: Common Beginner Mistakes

  1. Skipping equilibration. Jumping straight to production can give unstable or meaningless results.
  2. Not neutralizing the system. A net charge causes problems with long-range electrostatics.
  3. A box that's too small. The protein interacts with its own periodic image.
  4. Ignoring grompp warnings. They often point to real problems.
  5. Trusting one short run. A 100 ps simulation is for learning, not for conclusions.
  6. Analyzing without fixing PBC. RMSD and visualization can look wrong if the molecule is split across the box.
  7. Choosing the wrong force field for the system. Match the force field to your molecule type (protein, lipid, DNA, ligand).
  8. Using unprepared structures. Missing atoms, wrong protonation or unusual residues cause errors.
  9. Misreading pressure. Large fluctuations are normal. Focus on the average.
  10. Not recording settings. Always save your .mdp files, versions and commands.

Part 10: Reproducibility Tips

Keep your project organized so anyone (including future you) can repeat it:

lysozyme_md/
├── README.md          # what you did, versions, results, limitations
├── data/
│   └── 1AKI.pdb
├── mdp/
│   ├── ions.mdp
│   ├── minim.mdp
│   ├── nvt.mdp
│   ├── npt.mdp
│   └── md.mdp
├── run_all.sh         # all commands, in order
├── results/
│   ├── rmsd.png
│   ├── gyrate.png
│   └── rmsf.png
└── analysis/
    └── plot_xvg.py

In your README, record the GROMACS version, force field, water model, box type and size, temperature and pressure, run lengths and the analysis results. This also sets you up for the Docker post, where we'll package this whole setup so it runs the same on any machine.


Part 11: How MD Connects to Docking

You can now see how the two topics fit together:

  1. Dock a ligand into a protein to get a predicted pose
  2. Run MD on the protein-ligand complex to test whether the pose stays stable
  3. Analyze interactions and ligand movement over time

One extra challenge: ligands need their own force-field parameters, which standard protein setups don't provide. Tools like CHARMM-GUI, ACPYPE (for GAFF parameters) or the CGenFF server help with this. It's a good next topic once you're comfortable with a protein-only simulation.


Part 12: Your Learning Roadmap

Week 1: Understand the concepts. Force fields, time steps, trajectories, PBC, NVT and NPT.

Week 2: Run the lysozyme tutorial from this post, start to finish. Don't skip the equilibration checks.

Week 3: Analyze properly. Practice RMSD, RMSF, Rg, hydrogen bonds. Write a short interpretation of what you see.

Week 4: Repeat with a different protein. Pick a small, well-studied protein from the PDB and change as little as possible.

Week 5 and beyond:

  • Run longer simulations on a cluster or GPU
  • Run multiple replicates
  • Learn to set up protein-ligand systems
  • Automate the workflow with a script or a workflow manager (Snakemake or Nextflow)
  • Read the official GROMACS documentation and the Lemkul tutorials for more advanced topics

A good first portfolio project

  1. Simulate a small protein in water with GROMACS
  2. Run NVT and NPT equilibration with proper checks
  3. Run a production simulation (as long as you can manage)
  4. Analyze RMSD, RMSF and Rg, and make clear plots
  5. Write a README explaining the method, results and limitations
  6. Upload everything to GitHub

Quick Recap

  • MD simulates how atoms move over time, giving you a movie instead of a photo.
  • It uses a force field to calculate forces, and tiny time steps (about 2 fs) to move atoms forward.
  • The workflow: clean structure → topology → box → solvate → add ions → minimize → equilibrate (NVT, NPT) → production → analysis.
  • Always check energy, temperature, pressure and density before trusting the run.
  • Analyze with RMSD, RMSF and Rg, and look at the trajectory visually.
  • MD results are model-based predictions. Use longer runs and replicates for real conclusions.

Final Thoughts

Your first MD simulation can feel like a lot: new file types, many commands and a pile of new vocabulary. But the workflow is the same every time, and once you've seen one run from start to finish, the rest is practice.

Don't aim for perfect on the first attempt. Run the tutorial, break something on purpose, fix it, and look at your protein moving. That's when MD stops feeling abstract.

If you get stuck on any step, drop your error message in the comments and I'll help. And tell me: would you like to see how to simulate a protein-ligand complex from a docking result next?

In the next post, we'll look at DNA and protein language models (DNABERT, ESM, Enformer): what they actually do.

Editor’s Picks and Reader Favorites

The 2026 Bioinformatics Roadmap: How to Build the Right Skills From Day One

  If the universe flipped a switch and I woke up at level-zero in bioinformatics — no skills, no projects, no confidence — I wouldn’t touch ...