Skip to content

Latest commit

 

History

History
217 lines (137 loc) · 14.4 KB

Test.markdown

File metadata and controls

217 lines (137 loc) · 14.4 KB
title date layout
This is a test page
2019-07-03
git-wiki-post

Basics of a GROMACS simulation

About this tutorial

Here is some text.

GROMACS is an open source program to run molecular dynamics (MD) simulations. This page contains some basic commands to set up and run a MD simulation. It is important that you understand what each command is doing and that you document for yourself all the simulation parameters that were chosen and details about how the system was built. To perform the simulation you will need some force field parameter files. These can be downloaded here.

Convert pdb structure file to GROMACS topology and structure file.

First we must download a protein structure file (pdb text file) from the RCSB website. In this tutorial will we use the protein ubiquitin. The RCSB pdb code for ubiquitin is 1UBQ.pdb and can be found here. Download the file in PDB format. You can visualize the structure using a viewing program such as VMD, Chimera, or PyMOL.

We first need to convert this pdb file to a format that Gromacs uses. The Gromacs command pdb2gmx will generate a Gromacs topology file (.top), a position restraint file (posre.itp), and a Gromacs structure file (.gro). Generating a topology file can sometimes be tricky if there are missing atoms, non-standard amino acids, or small molecules in the pdb file. A basic usage of pdb2gmx is

{% highlight git %} $ gmx pdb2gmx –f 1ubq.pdb –o 1ubq.gro -p 1ubq.top –ignh {% endhighlight %}

where -f signals the input pdb file, here called 1ubq.pdb and -o is the output structure file and -p is the output topology file. The flag -ignh means to ignore H atoms in the PDB file. The -ignh flag is useful to deal with non-conventional naming of H atoms in pdb files; however, if you need to persevere the exact position of the H coordinates in the structure file, then you should not use the -ignh flag.

Typing the above command will prompt you to select a force field. Select the force field by typing the appropriate number and hitting the Enter/Return key. You will also be prompted to select a water model. For this tutorial select the AMBER99SB-ILDN force fields from Lindorff-Larsen et al., Proteins 78, 1950-58, 2010, and when prompted, select the TIP3P water model. You should now have generated a structure file 1ubq.gro, a topology file 1ubq.top, and a position restraint file posre.itp.

The topology file 1ubq.top 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).

Defining a simulations box and adding solvent

Next, we define and create a simulation box of specified dimensions using the editconf command

{% highlight git %} $ gxm editconf –f 1ubq.gro –o 1ubq_newbox.gro –c –d 1.0 –bt cubic {% endhighlight %}

The -f flag signals the input Gromacs structure file which we created above. The -o signals the new output structure file which contains the box definition. The -c flag centers the protein in the box, and the -d specifies a minimum distance from the protein to the edge of the box (in nm). Specifying a solute-box distance of 1.0 nm means that there are at least 2.0 nm between any two periodic images of a protein. This distance will be sufficient for just about any cutoff scheme commonly used in simulations. The -bt cubic flag indicates to use a cubic box shape. Now that we have generated a simulation box, which we must fill with water. We add solvent by typing

{% highlight git %} $ gmx solvate –cp 1ubq_newbox.gro –cs spc216.gro –o 1ubq_solv.gro –p 1ubq.top {% endhighlight %}

The input structure file signaled by -cp 1ubq_newbox.gro is the structure file that was generated by the previous command. The -cs flag is the solvent configuration structure file that comes standard with a Gromacs installation. We are using spc216.gro, which is a generic equilibrated 3-point solvent model. You can use spc216.gro as the solvent configuration for SPC, SPC/E, or TIP3P water, since they are all three-point water models. The -o flag indicates a new output structure file that contains both the protein and the solvent. The -p flag is our topology file generated above, which will be modified to include the solvent force fields as well.

Adding ions

Usually, we will want to add small molecule ions (NaCl) in order to neutralize the system (if the protein has a nonzero net charge) and to perform the simulation at physiological or experimental salt conditions. The Gromacs command genion will randomly replace water molecules with ions. In order to run genion we need to generate a compiled Gromacs input file (.tpr) file called a run input file. A .tpr file contains information from both the structure file (.gro) and topology file (.tpr) and is generated using the grompp (Gromacs pre-processor) command, which will also be used later when we run our first simulation.

To produce a .tpr file, we need an additional input file with extension .mdp (molecular dynamics parameter file) that contains specified parameters for running a simulation. For this tutorial, you can use the ions.mdp file. We then generate the .tpr file as follows:

{% highlight git %} gmx grompp -f ions.mdp -c 1ubq_solv.gro -p 1ubq.top -o ions.tpr {% endhighlight %}

where -o specifies the output .tpr file which we have called ions.tpr. We have now generated a compiled file called ions.tpr. Now we can add small ions with the command

{% highlight git %} gmx genion -s ions.tpr -o 1ubq_solv_ions.gro -p 1ubq.top -conc 0.15 -neutral {% endhighlight %}

where the -conc signals to make the final ion concentration 0.15 M (physiological salt concentration) and -neutral signals to neutralize the system so that the net charge in the system is zero. Gromacs will randomly replace certain molecules with small ions to reach our specified concentration and charge balance. When prompted select group 13 for SOL, which is the solvent group. This will tell Gromacs to replace some of the solvent molecules with small ions. We now have a simulation box containing our protein, water, and salt. To run an MD simulation we need the generated Gromacs structure file (1ubq_solv_ions.gro) and the Gromacs topology file (1ubq.top).

Energy Minimization

Before we can run a MD simulation, we need to relax the system to remove steric clashes or unphysical geometries. To run an energy minimization we need another .mdp file that contains the parameters for the energy minimization. You can use the em.mdp file. Again we use the grompp command to compile a Gromacs .tpr file.

{% highlight git %} gmx grompp -f em.mdp -c 1ubq_solv_ions.gro -p 1ubq.top -o em.tpr {% endhighlight %}

where -o signals the output em.tpr file. Now to run the energy minimization we use the Gromacs mdrun command

{% highlight git %} gmx mdrun -v -deffnm em {% endhighlight %}

The -v flag means "verbose" and means that Gromacs will print to the screen the minimization process each step. The -deffnm flag signals to make all output files the same name as the input file, here "em". The output files will be em.log (ASCII-text log file), em.edr (binary energy file), em.trr (binary full-precision trajectory), and em.gro (the final energy minimized structure). It is a good idea to check how the total potential energy changes during the minimization. We can used the generated em.edr file for this analysis.

{% highlight git %} gmx energy -f em.edr -o potential.xvg {% endhighlight %}

At the prompt, select "10" for the potential energy, and then hit "0" to terminate the input. Plot the generated potential.xvg using the Xmgrace plotting tool and see that the potential energy is converging to a minimum.

{% highlight git %} xmgrace potential.xvg {% endhighlight %}

A plot of the potential energy is shown below:

![]({{ site.url }}{{ site.baseurl }}/images/potential.png){: style="width: 600px; border: 10px"}

To verify the energy minimization was successful, the potential energy in (kJ/mol) should be negative, and (for a simple protein in water) on the order of –105 to –106, depending on the system size and number of water molecules.

Equilibration Run 1

Energy minimization from above optimizes the local geometry and solvent orientation. Before we can run a long MD trajectory, we still need to equilibrate the solvent molecules and ions around the protein at the temperature we wish to simulate. For the first phase of equilibration we will use an NVT ensemble (constant number of particles, volume and temperature). We will perform a short (100 ps) simulation with the protein positions restrained. Position restraints thus allow us to equilibrate the solvent around the protein, without causing significant structural changes in the protein. The restraint parameters are contained in the posre.itp file. Again we use a .mdp file containing the parameters for the simulation. These parameters are specified in the file nvt.mdp file.

We use the grompp command as before:

and mdrun just as we did at the energy minimization (EM) step

{% highlight git %} gmx grompp -f nvt.mdp -c em.gro -p 1ubq.top -o nvt.tpr -r em.gro {% endhighlight %}

where em.gro is the energy-minimized structure from above.

Take note of a few parameters in the nvt.mdp file by opening this file in a text editor of your choice. A few important lines to note are:

{% highlight git %} define = -DPOSRES; This sets position restraint on the protein gen_vel = yes; Initiates velocity generation. Using different random seeds (gen_seed) gives different initial velocities, and thus multiple (different) simulations can be conducted from the same starting structure. tcoupl = V-rescale; The velocity rescaling thermostat is an improvement upon the Berendsen weak coupling method, which did not reproduce a correct kinetic ensemble. pcoupl = no: Pressure coupling is not applied. {% endhighlight %}

Finally we can run the molecular dynamics as follows

{% highlight git %} gmx mdrun -v -deffnm nvt {% endhighlight %}

When the equilibration is finished you can analyze the temperature progression

{% highlight git %} gmx energy -f nvt.edr -o temperature.xvg {% endhighlight %}

Type "16 0" at the prompt to select the temperature of the system and exit. You can view the temperature progression using xmgrace

{% highlight git %} xmgrace temperature.xvg {% endhighlight %}

A plot of the temperature is shown below:

![]({{ site.url }}{{ site.baseurl }}/images/temperature.png){: style="width: 600px; border: 10px"}

Here we can see that over the course of the 1 ps equilibration run, the temperature is fluctuating around 300 K as expected.

Additional Equilibration Runs

The previous step, NVT equilibration, stabilized the temperature of the system. If we want to perform the simulation in the NVT ensemble at a particular density, we also need to perform an equilibration in the NPT ensemble at a specified temperature and pressure to allow the system density to reach its equilibrated value. This can be done using the mdp file npt.mdp

Again we use the grompp command:

{% highlight git %} gmx grompp -f npt.mdp -c nvt.gro -p 1ubq.top -o npt.tpr -r nvt.gro {% endhighlight %}

where nvt.gro is the final structure from the above nvt equilibration. Note here we no longer include the position restraint on the protein. Additionally, in the npt.mdp file we have added the Parrinello-Rahman barostat

{% highlight git %} pcoupl = Parrinello-Rahman ; Pressure coupling is applied. pcoupltype = isotropic ; uniform scaling of box vectors tau_p = 2.0 ; time constant, in ps ref_p = 1.0 ; reference pressure, in bar compressibility = 4.5e-5 ; isothermal compressibility of water, bar^-1 {% endhighlight %}

Again we run the molecular dynamics as follows:

{% highlight git %} gmx mdrun -v -deffnm npt {% endhighlight %}

When the run is finished you can analyze the pressure fluctuations

{% highlight git %} gmx energy -f npt.edr -o pressure.xvg {% endhighlight %}

Type "17 0" at the prompt to select the pressure of the system and exit. View the pressure progression using xmgrace

{% highlight git %} xmgrace pressure.xvg {% endhighlight %}

A plot of the pressure is shown below:

![]({{ site.url }}{{ site.baseurl }}/images/pressure.png){: style="width: 600px; border: 10px"}

The instantaneous pressure value fluctuates widely over the course of the equilibration run, but this behavior is not unexpected. (Why do you think the instantaneous pressure fluctuates so much?) Over the course of the equilibration, the average value of the pressure is around 1 bar.

Often you will perform several equilibration steps to reach the desired target ensemble. Some common equilibration work-flows are show below. This figure taken from LivingJ.Comp.Mol.Sci.2019,1(1),5957

![]({{ site.url }}{{ site.baseurl }}/images/equilscheme.png){: style="width: 600px; border: 10px"}

Production Run

Once the system has been equilibrated we can run a longer production run. Here we will perform the simulation in the NVT ensemble using the following mdp file production_nvt.mdp

in the production_nvt.mdp file we have extended the simulation time to 5 ns:

{% highlight git %} nsteps = 2500000 ; 2 * 2500000 = 50000 ps (5 ns) dt = 0.002 ; 2 fs {% endhighlight %}

This is a short production run for this tutorial. For an actual production run, you would need to run the simulation for much longer.

Again, we use the grompp command:

{% highlight git %} gmx grompp -f production_nvt.mdp -c npt.gro -p 1ubq.top -o production_nvt.tpr -r npt.gro {% endhighlight %}

where npt.gro is the final structure from the above npt equilibration. And we run the production molecular dynamics as follows:

{% highlight git %} gmx mdrun -v -deffnm production_nvt {% endhighlight %}

This may take some time if running on a personal PC. Once it is finished you can check out the Analyzing a MD trajectory tutorial.