Skip to main content

🧬 pdb-md

A reproducible, end-to-end GROMACS MD pipeline for DNA + zinc-finger complexes — plus a PDB/MMCIF pre-/post-processing toolkit.

The pdb-md md pipeline: preprocess → zaff → topology → em → nvt → npt → prod → pbc

Illustrative MD simulation curves — EM, NVT/NPT equilibration, production RMSD, and Zn–ligand distances Deeper dynamics analysis — tICA projection, free energy surface, Markov state model, and PMF

From a prepared PDB/MMCIF structure to a PBC-corrected trajectory in one command: zaff → topology → EM/NVT/NPT → production → PBC correction — each stage resumable, hashed against its inputs, and skippable when nothing changed. Alongside it, select, res-rename, termini-rm5p, neighbor, and restrain cover the everyday structure-prep chores.

License: BSD-3-Clause Python PyPI version PyPI downloads GitHub stars Commands PRs Welcome

Installation · Usage · Features · MD Pipeline · Prerequisites

If this project helps you, please consider giving it a Star ⭐. Thank you!


🚀 Features

  • End-to-end MD pipeline (pdb-md md) — init → doctor → run --yes turns a prepared structure into a PBC-corrected trajectory: ZAFF (four-coordinate bonded zinc) → LEaP topology → ParmEd conversion to GROMACS → EM → NVT/NPT equilibration → production → PBC correction. Every stage is resumable and hashed against its inputs, so re-runs skip unchanged work.
  • Zinc-site validation — each zinc_sites entry is checked against the structure (four-coordinate ZAFF requirement, Zn–ligand distance window) before tleap, then re-mapped through LEaP residue positions so the topology reports the correct atom indices.
  • Structure selection (select) — extract chains, residue ranges, and HETATM/heterogens from PDB or MMCIF.
  • Termini cleanup (termini-rm5p) — remove 5'-terminal phosphate groups from nucleic acids.
  • Residue renaming (res-rename) — rename residues (e.g. HIS → HIE/HID/HIP, CYS → CYM) to a force field's protonation-state naming.
  • Neighbor search (neighbor) — find every atom within a distance of a given atom.
  • Position restraints (restrain) — generate heavy-atom position-restraint .itp files and a patched topology.

Prerequisites

Always check for the official documentation of the MD simulation software you are using.

Tool Description Url
Amber Homepage https://ambermd.org/
Amber Tutorials https://ambermd.org/tutorials/
Amber Reference Manuals https://ambermd.org/Manuals.php
Gromacs Homepage https://www.gromacs.org/
Online Manual https://manual.gromacs.org/current/index.html
User Guide https://manual.gromacs.org/current/user-guide/index.html
Official Tutorials https://tutorials.gromacs.org/
Source Code https://gitlab.com/gromacs/gromacs
https://github.com/gromacs/gromacs
Python API https://manual.gromacs.org/current/gmxapi/index.html
Justin Lemkul MD Tutorials http://www.mdtutorials.com/gmx/
Chinese MD Tutorials https://jerkwin.github.io/9999/10/31/GROMACS%E4%B8%AD%E6%96%87%E6%95%99%E7%A8%8B/

Always check for the forums of the MD simulation software you are using.

Tool Description Url
Amber Amber Mailing List Archive http://archive.ambermd.org/

https://cse.google.com/cse?cx=partner-pub-9700140137778662:8927431201&ie=UTF-8&sa=Search&ref=lists.ambermd.org/
Gromacs GROMACS community forums https://gromacs.bioexcel.eu/
计算化学公社- 高水平计算化学、理论化学交流论坛[Chinese] http://bbs.keinsci.com/forum.php

Installation

pip install pdb-md

Usage

❯ pdb-md --help
                                                                                                                                                    
 Usage: pdb-md [OPTIONS] COMMAND [ARGS]...                                                                                                          
                                                                                                                                                    
 Pre- and post-processing toolkit for PDB/MMCIF structure files in molecular dynamics workflows.                                                    
                                                                                                                                                    
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion          Install completion for the current shell.                                                                          │
│ --show-completion             Show completion for the current shell, to copy it or customize the installation.                                   │
│ --help                        Show this message and exit.                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ select        Select segments from a PDB or MMCIF structure file.                                                                                │
│ termini-rm5p  Remove terminal phosphate groups from nucleic acids, e.g. 5' phosphate group from DNA/RNA.                                         │
│ res-rename    Rename residues of specified chains and residue numbers, e.g. to the residue names a                                               │
│               force field expects for a given protonation state (HIS -> HIE/HID/HIP, CYS -> CYM).                                                │
│ neighbor      Find all atoms within a distance of a given atom (identified by its serial number).                                                │
│ restrain      Generate heavy-atom position-restraint .itp files for the given moleculetypes                                                      │
│               and write a patched copy of the topology that includes them.                                                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

                                                               

0️⃣ prepare initial structure for your system

For monomer modeling, take protein CTCF as an example.

  • If an experimental structure such as a PDB entry is available, directly download the experimental structure.
  • If no experimental structure is available:
    • Homology modeling: Common homology modeling tools include Swiss-Model, Modeller, I-TASSER, etc. The uniprot-structure entry usually provides links to existing homology modeling structure databases, which generally point to the Swiss-Model database.
    • Prediction: Use SOTA prediction tools such as alphafold3.
    • Prediction database: The AlphafoldDB database contains predicted structures of many proteins, which can be downloaded directly.

For complex modeling, such as the CTCF-DNA complex

  • Molecular docking: The monomer structures of the protein and DNA can be obtained via the above methods, and then molecular docking tools are used for complex modeling, such as HADDOCK, ZDOCK, HDOCK, etc.
  • Homology modeling: When performing homology modeling for proteins, the template may contain complex information (for example, when searching for homologous templates of CTCF, we may find existing crystal structures of homologous proteins bound to DNA sequences). In such cases, homology modeling tools can be directly used for complex modeling.
  • Complex structure prediction: Use SOTA complex structure prediction tools such as alphafold3.

But in reality?

In most cases or in most published papers, researchers prefer to use the homology modeling method to obtain the initial structure of the system, and then perform molecular dynamics simulations to refine the structure. This is because homology modeling can provide a relatively accurate initial structure, and molecular dynamics simulations can further optimize the structure and explore its dynamic behavior.

So, why not alphafold3?

Homology modeling is generally preferred for simulations of single-component or simple-complex systems that demand high accuracy and reliability. By contrast, predictive tools such as AlphaFold3 are widely adopted for batch prediction, complex multicomponent assemblies, high-throughput pattern exploration, or sampling for dataset augmentation, prioritizing efficiency and coverage.

Homology Modeling

Three steps of the homology modeling process (that is, template searching, target-template sequence alignment and model building)

We will take CTCF and ZNF143 as an example to illustrate the process of homology modeling, and provide some tools and resources for each step.

You may directly search for the target protein structure in the PDB database; nevertheless, we recommend first examining the details under the Structure section of its UniProt entry(entry#structure). If experimental, predicted, or homology-modeled structures are available via the Structure link of this entry, the corresponding structural files can be downloaded directly as initial structures for simulations.

1️⃣ entry#structure contains experimental structures: CTCF

alt text

You may inspect these available experimental structures one by one to determine whether they match the structural requirements of your project.

The target protein fragment for modeling can be extracted and saved as a new PDB file either via custom Python scripts (e.g., using Biopython) or the selection syntax in visualization programs including PyMOL and UCSF Chimera. For missing residues, the unresolved regions can be filled by homology modeling, structure prediction, or tools such as PDBfixer described below.

2️⃣ entry#structure contains no experimental structures but typically includes homology models and predicted structures: ZNF143

alt text

Links to homology models and predicted structures are often provided in the entry#structure section of the UniProt entry, such as the SMR (Swiss-Model Repository) and AFDB (AlphaFold Protein Structure Database) links shown above.

Similarly, we recommend prioritizing homology models.

Within the dedicated Swiss-Model entry page, multiple homology models are available. Each model is annotated with metrics including template origin, template resolution, sequence coverage, and model quality scores. These metrics can guide the selection of the homology model best suited for your study.

The accompanying model report contains detailed information on model construction as well as template–target sequence alignments, which enable a preliminary assessment of the model quality.

Notably, Swiss-Model mostly delivers homology models for monomeric proteins together with limited ligands or small molecules. For complex assembly modeling, it is worthwhile checking whether the original template PDB structure contains a similar complex. The PDB ID of this template should therefore be retained for follow-up use.

3️⃣ entry#structure contains neither experimental nor homology-modeled structures but usually provides predicted structures

We still recommend performing homology modeling first. Widely used homology modeling tools include Swiss-Model, Modeller, I-TASSER, and Rosetta.

Swiss-Model is a web-based homology modeling server. Homology modeling can be initiated by submitting either the protein UniProt ID or the amino acid sequence on its webpage. The outputs are consistent with the homology model links shown in the entry#structure section of the corresponding UniProt entry, which also include template information, quantitative metrics and model reports.

In brief, once the homology model of the target protein (plus partial ligands and small molecules) is ready, a further consideration emerges when building complex assemblies like DNA–protein complexes: how to add the DNA sequence?

Common approaches are outlined below:

  • For known DNA sequences, tools including 3D-DART, 3DNA, Nucleic Acid Builder (NAB), VMD/AmberTools (NAB), and wDSSR can be used to generate three-dimensional DNA structures. The resulting DNA model is then docked to the homology-modeled protein structure via molecular docking programs such as AutoDock or HADDOCK to yield an initial complex structure.
  • If the homology modeling template already contains DNA, base mutation can be performed. When a homologous complex template is available, PyMOL (Mutagenesis tool), UCSF Chimera, or wDSSR (https://web.x3dna-dssr.org/mutation) may be adopted. These tools preserve the DNA phosphate backbone while only mutating the bases into the target sequence. This strategy retains the intrinsic bent conformation (posture) of DNA at the binding site to the greatest extent. For longer target DNA sequences, the DNA can be extended on the basis of the mutated fragment, or a longer DNA sequence can be aligned to the existing subsequence in PyMOL. Tools such as wDSSR (https://web.x3dna-dssr.org/fibermodel) and resources at https://github.com/x3dna-dssr are available for building DNA with template-specified geometric parameters.
Description Url
Homology Modeling https://strbio.github.io/homology.html
https://strbio.github.io/advanced.html
Modeling Resources https://strbio.github.io/links.html
X3DNA-DSSR https://github.com/x3dna-dssr
https://web.x3dna-dssr.org/
http://home.x3dna.org/
http://forum.x3dna.org/
MODELLER https://salilab.org/modeller/
I-TASSER https://zhanggroup.org//I-TASSER/
Rosetta Commons https://rosettacommons.org/

Prediction

There are several tools and resources available for predicting molecular conformations and structures:

Please refer to:

Manual structural refinement

Sometimes, initial structures from homology modeling or other pipelines cannot account for experimental results including ChIP-seq and other omics data, which necessitates manual structural correction. Selected fragments may be remodeled using homologous analogs as templates, e.g., adjusting the orientation of zinc finger 2 following the conformation of zinc finger 6 from another zinc-finger protein.

However, Given the inherent sampling limitations of standard molecular dynamics simulations and their pronounced dependence on initial configurations, what fundamental insights or predictive value can be reliably derived from such localized trajectories?

How can we ensure the scientific rigor of structural interpretations derived from limited sampling, and prevent molecular simulations from merely becoming post hoc rationalizations of predetermined initial structures?

If you are puzzled by these questions, and specifically on meaning of Initial Structure and Sampling in Molecular Dynamics, you can refer to meaning of MD

1️⃣ select

Select segments from a PDB or MMCIF structure file

❯ pdb-md select --help
                                                                                                                                                                               
 Usage: pdb-md select [OPTIONS]                                                                                                                                                
                                                                                                                                                                               
 Select segments from a PDB or MMCIF structure file.                                                                                                                           
                                                                                                                                                                               
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --input        -I      <path>  Input PDB or MMCIF file [required]                                                                                                        │
│    --output       -O      <path>  Output PDB file, defaults to <input stem>_selected.pdb in the current working directory                                                   │
│ *  --segment      -S      <str>   Segments to select, either 'chain' (whole chain, e.g. A) or 'chain:start-end' (e.g. A:1-10). Repeatable. The start-end range filters      │
│                                   polymer residues only; HETATM residues on the same chain are gated solely by --keep-hetero.                                               │
│                                   [required]                                                                                                                                │
│    --keep-hetero  -H      <str>   Keep HETATM residues. Repeatable. Each entry is 'spec' where spec is 'none','all', or a comma-separated list of residue names (e.g. 'ZN'  │
│                                   or 'ZN,HOH'). An entry without a colon/chain is the global default for every chain; an entry with a chain (e.g. 'A:all') overrides the    │
│                                   global set for that chain. Entries in the same scope are combined by union (-H ZN -H HOH == -H ZN,HOH); a chain entry replaces, not       │
│                                   merges with, the global set. A chain must also appear in --segment, otherwise it is dropped before -H is consulted.                       │
│    --help                         Show this message and exit.                                                                                                               │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

example:

pdb-md select -I znf263_all_hs7_30_0.54_0.37_model_0.cif -O znf263_all_hs7_30_0.54_0.37_model_0_selected.pdb -S A:369-683 -S B -S C -S D -S E -S F -S G -S H -S I -S J -S K:1-47 -S L:29-75 -H ZN

change from to


Selecting HETATM / heterogen residues

In short: polymer residue is governed by range + chain double filter, while HETATM is governed by chain only. The --keep-hetero option is the only way to keep HETATM residues.

HETATM residues (ions, ligands, waters, sugars) are selected at the chain level, not by residue range. The chain:start-end syntax filters polymer residues only.

Consequences:

  • A chain made entirely of HETATM (e.g. a single Zn ion, a glycan chain) is governed by the chain whitelist alone — -S B keeps the whole Zn.
  • On a mixed chain, chain:start-end does NOT narrow which HETATM are kept: -S A:1-3 --keep-hetero UNX still keeps UNX at resid 109, because the HETATM branch ignores regions.
  • --keep-hetero '' (default) drops every HETATM; all keeps them all; a comma list (e.g. ZN, HOH) is an exact resname whitelist (case-insensitive).

To pick specific HETATM on a mixed chain, split the chain in preprocessing (e.g. give the heterogen its own chain id) — the current CLI has no per-HETATM range selector.

--keep-hetero syntax

-H is repeatable. Each entry is [chain:]spec:

entry meaning
-H ZN global: every chain keeps HETATM named ZN
-H ZN,HOH global: every chain keeps ZN and HOH
-H all global: every chain keeps all HETATM
-H none / -H '' global: every chain drops all HETATM (default)
-H A:all chain A keeps all of its HETATM
-H A:none chain A drops all of its HETATM
-H E:ZN,HOH chain E keeps only ZN and HOH

Two rules govern how entries combine:

  1. Union within the same scope. Several entries for the same scope add up: -H ZN -H HOH ≡ -H ZN,HOH, and -H E:ZN -H E:HOH ≡ -H E:ZN,HOH. Adding an entry never removes something already whitelisted.
  2. A chain entry overrides the global entry. A chain that has its own [chain:] entry uses only that set and ignores the global one. This is what makes per-chain removal expressible: -H ZN -H J:none keeps ZN everywhere except chain J.

A -H chain id must also appear in --segment; otherwise the chain is dropped before -H is ever consulted, and a warning is printed.

2️⃣ preprocessing for MD simulation

Here we summarize several important easy to use application for fixing problems in Protein Data Bank files in preparation for simulating them.

Tool name Description Url Note
PDBFixer PDBFixer is an easy to use application for fixing problems in Protein Data Bank files in preparation for simulating them https://github.com/openmm/pdbfixer

https://htmlpreview.github.io/?https://github.com/openmm/pdbfixer/blob/master/Manual.html
General purpose tool for fixing PDB files
pdb2gmx gmx pdb2gmx reads a .pdb (or .gro) file, reads some database files, adds hydrogens to the molecules and generates coordinates in GROMACS (GROMOS), or optionally .pdb, format and a topology in GROMACS format. These files can subsequently be processed to generate a run input file https://manual.gromacs.org/current/onlinehelp/gmx-pdb2gmx.html Designed for preparing PDB files for GROMACS simulations, pdb2gmx is a subcommand of GROMACS tool gmx —— gmx pdb2gmx, it has several options for pdb file processing like -ignh to add the hydrogens, see in gmx pdb2gmx -h
pdb4amber Analyse PDB files and clean them for further usage, especially with the LEaP programs of Amber https://ambermd.org/AmberTools.php pdb4amber tool from the AmberTools MD package, designed for preparing PDB files for Amber simulations, also a command-line utility in the AmberTools suite —— pdb4amber, it also has several options for pdb file processing, Removing hydrogen or water atoms, see pdb4amber -h
BioForge BioForge is a pure-Rust toolkit for automated preparation of biological macromolecules. It reads experimental structures (PDB/mmCIF), reconciles them with high-quality residue templates, repairs missing atoms, assigns hydrogens and termini, builds topologies, and optionally solvates the system with water and ions—all without leaving the Rust type system https://github.com/TKanX/bio-forge
pdbtools A set of tools for manipulating and doing calculations on wwPDB macromolecule structure files https://github.com/harmslab/pdbtools see File/structure manipulation part for cleaning function in https://github.com/harmslab/pdbtools#filestructure-manipulation
pdb-tools A dependency-free cross-platform swiss army knife for PDB files https://github.com/haddocking/pdb-tools see https://www.bonvinlab.org/pdb-tools/

normal preprocessing

cited from pdbfixer manual

- If the structure was generated by X-ray crystallography, most or all of the hydrogen atoms will usually be missing.
- There may also be missing heavy atoms in flexible regions that could not be clearly resolved from the electron density. This may include anything from a few atoms at the end of a sidechain to entire loops.
- Many PDB files are also missing terminal atoms that should be present at the ends of chains.
- The file may include nonstandard residues that were added for crystallography purposes, but are not present in the naturally occurring molecule you want to simulate.
- The file may include more than what you want to simulate. For example, there may be salts, ligands, or other molecules that were added for experimental purposes. Or the crystallographic unit cell may contain multiple copies of a protein, but you only want to simulate a single copy.
- There may be multiple locations listed for some atoms.
- If you want to simulate the structure in explicit solvent, you will need to add a water box surrounding it.
- For membrane proteins, you may also need to add a lipid membrane.

you can

Add missing heavy atoms.
Add missing hydrogen atoms.
Build missing loops.
Convert non-standard residues to their standard equivalents.
Select a single position for atoms with multiple alternate positions listed.
Delete unwanted chains from the model.
Delete unwanted heterogens.
Build a water box for explicit solvent simulations.

Remove Chains
Identify Missing Residues
Replace Nonstandard Residues
Remove Heterogens
Add Missing Heavy Atoms
Add Missing Hydrogens
Add Water
Add Membrane

Removal of terminal phosphate group for Nucleic Acid

It is usually suggested that while preparing a nucleic acid system for simulation, 5' terminal phosphate group must be removed; or any terminal charged phosphate group should be removed...

Nucleic acids typically do not have 5’-phosphate groups. Force fields are parametrized to the most common use cases and do not necessarily cover all possible chemical space. Delete the phosphate atoms from the 5’-nucleotide and you can generate the topology such that it has a free 5’-hydroxyl group.

In most cases, e.g. for DNA simulations, 5’-phosphate groups are less cared about, so you can just delete them

Remove any phosphate group from terminal residues; these are often present synthetically but are not how force fields are typically parametrized (5’-OH terminus is typical).

In detail, we just need to remove the [O1P/OP1, O2P/OP2, O3P/OP3 if exists, P, Hydrogens attached to them] atoms from the 5' terminal residue of a nucleic acid chain.

You can use the termini-rm5p command to remove the 5' terminal phosphate group from nucleic acids as talked above.

❯ pdb-md termini-rm5p --help
                                                                                                                                                                                                          
 Usage: pdb-md termini-rm5p [OPTIONS]                                                                                                                                                                     
                                                                                                                                                                                                          
 Remove terminal phosphate groups from nucleic acids, e.g. 5' phosphate group from DNA/RNA.                                                                                                               
                                                                                                                                                                                                          
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --input   -I      <path>  Input PDB or MMCIF file [required]                                                                                                                                        │
│    --output  -O      <path>  Output PDB file, defaults to <input stem>_rm5p.pdb in the current working directory                                                                                       │
│    --chain   -C      <str>   Chains to process. Repeatable. If not provided, all chains will be processed.                                                                                             │
│    --help                    Show this message and exit.                                                                                                                                               │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
❯ pdb-md termini-rm5p -I znf263_all_hs7_30_0.54_0.37_model_0_selected.pdb -C K -C L

Wrote znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p.pdb
  chain K: removed OP3, P, OP1, OP2
  chain L: removed P, OP1, OP2

protonation(add hydrogens) and residue renaming

protonation state of the protein is important for MD simulation. The protonation state of a protein can be determined by the pH of the environment, which can affect the charge and conformation of the protein.

Here we summarize several tools for predicting or assigning the protonation state of a protein:

Basically predicted/assigned based on comparison between Pka calculation and the pH of the environment.

Tool name Description Url Note
H++ H++ is an automated system that computes pK values of ionizable groups in macromolecules and adds missing hydrogen atoms according to the specified pH of the environment. Given a (PDB) structure file on input, H++ outputs the completed structure in several common formats (PDB, PQR, AMBER inpcrd/prmtop) and provides a set of tools for analysis of electrostatic-related molecular properties. http://newbiophysics.cs.vt.edu/H++/index.php
PDB2PQR APBS-PDB2PQR software suite, Use PROPKA to assign protonation states at provided pH https://server.poissonboltzmann.org/pdb2pqr
PROPKA PROPKA predicts the pKa values of ionizable groups in proteins and protein-ligand complexes based in the 3D structure. https://github.com/jensengroup/propka
PKA17 PKA17: the grid-based pKa calculator for proteins http://kaminski.wpi.edu/PKA17/pka_calc.html
pdb2gmx gmx pdb2gmx, see above https://manual.gromacs.org/current/onlinehelp/gmx-pdb2gmx.html pdb2gmx --ignh
pdbfixer see above https://github.com/openmm/pdbfixer

https://htmlpreview.github.io/?https://github.com/openmm/pdbfixer/blob/master/Manual.html
tleap/pdb4amber see ambertools above

Of course, in most cases, people still rely on prior knowledge to determine the protonation state of specific residues. For example, tetracoordinate zinc finger proteins have been thoroughly studied, and the protonation states of coordinating atoms within this motif are well known, so computational tools are generally not required for such determinations.

In many cases, successful assignment of protonation states is often coupled with residue renaming operations. This is because in most force fields, the protonation state of a residue is distinguished by its residue name. For instance, the three protonation states of HIS correspond to three residue names: HID, HIE, and HIP. Therefore, residue renaming is usually needed after the protonation state is determined.

Take the classic tetracoordinate zinc finger protein as an example. The coordinating CYS and HIS residues are commonly renamed to CYM, HID/HIE/HIP, or further processed (e.g., ZAFF), so that the force field can correctly recognize their protonation states.

Here we take ZAFF as an example, with reference to ZAFF.

alt text

For residue renaming, most scripts are based on raw text processing given that the PDB file is an 80-column, fixed-width text file. However, this approach is not robust and can easily introduce errors just as manual editing does. Therefore, we recommend using the 'biopython' library to read the PDB file, modify the residue names, and then write it back to a new PDB file. This method is more robust and less error-prone.

You can use the res-rename command to rename residues by chain and residue number. This applies a renaming you have already decided on; the protonation-state decision itself is made beforehand (by the tools above, or by hand).

❯ pdb-md res-rename --help
                                                                                                                                                                                          
 Usage: pdb-md res-rename [OPTIONS]                                                                                                                                                       
                                                                                                                                                                                          
 Rename residues of specified chains and residue numbers, e.g. to the residue names a force field expects for a given protonation state (HIS -> HIE/HID/HIP, CYS -> CYM).                 
                                                                                                                                                                                          
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --input   -I      <path>  Input PDB or MMCIF file [required]                                                                                                                        │
│    --output  -O      <path>  Output PDB file, defaults to <input stem>_renamed.pdb in the current working directory                                                                    │
│ *  --rename  -R      <str>   Residue to rename as 'chain:resnum:newresname' (e.g. A:20:HIE). Repeatable. resnum is the residue number carried by that chain's own records (columns     │
│                              23-26); it is not the atom serial, and it does not necessarily restart at 1 per chain. The new name may be at most 4 characters.                          │
│                              [required]                                                                                                                                                │
│    --help                    Show this message and exit.                                                                                                                               │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

example:

pdb-md res-rename \
-I znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum.pdb \
-R A:12:CY4 \
-R A:15:CY4 \
-R A:68:CY4 \
-R A:71:CY4 \
-R A:96:CY4 \
-R A:99:CY4 \
-R A:124:CY4 \
-R A:127:CY4 \
-R A:152:CY4 \
-R A:155:CY4 \
-R A:209:CY4 \
-R A:212:CY4 \
-R A:237:CY4 \
-R A:240:CY4 \
-R A:265:CY4 \
-R A:268:CY4 \
-R A:293:CY4 \
-R A:296:CY4 \
-R A:28:HD2 \
-R A:32:HD2 \
-R A:84:HD2 \
-R A:88:HD2 \
-R A:112:HD2 \
-R A:116:HD2 \
-R A:140:HD2 \
-R A:144:HD2 \
-R A:168:HD2 \
-R A:172:HD2 \
-R A:225:HD2 \
-R A:229:HD2 \
-R A:253:HD2 \
-R A:257:HD2 \
-R A:281:HD2 \
-R A:285:HD2 \
-R A:309:HD2 \
-R A:313:HD2 \
-R B:316:ZN4 \
-R C:317:ZN4 \
-R D:318:ZN4 \
-R E:319:ZN4 \
-R F:320:ZN4 \
-R G:321:ZN4 \
-R H:322:ZN4 \
-R I:323:ZN4 \
-R J:324:ZN4

the log shows:

Wrote znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum_renamed.pdb
  chain A: 12 CYS -> CY4
  chain A: 15 CYS -> CY4
  chain A: 68 CYS -> CY4
  chain A: 71 CYS -> CY4
  chain A: 96 CYS -> CY4
  chain A: 99 CYS -> CY4
  chain A: 124 CYS -> CY4
  chain A: 127 CYS -> CY4
  chain A: 152 CYS -> CY4
  chain A: 155 CYS -> CY4
  chain A: 209 CYS -> CY4
  chain A: 212 CYS -> CY4
  chain A: 237 CYS -> CY4
  chain A: 240 CYS -> CY4
  chain A: 265 CYS -> CY4
  chain A: 268 CYS -> CY4
  chain A: 293 CYS -> CY4
  chain A: 296 CYS -> CY4
  chain A: 28 HIS -> HD2
  chain A: 32 HIS -> HD2
  chain A: 84 HIS -> HD2
  chain A: 88 HIS -> HD2
  chain A: 112 HIS -> HD2
  chain A: 116 HIS -> HD2
  chain A: 140 HIS -> HD2
  chain A: 144 HIS -> HD2
  chain A: 168 HIS -> HD2
  chain A: 172 HIS -> HD2
  chain A: 225 HIS -> HD2
  chain A: 229 HIS -> HD2
  chain A: 253 HIS -> HD2
  chain A: 257 HIS -> HD2
  chain A: 281 HIS -> HD2
  chain A: 285 HIS -> HD2
  chain A: 309 HIS -> HD2
  chain A: 313 HIS -> HD2
  chain B: 316 ZN -> ZN4
  chain C: 317 ZN -> ZN4
  chain D: 318 ZN -> ZN4
  chain E: 319 ZN -> ZN4
  chain F: 320 ZN -> ZN4
  chain G: 321 ZN -> ZN4
  chain H: 322 ZN -> ZN4
  chain I: 323 ZN -> ZN4
  chain J: 324 ZN -> ZN4

CRITICAL: TER record must separate protein chain from each ZN residue — tLEaP uses TER to avoid creating unwanted bonds to adjacent residues.

grep "^TER" znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum_renamed.pdb       # TER after each chain and after protein before ZN
grep "ZN[0-9]\|CY[0-9]\|HD[0-9]" znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum_renamed.pdb | head

A note on 4-character residue names. A PDB residue name occupies columns 18-20, but some force fields use 4-character names (GROMOS HISA/HISB, CHARMM CYSH) that borrow the blank column 21 between the name and the chain id. Biopython's PDBIO formats the residue name with a minimum width of 3, which does not truncate: a 4-character name pushes every following column one to the right and emits an 81-column record with the chain id and residue number out of place -- a record fixed-column parsers read wrong. res-rename renders the file in memory and repairs those records before saving, so both 3- and 4-character names come out as well-formed 80-column lines. Names longer than 4 characters are rejected outright, since they have nowhere in the format to go.

This note covers writing only. Biopython's parser reads the residue name from three columns, so a 4-character name already in the input is silently truncated to three (no error) -- and that includes the file this command writes. Re-running any pdb-md command on res-rename's output will lose the 4th character, so the truncation is reported as a warning.

3️⃣ Force Fields & Water Models

How to Prepare Force Fields and Choose Water Models in MD Simulation Setup?

Please check our materials first in Molecular Dynamics Force Fields: How to Choose, How to Configure, and What to Do When Parameters Are Missing?

And then check the official documentation of the MD simulation software you are using for detailed instructions on how to prepare force fields and choose water models.

System Starting parameter sets to consider Items to be verified
Canonical proteins AMBER ff14SB/ff19SB, CHARMM36m, OPLS-AA/M Protein type, conformational state, solvent setup, and relevant experimental validations
Protein–small organic molecule Protein force field paired with GAFF2, CGenFF, OpenFF Sage, or corresponding OPLS small-molecule parameters Ligand chemical environment, charge scheme, critical dihedral angles, and cross-component interactions
DNA, RNA and protein–nucleic acid complexes Dedicated nucleic acid force fields, e.g., AMBER DNA/RNA parameter sets DNA and RNA are not interchangeable; sequence, structure, modifications and ionic conditions need to be checked
Lipid bilayers, membrane proteins Specialized lipid parameters such as AMBER Lipid21 Lipid species, membrane composition, and compatibility with proteins, water and ions
Sugars, polysaccharides, glycoproteins Carbohydrate force fields such as GLYCAM Monosaccharide stereochemistry, anomeric configuration, linkage positions, glycosidic bonds and protein–glycan linkages
Intrinsically disordered proteins, flexible peptides Parameter sets validated for disordered states, e.g., studies using CHARMM36m Stability alone is insufficient; conformational distribution, global dimensions and secondary structure propensity must be assessed
Metalloproteins, metalloenzymes Specialized nonbonded or bonded models, or QM/MM approaches depending on the research question Oxidation state, coordination geometry, ligand exchange, and possible chemical reactions
Non-natural residues, post-translational modifications, covalent ligands Pre-validated custom residue parameters or supplementary parameterization Not only newly added groups but also new covalent connections to the parent structure

Selection criteria for proteins, small molecules and specialized components can be found in the original publications of ff19SB, CHARMM36m and OPLS-AA/M, as well as AMBER official documentation for component parameters.

For typical protein-nucleic acid complexes, the following force field combinations are often used:

CHARMM36m/CHARMM36 + CHARMM36 NA + CHARMM-TIP3P
Amber-ff19SB + OL24/OL21 + OPC
Amber-ff14SB + OL15/bsc1 + TIP3P 

Also refer to https://ambermd.org/AmberModels.php

alt text

e.g. Considering the compatibility of ZAFF (built with tip3p water model) with the protein-nucleic acid force field, we recommend using the following force field combinations for Zinc finger protein-DNA complex: Amber-ff14SB + bsc1 + TIP3P

4️⃣ Topology and System Construction

Structure Preprocessing & Standardization: done in 1️⃣2️⃣3️⃣

Force Field Allocation & Initial Topology Generation:

  1. Assign force field parameters: Map the atom types, charges (e.g., RESP or AM1-BCC for ligands), and bonding rules based on the selected force field (e.g., AMBER, CHARMM, OPLS).
  2. Generate structural topology: Create the core topology file containing molecular connectivity, mass, and non-bonded parameters.

System Solvation & Periodic Boundary Definition:

  1. Define the simulation box: Setup Periodic Boundary Conditions (PBC) by choosing a box geometric shape (e.g., cubic, truncated octahedron) and setting a minimum clearance distance from the solute to the box edge (typically 10–12 Å).
  2. Add solvent molecules: Fill the defined box with an explicit water model (e.g., TIP3P, SPC/E, OPC).

System Neutralization & Ionization:

  1. Neutralize net charge: Calculate the total net charge of the system and add a corresponding number of counter-ions (Na⁺ or Cl⁻) to achieve a net charge of zero.
  2. Set ionic concentration: Add extra ion pairs to mimic physiological salinity conditions (commonly 0.15 M NaCl).

Final Coordination & Parameter Export:

  • Compile simulation-ready inputs: Merge all components into final structural coordinate files and master topology files compatible with your targeted simulation engine (e.g., .prmtop/.inpcrd for AMBER, or .gro/.top for GROMACS).

For typical Gromacs topology construction workflow, you can refer to mdtutorials, generally like:

# after `Structure Preprocessing & Standardization` according to your system

# initialize your topology
# The topology (topol.top by default) contains all the information necessary to define the molecule within a simulation. This information includes nonbonded parameters (atom types and charges) as well as bonded parameters (bonds, angles, and dihedrals)
gmx pdb2gmx 

# Defining the Unit Cell & Adding Solvent
# Define the box dimensions using the editconf module
gmx editconf
# Fill the box with water using the solvate module
gmx solvate

# Adding Ions
# The tool for adding ions within GROMACS is called genion. What genion does is read through the topology and replace water molecules with the ions that the user specifies. The input is called a run input file, which has an extension of .tpr; this file is produced by the GROMACS grompp module (GROMACS pre-processor), which will also be used later when we run our first simulation. What grompp does is process the coordinate file and topology (which describes the molecules) to generate an atomic-level input (.tpr). The .tpr file contains all the parameters for all of the atoms in the system.
# To produce a .tpr file with grompp, we will need an additional input file, with the extension .mdp (molecular dynamics parameter file); grompp will assemble the parameters specified in the .mdp file with the coordinates and topology information to generate a .tpr file.
# An .mdp file is normally used to run energy minimization or an MD simulation, but in this case is simply used to generate an atomic description of the system

# prepare your .mdp file ——> produce a .tpr file with grompp + .mdp ——> add ions with genion + .tpr
gmx grompp
gmx genion

Normally, we can directly use the complete GROMACS workflow. However, there are some exceptional cases. For example, when modeling zinc finger proteins involving ZAFF, we need to employ Amber ZAFF to construct the topological system.

For details, please refer to ZAFF tutorial and ZAFF issue in Amber forum

source leaprc.protein.ff14SB # for protein
source leaprc.DNA.bsc1 # for dna
source leaprc.water.tip3p # for water
addAtomTypes { { "ZN" "Zn" "sp3" } { "S4" "S" "sp3" } { "N3" "N" "sp3" } } # C2H2 center ID4
loadamberparams frcmod.ions1lm_126_tip3p # for ions
loadamberprep ZAFF.prep
loadamberparams ZAFF.frcmod
mol = loadpdb znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum_renamed.pdb

# for 9 zn2+ ions, SG for CY4, NE2 for HD2
# CY4 list (CYS): 12,15,68,71,96,99,124,127,152,155,209,212,237,240,265,268,293,296
# HD2 list (HIS): 28,32,84,88,112,116,140,144,168,172,225,229,253,257,281,285,309,313

# ⚠️ ZN numbering below is just a showcase
# for zn1 (mol.316.ZN)
bond mol.316.ZN mol.12.SG
bond mol.316.ZN mol.15.SG
bond mol.316.ZN mol.28.NE2
bond mol.316.ZN mol.32.NE2

# for zn2 (mol.317.ZN)
bond mol.317.ZN mol.68.SG
bond mol.317.ZN mol.71.SG
bond mol.317.ZN mol.84.NE2
bond mol.317.ZN mol.88.NE2

# for zn3 (mol.318.ZN)
bond mol.318.ZN mol.96.SG
bond mol.318.ZN mol.99.SG
bond mol.318.ZN mol.112.NE2
bond mol.318.ZN mol.116.NE2

# for zn4 (mol.319.ZN)
bond mol.319.ZN mol.124.SG
bond mol.319.ZN mol.127.SG
bond mol.319.ZN mol.140.NE2
bond mol.319.ZN mol.144.NE2

# for zn5 (mol.320.ZN)
bond mol.320.ZN mol.152.SG
bond mol.320.ZN mol.155.SG
bond mol.320.ZN mol.168.NE2
bond mol.320.ZN mol.172.NE2

# for zn6 (mol.321.ZN)
bond mol.321.ZN mol.209.SG
bond mol.321.ZN mol.212.SG
bond mol.321.ZN mol.225.NE2
bond mol.321.ZN mol.229.NE2

# for zn7 (mol.322.ZN)
bond mol.322.ZN mol.237.SG
bond mol.322.ZN mol.240.SG
bond mol.322.ZN mol.253.NE2
bond mol.322.ZN mol.257.NE2

# for zn8 (mol.323.ZN)
bond mol.323.ZN mol.265.SG
bond mol.323.ZN mol.268.SG
bond mol.323.ZN mol.281.NE2
bond mol.323.ZN mol.285.NE2

# for zn9 (mol.324.ZN)
bond mol.324.ZN mol.293.SG
bond mol.324.ZN mol.296.SG
bond mol.324.ZN mol.309.NE2
bond mol.324.ZN mol.313.NE2

In the above bonding process of ZAFF according to the protocol, we need to identify which Zn ion is coordinated in each zinc finger. Since the Zn ions output by alphafold3 only have coordinates, we need to make judgments separately based on the coordination geometric environment of each Zn ion.

For general metal coordination problems, we can use distance constraints to identify the coordinated central atoms or correct parts with incorrect coordination geometry in the initial structure.

Here, you can use the 'neighbor' command to find the corresponding chemical gemoetry around the the specifc ZN atom

❯ pdb-md neighbor --help
                                                                                                                                                                                                                                                     
 Usage: pdb-md neighbor [OPTIONS]                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                     
 Find all atoms within a distance of a given atom (identified by its serial number).                                                                                                                                                                 
                                                                                                                                                                                                                                                     
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --input     -I      <path>   Input PDB or MMCIF file [required]                                                                                                                                                                                │
│ *  --serial    -S      <int>    Atom serial number (PDB columns 7-11) to search around [required]                                                                                                                                                 │
│ *  --distance  -D      <float>  Distance threshold in Angstrom, ≤ threshold is considered a neighbor [required]                                                                                                                                   │
│    --help                       Show this message and exit.                                                                                                                                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

e.g. use 5A here to identify which Zn ion is coordinated in each zinc finger

Generally, ZN-S or ZN-N bond length in typical ZAFF topology lies within 2.0~2.5A

If the structure still fails to meet your expected results within the specified coordination distance range, for example, the position of Zn ions in the structure output by alphafold3 is placed randomly, then there may be some issues with this structure.

# for zn-316, use 5A distance threshold
pdb-md neighbor -S 316 -D 5 -I znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum_renamed.pdb
# or
# pdb-md neighbor -S 316 -D 5 -I znf263_all_hs7_30_0.54_0.37_model_0_selected_rm5p_renum_renamed.pdb  | grep "CY[0-9]\|HD[0-9]"

# target: serial 316  chain A  GLY 40  atom N
#serial chain   resid   resname atom    element distance
310     A       39      MET     C       C       1.324
317     A       40      GLY     CA      C       1.466
311     A       39      MET     O       O       2.235
309     A       39      MET     CA      C       2.444
318     A       40      GLY     C       C       2.479
286     A       36      ARG     O       O       2.635
320     A       41      VAL     N       N       2.755
308     A       39      MET     N       N       2.833
312     A       39      MET     CB      C       3.225
319     A       40      GLY     O       O       3.555
323     A       41      VAL     O       O       3.667
285     A       36      ARG     C       C       3.709
304     A       38      CYS     C       C       3.812
322     A       41      VAL     C       C       3.944
321     A       41      VAL     CA      C       3.975
284     A       36      ARG     CA      C       4.231
305     A       38      CYS     O       O       4.301
277     A       35      GLU     O       O       4.527
297     A       37      LEU     O       O       4.618
296     A       37      LEU     C       C       4.630
313     A       39      MET     CG      C       4.665
302     A       38      CYS     N       N       4.755
294     A       37      LEU     N       N       4.780
327     A       42      ASP     N       N       4.799
303     A       38      CYS     CA      C       4.896
324     A       41      VAL     CB      C       4.979
# 26 atoms within 5.0 A

Here, we revisit the entire workflow from the start, and we now use homology modeling to generate a more reasonable initial structure for the zinc finger protein-DNA complex.

According to literature statistics, for the selection of initial structures in the structural modeling section, most researchers still mainly adopt homology modeling combined with manual fine-tuning or other docking techniques. Relatively few directly use structure prediction tools such as AlphaFold3. The papers adopting the latter approach claim that the structural files they used achieve relatively high values in terms of confidence and interaction interface metrics. This indicates that for refined simulations (rather than large-scale proteome batch studies), homology modeling and other related techniques remain dominant, unless large-scale batch analysis is required or the predicted results have excellent metrics.

source leaprc.protein.ff14SB
source leaprc.DNA.bsc1
source leaprc.water.tip3p

# ZAFF metal-center atom types (C2H2 Zn site)
addAtomTypes { { "ZN" "Zn" "sp3" } { "S4" "S" "sp3" } { "N3" "N" "sp3" } }

loadamberparams frcmod.ions1lm_126_tip3p
loadamberprep ZAFF.prep
loadamberparams ZAFF.frcmod

mol = loadpdb $OUR_Homology_Model_PDB

# ---- Zn coordination bonds: 9 Zn x (2 SG + 2 NE2) = 36 bonds ----
# ZF1 : Zn 365 <- Cys 62,65   His 78,82
bond mol.365.ZN mol.62.SG
bond mol.365.ZN mol.65.SG
bond mol.365.ZN mol.78.NE2
bond mol.365.ZN mol.82.NE2

# ... (similar bonding commands for other Zn ions) ...

# ---- QC: report net charge + geometry before saving ----
charge mol
check mol

# ---- dry topology (inspect Zn bonding survived before solvation) ----
saveamberparm mol znf263_hs7_dry.prmtop znf263_hs7_dry.inpcrd
savepdb mol znf263_hs7_dry.pdb

# ---- solvate + set 0.15 M NaCl AND neutralize in ONE step (SPLIT method) ----
# refer to http://archive.ambermd.org/202002/0194.html
solvateBox mol TIP3PBOX 10.0
# SPLIT (Machado et al. JCTC 2020, doi:10.1021/acs.jctc.9b00953):
#   No = Nw*Co/56 ;  N+ = No - Q/2 ;  N- = No + Q/2
#   Nw = 18766 waters, Co = 0.15 M, Q = -34  =>  No = 50, N+(NA) = 67, N-(CL) = 33
addionsrand mol NA 67 CL 33

# ---- final solvated topology ----
charge mol
saveamberparm mol znf263_hs7_solv.prmtop znf263_hs7_solv.inpcrd
savepdb mol znf263_hs7_solv.pdb

quit

Construct the above script as tleap_zaff.in, then run it in AmberTools:

tleap -f tleap_zaff.in

No redirection is required. Running the above program will synchronously generate one leap.log log file, in which you can view the execution results of each step in the above script as well as some statistical data for the topology system.

It is recommended to check the log after each run of the tleap program and record the following data.

e.g.

Item Value
Water model TIP3P (TIP3PBOX)
Buffer distance 10.0 Å (= 1.0 nm)
Box type Orthogonal cubic box (solvateBox)
Box angles α/β/γ 90° / 90° / 90°
Net charge sign Negative (DNA + deprotonated Cys)
Neutralizing ion NA⁺
Solute vdw bounding box 98.565 / 55.085 / 58.255 Å
Total bounding box for atom centers 118.565 / 75.085 / 78.255 Å
Solvent unit box 18.774 / 18.774 / 18.774 Å
Total vdw box size 121.742 / 77.891 / 81.303 Å
Volume 770965.169 A^3 (= 770.965 nm³)
Total mass 391382.052 amu
Density 0.843 g/cc
Solute (DNA+Protein+Zn) 373 residues/unit, 6638 atoms
Total charge before addng ions -34.000180
Solute 18666 water, 55998 atoms
Na+ 67
CI- 33
Total 19139 reside/unit, 62736 atoms

Overall, the main tasks involved in topological system construction are: defining the solvent box, adding ions to neutralize the system, and adding salt to simulate the physiological environment.

1️⃣ Define the solvent box

For the solvent box, it is usually necessary to select an appropriate box size and shape according to the size of the simulation system and the required solvent environment. In particular, details such as the buffer distance are related to the PBC correction in the later stage.

Refer to: https://manual.gromacs.org/2026.1/reference-manual/algorithms/periodic-boundary-conditions.html

For conventional simulations, a cubic box is sufficient. If less water is desired, shapes such as a dodecahedron can be used.

The buffer distance is generally set to 10~12 Å (i.e., 1.0 nm and 1.2 nm). A value that is too small may result in an insufficiently large solvent box, while an excessively large value will increase the computational cost.

2️⃣ Add ions: neutralization & simulation of physiological environment

When adding ions, ions are generally added to neutralize the system based on the net charge of the system, and Na⁺ or Cl⁻ ions are usually used.

For physiological environment simulation, 0.15 M NaCl is generally added.

In GROMACS, you can check the net charge of the system by viewing the output files generated by pdb2gmx. You can also use the simple command below to add ions to neutralize the system and add salt to simulate the physiological environment in one step:

gmx genion -s ions.tpr -o solv_ions.gro -p topol.top -pname NA -nname CL -neutral -conc 0.15

In AmberTools, the system charge can be checked using the charge mol command in the preceding tleap.in script. After that, addionsrand/addions/addions2 can be used to add ions to neutralize the system.

refer to:https://github.com/pgbarletta/locuaz/blob/92298259874c087f46dbd911ca1bdb354ad9fcea/docs/source/tutorialtleap.rst。

The commonly used commands are as follows:

addions mol CL 0
addions mol NA 0

But how do I set a specified salt concentration, for example, a physiological salt concentration of 0.15 M? This operation is relatively complicated in AmberTools, and the number of ions to be added usually needs to be calculated according to the formula.

Some third-party methods for approximate calculation:

https://computecanada.github.io/molmodsim-amber-md-lesson/12-Adding_Ions/index.html

http://archive.ambermd.org/202002/0194.html (I have tested this and recommend)

5️⃣ Topology conversion

Since Ambertools was used earlier to construct the topology system of ZAFF, we need to convert the Amber topology file to a Gromacs topology file if the Gromacs simulation engine is adopted downstream.

Three conversion methods have been collected so far:

amb2gro_top_gro.py script: comes with ambertools installation

ParmEd: https://github.com/ParmEd/ParmEd (I have tested this and recommend)

acpype: https://github.com/alanwilter/acpype

e.g. using ParmEd to convert the topology file:

import parmed as pmd

# convert AMBER topology to GROMACS, CHARMM formats
amber = pmd.load_file('znf263_hs7_solv.prmtop', 'znf263_hs7_solv.inpcrd')
# Save a GROMACS topology and GRO files
amber.save('znf263_hs7_solv_gmx.top')
amber.save('znf263_hs7_solv_gmx.gro')

Here, we can visualize the converted GROMACS topology file using VMD or PyMOL to check whether the structure is correct (directly load .gro file in pymol).

alt text

Fixing Gromacs topology file after conversion

Sometimes, after converting the Amber topology file(.prmtop, .inpcrd) to Gromacs format(.top, .gro), there may be some issues with the converted Gromacs topology file. For example, if you use parmed to convert the Amber topology file to Gromacs format, you may find that the converted Gromacs topology file is missing position restraints for the protein and DNA, which may cause problems in the subsequent simulation. E.g., see https://gromacs.bioexcel.eu/t/position-restraints-and-mdp-setup-after-an-ambertools-zaff-parmed-gromacs-handover/13768

In this case, you can manually add the position restraints to the Gromacs topology file.

In general, this can be resolved in three ways:

  1. Avoid the conversion. Run the equilibration and production stages in AmberTools/Amber with sander or pmemd directly from the .prmtop/.inpcrd, where the restraints are handled by AMBER's own restraint-weight mechanism; the conversion step is then avoided entirely.

  2. Add the restraints manually, using the standard GROMACS tools. Starting from the .gro and .top produced by ParmEd, and for a single-component solute or a system simple enough that the solute can be isolated as one group, you can generate the index file with gmx make_ndx, write the position-restraint file posre.itp with gmx genrestr, include that .itp from the solute .top, and then include the solute topology into the master topology. In the master topology an #ifdef POSRES block is added at the end of each [moleculetype] so that the restraints are activated. These restraints are used only in the subsequent NVT/NPT equilibration stages.

  3. Generate the restraints per moleculetype from the topology itself. The two GROMACS tools above do not generalize to multi-moleculetype systems: gmx genrestr numbers atoms by their global index in the coordinate file and, as the GROMACS documentation states, produces a useful file only for the first molecule. Because [position_restraints] indices refer to atoms within a moleculetype (local numbering 1…N) and not to global indices in the coordinate file, the restraint files must instead be generated directly from each [atoms] section, one file per moleculetype. So in this case, you can use the pdb-md restrain command to generate the position restraint files for each moleculetype in the Gromacs topology file.

pdb-md restrain

Generate heavy-atom position-restraint .itp files for the given moleculetypes and write a patched copy of the topology that includes them. This fills the gap left by an AMBER-to-GROMACS conversion (e.g. ParmEd): the converted topology has no posre file and no #ifdef POSRES block, so define = -DPOSRES in the NVT/NPT .mdp files would be a silent no-op.

❯ pdb-md restrain --help
                                                                                                                                                    
 Usage: pdb-md restrain [OPTIONS]                                                                                                                   
                                                                                                                                                    
 Generate heavy-atom position-restraint .itp files for the given moleculetypes and write a patched copy of the topology that includes them.         
                                                                                                                                                    
 This fills the gap left by an AMBER-to-GROMACS conversion (e.g. ParmEd): the                                                                       
 converted topology has no posre file and no #ifdef POSRES block, so                                                                                
 'define = -DPOSRES' in the NVT/NPT .mdp files would be a silent no-op.                                                                             
                                                                                                                                                    
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --input         -I      <path>   Input GROMACS topology file (.top) [required]                                                                │
│ *  --moleculetype  -M      <str>    Name of a [ moleculetype ] to restrain. Repeatable. One heavy-atom restraint file is written per             │
│                                     moleculetype.                                                                                                │
│                                     [required]                                                                                                   │
│    --fc            -F      <float>  Position-restraint force constant in kJ mol^-1 nm^-2. [default: 1000.0]                                      │
│    --output        -O      <path>   Output topology, defaults to <input stem>_posres.top in the current working directory                        │
│    --force                          Replace the existing #ifdef POSRES block of a selected moleculetype instead of skipping it.                  │
│    --help                           Show this message and exit.                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

example:

pdb-md restrain \
    -I znf263_hs7_solv_gmx.top \
    -M system1 -M system2 -M system3 \
    -O znf263_hs7.top

the log shows:

Wrote posre_system1.itp
  system1: 595/908 heavy atoms restrained
Wrote posre_system2.itp
  system2: 547/866 heavy atoms restrained
Wrote posre_system3.itp
  system3: 2496/4864 heavy atoms restrained
Wrote znf263_hs7.top

If a selected moleculetype already carries an #ifdef POSRES block (e.g. re-running on a topology the command produced earlier), that moleculetype is reported and skipped unless --force is given, which replaces the old block instead:

$ pdb-md restrain -I znf263_hs7.top -M system1 -M system2 -M system3 -O znf263_hs7_v2.top
WARNING: system1: already restrained; skipped (pass --force to replace the existing block)
    #ifdef POSRES
    #include "posre_system1.itp"
    #endif
WARNING: system2: already restrained; skipped (pass --force to replace the existing block)
    #ifdef POSRES
    #include "posre_system2.itp"
    #endif
WARNING: system3: already restrained; skipped (pass --force to replace the existing block)
    #ifdef POSRES
    #include "posre_system3.itp"
    #endif
Wrote znf263_hs7_v2.top

6️⃣ Start Simulation

For the amber system, we typically use Amber's pmemd for simulations. The Amber simulation workflow includes energy minimization, heating, equilibration and production phases. Each phase requires corresponding input files (.mdin) and parameter settings.

The Amber simulation workflow will not be elaborated here. Users can refer to the official Amber documentation and tutorials for operations, which have been listed before.

You may also refer to some third-party simulation project scripts, such as https://github.com/HFChenLab/MD-analysis-scripts

Below, we focus on the GROMACS simulation workflow, a widely adopted pipeline in molecular dynamics simulations.

The material below is primarily adapted from Lemkul’s GROMACS tutorial, available at http://www.mdtutorials.com/gmx/

Pre-simulation

.mdp files are the parameter files for GROMACS simulations. You can check the official GROMACS documentation for details on the parameters in the .mdp files.

Energy minimization, EM

gmx grompp + gmx mdrun

The general em.mdp file can be referenced at http://www.mdtutorials.com/gmx/complex/Files/em.mdp, also copied as lemkul_complex_em.mdp

emtol = 1000.0 kJ/mol/nm (steepest descent) is a relatively loose convergence criterion, which is sufficient for most systems. If you want to achieve a more precise energy minimization, you can set emtol = 10.0 kJ/mol/nm (conjugate gradient) or even lower.

It is recommended to perform two-stage em mdrun. Use steepest descent for the first stage and conjugate gradient for the second stage. The first stage can quickly eliminate most unreasonable interatomic distances, and the second stage can optimize the structure more precisely.

# step1: steep descent
# em1.mdp in ./refers/Gromacs/EM/em1.mdp
gmx grompp -f em1.mdp -c $GRO -p $TOP -o $EM1.tpr -maxwarn 1
gmx mdrun -deffnm $EM1 -v -ntmpi 1 -ntomp 16 -nb gpu -gpu_id 0

# step2: conjugate gradient
# em2.mdp in ./refers/Gromacs/EM/em2.mdp
gmx grompp -f em2.mdp -c $EM1.gro -p $TOP -o $EM2.tpr -maxwarn 1
gmx mdrun -deffnm $EM2 -v -ntmpi 1 -ntomp 16 -nb gpu -gpu_id 0

After em is completed, it is suggested to check the energy change with gmx energy and verify whether the em potential has converged.

NVT equilibration, NVT

gmx grompp + gmx mdrun

The general nvt.mdp file can be referenced at http://www.mdtutorials.com/gmx/complex/Files/nvt.mdp, also copied as lemkul_complex_nvt.mdp

310 K is roughly equal to 37 °C, which is the normal human body temperature.

.itp files (fixed above) for position restraints are included in the topology file, and the define = -DPOSRES option is set in the .mdp file to enable the position restraints during NVT simulation.

# nvt.mdp in ./refers/Gromacs/NVT/nvt.mdp
gmx grompp -f nvt.mdp -c $EM2.gro -r $EM2.gro -p $TOP -o $NVT.tpr -maxwarn 1
gmx mdrun -deffnm $NVT -v -ntmpi 1 -ntomp 16 -nb gpu -gpu_id 0

If you want to perform parallel simulation:

# 3 replicas NVT simulation at least
# 3 different random seeds are used to generate 3 different initial velocities for the same system
sed 's/gen_seed *= *-1/gen_seed = ${SEED1}/' nvt.mdp > nvt_r1.mdp                                                                                          
sed 's/gen_seed *= *-1/gen_seed = ${SEED2}/' nvt.mdp > nvt_r2.mdp                                                                                          
sed 's/gen_seed *= *-1/gen_seed = ${SEED3}/' nvt.mdp > nvt_r3.mdp                                                                                          

for r in r1 r2 r3; do                                                                                                                                   
    gmx grompp -f nvt_${r}.mdp -c $EM2.gro -r $EM2.gro -p $TOP -o ${NVT_PREFIX}_${r}.tpr -maxwarn 1                                                                
    gmx mdrun -deffnm ${NVT_PREFIX}_${r} -ntmpi 1 -ntomp 16 -nb gpu -gpu_id 0 -v                                                                                    
done  

After NVT is completed, it is suggested to check the temperature change with gmx energy and verify whether the system temperature has converged to the target temperature.

NPT equilibration, NPT

gmx grompp + gmx mdrun

The general npt.mdp file can be referenced at http://www.mdtutorials.com/gmx/complex/Files/npt.mdp, also copied as lemkul_complex_npt.mdp

1.0 bar is roughly equal to 1 atm, which is the normal atmospheric pressure at sea level. Set 1.0bar & 310K generally.

# npt.mdp in ./refers/Gromacs/NPT/npt.mdp
gmx grompp -f npt.mdp -c $NVT.gro -r $NVT.gro -p $TOP -o $NPT.tpr -maxwarn 1
gmx mdrun -deffnm $NPT -v -ntmpi 1 -ntomp 16 -nb gpu -gpu_id 0

You may also run NPT simulations in parallel, analogous to the NVT stage.

For parallel jobs, the NPT run typically continues from the distinct replicas generated in the preceding NVT simulation.

# 3 replicas NPT simulation (continuation=yes, inherit NVT velocities/state)
# shared npt.mdp file for all replicas cause difference is only in the initial velocities/state from NVT simulation
for r in r1 r2 r3; do
    gmx grompp -f npt.mdp \
        -c ${NVT_DIR}/${NVT_PREFIX}_${r}.gro \
        -r ${NVT_DIR}/${NVT_PREFIX}_${r}.gro \
        -t ${NVT_DIR}/${NVT_PREFIX}_${r}.cpt \
        -p $TOP \
        -o ${NPT_PREFIX}_${r}.tpr -maxwarn 1
    gmx mdrun -deffnm ${NPT_PREFIX}_${r} -ntmpi 1 -ntomp 16 -nb gpu -gpu_id 0 -v
done

After NPT is completed, it is suggested to check the pressure change with gmx energy and verify whether the system pressure has converged to the target pressure. You can also check the density change with gmx energy and verify whether the system density has converged to the target density (typically around 1.0 g/cm³ for water).

Production simulation, MD

So, when the system has been equilibrated, we can start the production simulation. The general md.mdp file can be referenced at http://www.mdtutorials.com/gmx/complex/Files/md.mdp, also copied as lemkul_complex_md.mdp

Here we take 200 ns as an example. The simulation time can be adjusted according to the research needs. The longer the simulation time, the more accurate the results, but the higher the computational cost.

# md.mdp in ./refers/Gromacs/MD/md.mdp
gmx grompp -f md.mdp -c $NPT.gro -t $NPT.cpt -p $TOP -o $MD.tpr -maxwarn 1
gmx mdrun -deffnm $MD -v -ntmpi 1 -ntomp 16 -nb gpu -pme gpu -bonded gpu -update gpu -gpu_id 0

For parallel jobs, the MD run typically continues from the distinct replicas generated in the preceding NPT simulation.

# Production MD: 3 replicas x 200 ns (310 K, 1 bar, no restraints).
# All 3 fresh from scratch, each restarting from its own NPT checkpoint.
for r in r1 r2 r3; do
    gmx grompp -f md.mdp \
        -c ${NPT_DIR}/znf263_hs7_npt_${r}.gro \
        -t ${NPT_DIR}/znf263_hs7_npt_${r}.cpt \
        -p $TOP \
        -o ${PREFIX}_${r}.tpr -maxwarn 1
    gmx mdrun -deffnm ${PREFIX}_${r} \
        -ntmpi 1 -ntomp 16 -nb gpu -pme gpu -bonded gpu -update gpu -gpu_id 0 -v
done

7️⃣ PBC correction

When the production simulation is completed, whether the system is equilibrated or not, we need to perform PBC correction on the trajectory file. Because the simulation system is set up with periodic boundary conditions, the trajectory file may contain artifacts where molecules appear to be split across the boundaries of the simulation box. This can lead to incorrect interpretations of molecular interactions and dynamics. What's more, we need to judge whether the system is equilibrated or not based on the trajectory file, and PBC artifacts can interfere with this analysis.

So, some short-time simulations have been done -> need to check whether the system is equilibrated or not -> need to analyze the corrected trajectory file -> need to perform PBC correction on the trajectory file.

In Molecular Dynamics (MD) simulations, Periodic Boundary Conditions (PBC) are introduced to simulate an infinite macroscopic system. As a result, when a molecule crosses a boundary, it gets "cut off" or "teleported" to the opposite side. This is why almost all raw simulation trajectories inherently suffer from PBC issues.

For details, please refer to the GROMACS manual: https://manual.gromacs.org/2026.1/reference-manual/algorithms/periodic-boundary-conditions.html

The general trjconv command can be referenced at http://www.mdtutorials.com/gmx/complex/Files/trjconv.md

Suggested workflow for PBC correction: https://manual.gromacs.org/current/user-guide/terminology.html#suggested-workflow

Fixing periodicity effects with gmx trjconv to suit visualization or analysis can be tricky. Multiple invocations can be necessary. You may need to create custom index groups (e.g. to keep your ligand with your protein) Following the steps below in order (omitting those not required) should help get a pleasant result. You will need to consult gmx trjconv -h to find out the details for each step. That is deliberate – there is no magic “do what I want” recipe. You have to decide what you want, first. :-)

1. First make your molecules whole if you want them whole.

2. Cluster your molecules/particles if you want them clustered.

3. If you want jumps removed, extract the first frame from the trajectory to use as the reference, and then use -pbc nojump with that first frame as reference.

4. Center your system using some criterion. Doing so shifts the system, so do not use -pbc nojump after this step.

5. Perhaps put everything in some box with the other -pbc or -ur options.

6. Fit the resulting trajectory to some (other) reference structure (if desired), and do not use any PBC related option afterwards.

With point three, the issue is that gmx trjconv removes the jumps from the first frame using the reference structure provided with -s. If the reference structure (run input file) is not clustered/whole, using -pbc nojump will undo steps 1 and 2.

Though there is no one-size-fits-all solution for PBC correction, the following workflow is recommended for our Protein-DNA complex system:

# make index file for trjconv
# 3 groups: protein(contains Zn ligand)、DNA、complex (protein+DNA)
gmx make_ndx -f $RUN.tpr -o $NDX

# 1 whole
# gmx -pbc whole
# system (group 0) for output
gmx trjconv -s $RUN.tpr -f $RUN.xtc -pbc whole -o ${RUN}_1whole.xtc


# 2 cluster
# gmx -pbc cluster
# complex group for clustering, system (group 0) for output
gmx trjconv -s $RUN.tpr -f ${RUN}_1whole.xtc -n $NDX -pbc cluster -o ${RUN}_2cluster.xtc

# 3 whole
# gmx -pbc whole
# this time for ligand Zn
# system (group 0) for output
gmx trjconv -s $RUN.tpr -f ${RUN}_2cluster.xtc -pbc whole -o ${RUN}_3whole.xtc

# 4 nojump
# gmx -pbc nojump
# reference = first frame of 3whole
# system (group 0) for output
gmx trjconv -s $RUN.tpr -f ${RUN}_3whole.xtc -dump 0 -o ${RUN}_frame0.gro
gmx trjconv -s ${RUN}_frame0.gro -f ${RUN}_3whole.xtc -pbc nojump -o ${RUN}_4nojump.xtc

# 5 center
# gmx -center 
# complex group for centering, system (group 0) for output
gmx trjconv -s $RUN.tpr -f ${RUN}_4nojump.xtc -n $NDX -center -o ${RUN}_5center.xtc

# Usually no further PBC correction is needed after this step, such as `-pbc mol -ur compact`
# Always check the trajectory after each step (through VMD or extract some metrics like `ZN-ZF rmsd` from the trajectory) to ensure that the PBC correction is proceeding as expected. If any issues arise, you may need to adjust the parameters or steps accordingly.

8️⃣ Post-Analysis

9️⃣ Final

A typical workflow for preparing a PDB file for MD simulation

pdb from Homology modeling/ Alphafold prediction -> pdbfixer(fix missing atoms, remove heterogens and hydrogens) -> pdb-md select (select chains and residues) -> pdb-md termini-rm5p (remove 5' terminal phosphate group for nucleic acids) -> pdb4amber renum(optional, but 1recommended) -> protonation (add hydrogens) status determined, followed by pdb-md res-rename (rename residues to the force field's protonation-state names) -> pdb4amber renum(optional, only if needed) -> pdb2gmx/pdb4amber (generate topology and coordinates for MD simulation)

🔟 End-to-end MD pipeline (pdb-md md)

The md subcommand turns the manual steps above into one reproducible run: zaff (Amber topology with the ZAFF bonded zinc model) → topology (ParmEd conversion to GROMACS) → energy minimization → NVT/NPT equilibration → production → PBC correction. Each stage is resumable, hashed against its inputs, and skippable when nothing upstream changed.

Installation

pip install "pdb-md[md]"

The md extra only adds PyYAML (for run.yaml). GROMACS, AmberTools (tleap) and ParmEd are external tools you install and point at yourself; they are not bundled.

Typical workflow

# 1. Write a documented run.yaml template next to your inputs.
pdb-md md init --template --output run.yaml

# 2. Edit run.yaml: input structure, zinc_sites, mdp files, tool paths.
#    Every relative path resolves against the directory holding run.yaml.

# 3. Check that gmx / tleap / ParmEd / mdp files / the structure are usable.
pdb-md md doctor run.yaml

# 4. Print the plan (RUN/SKIP per stage) without executing anything.
pdb-md md run run.yaml --dry-run

# 5. Execute. --yes skips the production-MD confirmation prompt.
pdb-md md run run.yaml --yes

# Resume or inspect at any time.
pdb-md md status .
pdb-md md stage zaff <run_dir>       # run one stage (plus settled deps)
pdb-md md pbc <run_dir> --replica 1  # only the PBC correction for one replica

Run directory contract

<run_name>/
  run.yaml                  # editable config; relative paths resolve against this file's dir
  state.json                # stage status, input hashes, artifacts, timing, tool versions
  .lock                     # fcntl lock preventing concurrent runs of the same run
  logs/
    run.log zaff.log topology.log em.log nvt.log npt.log prod.log pbc.log
  00_input/structure.pdb    # input copy, never modified
  01_zaff/   tleap_zaff.in  leap.log  <name>_dry.prmtop/.inpcrd/.pdb  <name>_solv.prmtop/.inpcrd/.pdb  zaff_report.json
  02_topology/  topol.top conf.gro posre_<moleculetype>.itp topology_report.json
  03_em/       em1.tpr/.gro/.edr/.log  em2.tpr/.gro/.edr/.log
  04_nvt/repN/ nvt.tpr|.gro|.edr|.log|.cpt
  05_npt/repN/ npt.tpr|.gro|.edr|.log|.cpt
  06_prod/repN/ <prefix>.tpr|.gro|.xtc|.edr|.log|.cpt
  07_pbc/repN/ pbc.ndx  <prefix>_1whole.xtc _2cluster.xtc _3whole.xtc _4nojump.xtc _5center.xtc <prefix>_frame0.gro  pbc_report.json

The ZAFF stage

ZAFF is a bonded (four-coordinate) zinc model, so every site must have exactly four ligands:

zinc_sites:
  - center_id: 4               # optional; center 11/12 is rejected (cannot be modelled)
    coordination_number: 4     # ZAFF supports 4 only
    zn: {chain: B, resid: 365, resname: ZN4, atom: ZN}
    ligands:
      - {chain: A, resid: 62, resname: CY4, atom: SG}
      - {chain: A, resid: 65, resname: CY4, atom: SG}
      - {chain: A, resid: 78, resname: HD2, atom: NE2}
      - {chain: A, resid: 82, resname: HD2, atom: NE2}

The stage validates each site against the preprocessed 00_input/structure.pdb (including the Zn–ligand distance window) before calling tleap. Coordinates in that file are not system atom numbers: tleap may add hydrogens and reorder atoms, so the topology stage maps each site through LEaP residue positions and writes the result to 02_topology/site_atoms.json, re-checking it against conf.gro atom names. The PBC stage reads that file for its distance check.

Solvation and salt are split into two tleap passes: pass 1 loads the ZAFF-prepared structure, bonds each Zn to its ligands, solvates the box, and its leap.log supplies the water count and net charge; pass 2 reloads that topology and adds the SPLIT counter-/co-ions computed from those numbers.

The PBC stage

Each production replica is corrected with the standard five-step trjconv workflow, using the default group names cluster: Complex, center: Complex and output: System (overridable via pbc.groups in run.yaml):

  1. whole → _1whole.xtc
  2. cluster → _2cluster.xtc
  3. whole → _3whole.xtc
  4. nojump with the frame-0 reference → _4nojump.xtc
  5. center → _5center.xtc

The index file it needs is written as 07_pbc/repN/pbc.ndx; it never overwrites an existing analysis.ndx. _5center.xtc is the canonical downstream input for analysis.

Known limitations

  • Histidines must already be renamed to their force-field protonation names (e.g. HIE/HID/HIP); otherwise tleap stops.
  • Insertion codes and duplicate (chain, resid) references stop zinc-site resolution.
  • Metals other than zinc are not supported by this pipeline; use MCPB.py.
  • Without a GPU, edit mdrun.args in run.yaml (the template enables GPU offload); the pipeline passes those arguments through unchanged.

Metadata

Release files for pdb-md 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pdb-md 0.6.0
File Interpreter ABI Platform Actions
pdb_md-0.6.0-py3-none-any.whl Python 3 none any Details for pdb_md-0.6.0-py3-none-any.whl

Release files / pdb_md-0.6.0-py3-none-any.whl

Download URL pdb_md-0.6.0-py3-none-any.whl
Size 115.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1deeb29147aae59dedd2d55226aa83fb4a8c1ae613f525994608b0079b4ea6a
BLAKE2b-256 checksum
How to use checksums
df01b8e909164683d15fa1a44fb9cd778ea2f1af96d5f7d4677c44b1dc968cef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for pdb-md 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page