How to Analyze Protein Secondary Structure from a GROMACS Trajectory (gmx dssp): A Step-by-Step Guide - StemSkills Lab
Skip to content

How to Analyze Protein Secondary Structure from a GROMACS Trajectory (gmx dssp): A Step-by-Step Guide

How to Analyze Protein Secondary Structure from a GROMACS Trajectory (gmx dssp): A Step-by-Step Guide

Use gmx dssp to assign secondary structure for every residue in every frame of a GROMACS trajectory. One command, gmx dssp -f md.xtc -s md.tpr -o dssp.dat -num num.xvg, writes both a per-frame string of one-letter DSSP codes and an .xvg of per-frame counts you can plot against time.

Secondary structure over time is the sixth figure in almost every protein MD chapter, and it is the one that answers the question your examiner will actually ask: did the protein stay folded? Your trajectory already gave you RMSD and RMSF and radius of gyration with SASA, but none of those tell you whether helix 3 melted at 40 ns. This guide is written by the StemSkills Lab team from 10+ years in structural bioinformatics, drug design and multiscale molecular modeling, and every flag below is checked against the GROMACS 2026.3 online manual.

There is one trap worth naming before anything else. Nearly every tutorial, forum answer and video still teaches gmx do_dssp, an external dssp binary, the DSSP_DSSP environment variable and an ss.xpm file. On a current GROMACS, none of that exists. Follow those steps and your first command fails.

What replaced gmx do_dssp, and does the old tool still exist?

GROMACS 2023 removed the old wrapper. The 2023 release notes record that gmx do_dssp was replaced by a native implementation of the DSSP algorithm, that the new tool is called gmx dssp, and that DSSP version 4 behavior, previously reached through gmx do_dssp -ver 4, is now the default.

The practical consequence: do_dssp no longer appears in the command reference for current GROMACS at all. It is not deprecated-but-working. It is gone. If a tutorial tells you to install a separate DSSP executable and point GROMACS at it, that tutorial predates 2023.

Check which side of the line your build sits on before you do anything else:

gmx --version
gmx help commands | grep dssp

If dssp appears, use this guide as written. If only do_dssp appears, you are on GROMACS 2022 or older and the legacy route in the comparison table below applies to you.

What do the DSSP one-letter codes mean?

DSSP assigns each residue a single character per frame. Students routinely stall here because the output is a wall of letters with no key attached. This is that key, taken from the official gmx dssp documentation:

CodeMeaningHow to read it in a result
HAlpha-helixThe main helical signal. Most helix-loss claims live in this column.
G310-helixShort, tighter helix. Often appears at the frayed ends of an H segment.
IPi-helixRare and wider. Only preferentially detected if you pass -pihelix.
EExtended strand participating in a beta-ladderThe beta-sheet signal.
BResidue in an isolated beta-bridgeA single paired residue, not a full strand.
THydrogen-bonded turnStructured but not helix or sheet.
SBendGeometric, not hydrogen-bond based.
PKappa-helix (polyproline II helix)Present because DSSP v4 searches for it. Absent in v2 behavior.
~Loop, no special designationThis is coil. It is a tilde, not a blank.
=BreakChain break. Not a structural state.

Two of those rows matter more than students expect. P only appears because polyproline searching is on by default in DSSP v4, so a v4 run and a v2 run of the same trajectory legitimately disagree. And coil is ~, so if you write a parser that counts blank characters, you will count zero.

The letters come from the original algorithm. Wolfgang Kabsch and Christian Sander defined them in “Dictionary of protein secondary structure: pattern recognition of hydrogen-bonded and geometrical features”, Biopolymers volume 22, pages 2577 to 2637 (1983). Europe PMC records that paper at 11,056 citations, which is a fair measure of how settled this definition is: you are not choosing a convention, you are reporting the standard one.

How do you prepare the trajectory before running gmx dssp?

Fix periodicity first. DSSP assigns structure from backbone hydrogen bonding, so a protein broken across the periodic boundary produces assignments that are wrong without being obviously wrong. You get a plot, it just does not mean what you think.

Run the standard correction described in our gmx trjconv tutorial:

gmx trjconv -s md.tpr -f md.xtc -o md_nojump.xtc -pbc nojump
gmx trjconv -s md.tpr -f md_nojump.xtc -o md_fit.xtc -pbc mol -center -ur compact

Select Protein for centering and System for output when prompted. Note that gmx dssp also carries its own -pbc and -rmpbc options, so a clean single-chain system often works on the raw trajectory. Doing the trjconv pass anyway costs a minute and removes an entire category of silent error, which is the right trade for a thesis figure.

What is the exact gmx dssp command?

The minimum useful run, producing both outputs at once:

gmx dssp -f md_fit.xtc -s md.tpr -o dssp.dat -num num.xvg

For a structure without explicit hydrogens, which includes most PDB files and any trajectory you stripped down, add two flags:

gmx dssp -f md_fit.xtc -s md.tpr -o dssp.dat -num num.xvg \
         -hmode dssp -clear -sel Protein

These are the options you will actually touch, with their real defaults from the 2026.3 manual:

FlagDefaultWhat it does and when to change it
-odssp.datPer-frame secondary structure strings in one-letter codes. Not an .xpm file.
-numnum.xvgPer-frame counts of each structure type across the trajectory. This is your plot.
-hmodegromacsSet to dssp to build hydrogen pseudo-atoms from the C and O coordinates of the previous residue. Required when your structure has no hydrogens.
-clearnoSkips residues missing a critical backbone atom (CA, C, N, O or H). The manual recommends pairing it with -hmode dssp.
-selpromptsSelection for the analysis. Pass Protein so water, ions and ligand never enter the assignment.
-nbyesUses GROMACS neighbor searching to find candidate hydrogen-bond partners instead of iterating over all residue pairs. Leave it on.
-cutoff0.9Neighbor-search distance in nm. The manual requires a value of at least 0.9.
-polyproyesSearches for polyproline helices, matching DSSP v4. Turn it off to reproduce DSSP v2 behavior.
-pihelixnoShifts the pattern search toward preferring pi-helices.
-ppstretchdefaultPolyproline stretch size: default is 3, shortened is 2.
-hbondsee manualChooses the hydrogen-bond criterion, either energy (electrostatic interaction energy) or geometry.

Report -hmode, -clear and -polypro in your methods text. They change the assignment, so a reader cannot reproduce your figure without them. Our guide to the MD methods section covers where these belong in the write-up.

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 read the two output files?

They answer different questions, and most students only ever open one of them.

num.xvg holds per-frame counts of each structure type. This is the classic figure: how many residues were helix at each point in time. Open the file in a text editor first and read the legend lines beginning with @ s0 legend. Those legends tell you which column is which structure type. Do not assume a column order from someone else’s script, because the set of reported types depends on the options you ran with.

Plot it with the same approach from our plot GROMACS .xvg in Python guide:

import numpy as np
import matplotlib.pyplot as plt

# .xvg comment lines start with # or @
data = np.loadtxt("num.xvg", comments=["#", "@"])
time = data[:, 0]

plt.plot(time, data[:, 1], label="check @ s0 legend for this column")
plt.xlabel("Time (ps)")
plt.ylabel("Number of residues")
plt.legend()
plt.tight_layout()
plt.savefig("secondary_structure.png", dpi=300)

dssp.dat holds one line per frame, each line a string of one-letter codes in residue order. That is the per-residue-per-frame timeline. Character position i on every line is the same residue, so reading down a column tells you the history of one residue, and reading across a line gives you the whole protein at one instant. This is what you need to say “the C-terminal helix frayed” rather than “helix content dropped”.

A minimal way to pull one residue’s history:

with open("dssp.dat") as f:
    frames = [line.strip() for line in f if line.strip()]

residue_index = 42          # zero-based position in the string
history = [frame[residue_index] for frame in frames]
print("".join(history))

Should you use gmx dssp, gmx do_dssp, or standalone DSSP?

This is the decision most readers arrive with, usually because a tutorial and their terminal disagree.

gmx dsspgmx do_dssp (legacy)Standalone DSSP / mkdssp
GROMACS version2023 and newer2022 and olderAny, works outside GROMACS
External dependencyNone, built inSeparate dssp binary requiredThe DSSP program itself
Main output.dat of code strings, .xvg of counts.xpm matrix, then xpm2psOne DSSP file per structure
Hydrogen handling-hmode gromacs or -hmode dsspHandled by the external binaryHandled by the program
Trajectory supportNative, whole trajectoryWhole trajectory via wrapperPer frame, you extract frames yourself
Algorithm versionv4 by default, v2 via -polypro nov2 default, v4 via -ver 4Whichever you installed
Migrating an old protocolDrop DSSP_DSSP and -ver, expect .dat not .xpm, delete the xpm2ps stepNothing to changeAdd a frame-extraction loop with trjconv

For a current GROMACS the choice is settled. The standalone route stays useful only when you need DSSP output for a handful of specific frames, or for a structure that never came from a GROMACS run.

The native module is also the faster path. In the primary paper for the tool, “DSSP in GROMACS: Tool for Defining Secondary Structures of Proteins in Trajectories” by Gorelov, Titov, Tolicheva, Konevega and Shvetsov (Journal of Chemical Information and Modeling, 2024, pages 3593 to 3598), the authors state that the implementation is “fully compatible with the DSSP v.4 and DSSP v.2 algorithms” and that it “works much faster than the original DSSP v.4 and DSSP v.2 algorithms”. Cite this paper alongside the GROMACS citation when you use the tool.

How do you interpret the trace without overclaiming?

This is where marks are won and lost. The plot is easy to produce and easy to over-read.

A trace that stays flat, with helix and sheet counts fluctuating by a few residues around a stable mean, supports one claim: the fold was maintained over the sampled time. That is a real and reportable result, and it is what most well-behaved systems show.

A count that decays and does not recover, localized in dssp.dat to a specific stretch of residues, supports a stronger claim about that region. Say which residues. “Residues 78 to 91 lost helical assignment after roughly 35 ns and did not recover” is a finding. “The protein unfolded” almost never is.

Three honest limits to hold onto:

  • Terminal fraying is not unfolding. The first and last turns of a helix flicker between H, G and ~ in essentially every simulation.
  • A few percent of drift is noise. One short trajectory moving from, say, 44 to 41 helical residues is within normal fluctuation, not a structural transition.
  • One replica is one sample. A single trajectory cannot establish that a transition is reproducible. Our guide on how long to run an MD simulation covers sampling length and replicas.

Discard the pre-equilibration portion before you quote any average, for the same reason you do it for RMSD.

Troubleshooting: which error are you actually hitting?

What you seeWhat it meansFix
Unknown command: dsspGROMACS 2022 or olderConfirm with gmx --version. Either upgrade, or use the legacy gmx do_dssp route with an external binary.
Unknown command: do_dsspGROMACS 2023 or newer, running an old tutorialUse gmx dssp. Drop -ver and every DSSP install step.
Failed to execute command: dsspLegacy wrapper cannot find the external binaryOnly affects old GROMACS. The DSSP_DSSP environment variable belongs to that era and is not needed by gmx dssp.
Output is empty, or almost all ~No hydrogens, so the hydrogen-bond test fails everywhereAdd -hmode dssp to build hydrogen pseudo-atoms from the previous residue, and -clear.
Complaints about specific residuesMissing backbone atoms, common after stripping or with modified residues-clear skips residues missing CA, C, N, O or H rather than failing.
Assignments look scrambled or implausiblePeriodic boundary artifactsRun the trjconv -pbc nojump then -pbc mol -center pass first.
Counts far exceed your residue countWater, ions or ligand entered the selectionPass -sel Protein explicitly instead of accepting the default group.
A tutorial says to convert ss.xpmgmx dssp never wrote oneThere is no xpm2ps step. Plot num.xvg and parse dssp.dat.
Results differ from a published figurev4 versus v2 algorithm differencePolyproline search is on by default. Set -polypro no to reproduce v2 behavior.

Frequently asked questions

Does gmx dssp need an external DSSP installation?

No. Since GROMACS 2023 the algorithm is implemented natively inside GROMACS. There is no separate binary to install and no environment variable to set. Any instruction telling you otherwise applies to the removed gmx do_dssp.

Why is my output a .dat file instead of the .xpm every tutorial shows?

Because .xpm was the legacy tool’s format. gmx dssp -o writes a .dat file of per-frame one-letter code strings, and -num writes an .xvg of per-frame counts. Nothing in the modern workflow needs gmx xpm2ps.

My protein has no hydrogens. Will gmx dssp still work?

Yes, with -hmode dssp, which builds hydrogen pseudo-atoms from the C and O coordinates of the previous residue. The manual recommends combining it with -clear so residues missing critical backbone atoms are skipped rather than misassigned.

Which DSSP version does gmx dssp implement?

Version 4 by default, which includes the polyproline helix search reported as P. Passing -polypro no disables that search and reproduces DSSP v2 behavior, which is what you want when comparing against older published assignments.

How do I turn the per-frame strings into a per-residue timeline plot?

Read dssp.dat as a list of equal-length strings, one per frame, then index the same character position across frames to follow a single residue. Mapping each letter to an integer code gives you a matrix you can render as a heatmap with matplotlib.

Can I run gmx dssp on a single PDB structure instead of a trajectory?

Yes. Pass the structure to -f as a single configuration. The synopsis accepts a single configuration in place of a trajectory, and you get one line of assignments.

Where this fits in your project

Secondary structure closes out the standard analysis set. With RMSD, RMSF, radius of gyration, SASA, hydrogen bonds and now a per-residue structure timeline, you can state what moved, how much, and where, which is the whole job of an MD results chapter. Work through the full sequence in our GROMACS molecular dynamics guide, and see where these skills sit against everything else in the computational biology skills roadmap.

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

Sources

Think you know Molecular Dynamics (GROMACS)?
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