How to create an index file in GROMACS
The gmx make_ndx command
Molecular Dynamics recently established itself as one of the most important techniques in molecular biology, and several programs, including GROMACS, are commonly used to perform simulations.
In a previous article I introduced you to the basic functions and commands of the program. They are mostly required to simply set up and run an MD simulation.
However, one of the main advantage of GROMACS is that it also comes with a number of useful tools to “play” with your system.
In this article, you can find a general overview of the gmx make_ndx
command. A useful tool that you may find helpful for your routine investigations.
The gmx make_ndx command
Let’s start from the basics.
GROMACS comes with different file formats that are needed to perform different actions. One of them is the ndx file format.
This file is simply composed by different sets of atoms.
By default GROMACS creates a default index file for your system. This means that when you don’t specify an index file GROMACS will use the default one.
In most cases, the default index file provided by GROMACS will do just fine.
However, in some others, this might not be enough, and you will need to create your own index file with some special groups of atoms that you need for your investigations.
Here I will demonstrate how to create, edit and use index files through different example and explaining the commands to manipulate them.
Creating a new index
Let’s assume that you have a large system but you are interested in taking into account just a small part of it.
What you can do in GROMACS is to generate an index file (index.ndx
), and create a new group containing only the parts you are interested in.
You can use the gmx make_ndx
command like this.
|
|
- Call the program with
gmx
- Select the
make_ndx
command - Select the
-f
flag and provide the starting structure (system.gro
) - Call the
-o
flag and decide how you want to name the output file (index.ndx
)
Once the program runs you will be prompted a list of groups. Something resembling this text below.
|
|
The names of the groups are quite self explanatory.
In the bottom of the screen you will find a series of commands that you can use to create new groups for your analysis.
To add a special index composed of the Protein (group 1) and the lipids CHL1 (group 13) , and POPC (group 14) you can enter the following:
|
|
You can press Enter to see an updated version of the groups in the index file.
|
|
As you can see we have a new selection named 18 Protein_CHL1_POPC
. To rename this group to Protein_Lipids
you can type:
|
|
|
|
You can play with the selection tool in various ways.
For instance, you can also select a range of atoms you want to analyze. If you want to consider atoms 1 to 100 you have to type:
|
|
In the same fashion, you can select some residues in a protein.
|
|
You also have some more sophisticated ways of using the selection tool. For instance, if you want to select only the heavy atoms from the protein you can type:
|
|
which stands for group 1 and (&) not (!) atoms (a) hydrogens (H).
To view the complete list of groups again, simply press enter at the prompt. If you want to remove a selection, type del
followed by the selection number:
|
|
When you are done remember to save and quit with q
.
Modify an existing index
Of course, once you created your special index you can also modify it.
|
|
- Call the program with
gmx
- Select the
make_ndx
command - Select the
-f
flag and provide the starting structure (system.gro
) - Call the
-n
flag and give GROMACS the index you previously created (index.ndx
)
Now you can modify it as already highlighted above.
How to use an index file
An index file is not useful by itself. It needs to be passed to other GROMACS commands to run some specific analysis.
This is generally achieved by passing an index file via the -n
flag.
You can find some practical use cases of index files in other articles in this website.
Here I show you how to use an index file to analyze the trajectory of a specific part of the system.
You can also use it to calculate the RMSD for some particular regions as showed here.