Gmx trjconv Index Error

GROMACS version: 2024.1
GROMACS modification: No
Here post your question

Dear developers and users,
I converted the 5000 frame-trajectory to 250 frame-trajectory with gmx trjconv -skip. After that, I tried to run gmx trjconv -fit rot+trans command, but I got Index Error about atom numbers as you can see below. Then, I tried to make new index.ndx from npt.gro but DNA group does not seem in the index list although DNA indices have been in npt.gro. How can I fix this problem?

Command line:
gmx_mpi trjconv -f npt_500ns_250fr.tmp.pdb -tu ns -s npt.tpr -n index.ndx -o npt_250fr.pdb -fit rot+trans

Will write pdb: Protein data bank file
Reading file npt.tpr, VERSION 2024.1 (single precision)
Reading file npt.tpr, VERSION 2024.1 (single precision)
Group 0 ( System) has 1204488 elements
Group 1 ( Protein) has 16528 elements
Group 2 ( Protein-H) has 8194 elements
Group 3 ( C-alpha) has 1014 elements
Group 4 ( Backbone) has 3042 elements
Group 5 ( MainChain) has 4054 elements
Group 6 ( MainChain+Cb) has 5020 elements
Group 7 ( MainChain+H) has 4996 elements
Group 8 ( SideChain) has 11532 elements
Group 9 ( SideChain-H) has 4140 elements
Group 10 ( Prot-Masses) has 16528 elements
Group 11 ( non-Protein) has 1187960 elements
Group 12 ( Other) has 1754 elements
Group 13 ( ZN2) has 2 elements
Group 14 ( K) has 8 elements
Group 15 ( CLA) has 888 elements
Group 16 ( POT) has 864 elements
Group 17 ( MG) has 26 elements
Group 18 ( Ion) has 34 elements
Group 19 ( ZN2) has 2 elements
Group 20 ( K) has 8 elements
Group 21 ( CLA) has 888 elements
Group 22 ( POT) has 864 elements
Group 23 ( MG) has 26 elements
Group 24 ( DNA) has 3116 elements
Group 25 ( ZN2) has 2 elements
Group 26 ( K) has 8 elements
Group 27 ( CLA) has 888 elements
Group 28 ( POT) has 864 elements
Group 29 ( MG) has 26 elements
Group 30 ( Water) has 1183056 elements
Group 31 ( SOL) has 1183056 elements
Group 32 ( non-Water) has 21432 elements
Group 33 ( Water_and_ions) has 1183090 elements
Group 34 ( DNA_Protein) has 19644 elements
Group 35 (Water_and_ions2) has 1184844 elements
Group 36 (DNA_Protein_ZN2) has 19646 elements
Select a group: Group 0 ( System) has 1204488 elements
Group 1 ( Protein) has 16528 elements
Group 2 ( Protein-H) has 8194 elements
Group 3 ( C-alpha) has 1014 elements
Group 4 ( Backbone) has 3042 elements
Group 5 ( MainChain) has 4054 elements
Group 6 ( MainChain+Cb) has 5020 elements
Group 7 ( MainChain+H) has 4996 elements
Group 8 ( SideChain) has 11532 elements
Group 9 ( SideChain-H) has 4140 elements
Group 10 ( Prot-Masses) has 16528 elements
Group 11 ( non-Protein) has 1187960 elements
Group 12 ( Other) has 1754 elements
Group 13 ( ZN2) has 2 elements
Group 14 ( K) has 8 elements
Group 15 ( CLA) has 888 elements
Group 16 ( POT) has 864 elements
Group 17 ( MG) has 26 elements
Group 18 ( Ion) has 34 elements
Group 19 ( ZN2) has 2 elements
Group 20 ( K) has 8 elements
Group 21 ( CLA) has 888 elements
Group 22 ( POT) has 864 elements
Group 23 ( MG) has 26 elements
Group 24 ( DNA) has 3116 elements
Group 25 ( ZN2) has 2 elements
Group 26 ( K) has 8 elements
Group 27 ( CLA) has 888 elements
Group 28 ( POT) has 864 elements
Group 29 ( MG) has 26 elements
Group 30 ( Water) has 1183056 elements
Group 31 ( SOL) has 1183056 elements
Group 32 ( non-Water) has 21432 elements
Group 33 ( Water_and_ions) has 1183090 elements
Group 34 ( DNA_Protein) has 19644 elements
Group 35 (Water_and_ions2) has 1184844 elements
Group 36 (DNA_Protein_ZN2) has 19646 elements
Reading frame 0 time 0.000 b file
Precision of npt_500ns_250fr.tmp.pdb is 0.0001 (nm)


Program: gmx trjconv, version 2024.1
Source file: src/gromacs/tools/trjconv.cpp (line 1033)

Fatal error:
Index[19638] 19647 is larger than the number of atoms in the
trajectory file (19646). There is a mismatch in the contents
of your -f, -s and/or -n files.

Did you output all the atoms when you reduced the trajectory? Or just a subset of the system?

I choose Group 36 (DNA_Protein_ZN2), not all system.

Then that is the problem probably. Now, you structure is reduced , as you output only one part of the system, but you still provide a .tpr file that contains the whole system, which has more atoms.

Your options are:
(i) Try to redo the same analysis with the whole structure
(ii) Reduce the .tpr with something like gmx convert-tpr -s your_tpr.tpr -o new_tpr.tpr -n your_index.ndx. Select the same group as before (Group 36 DNA_Protein_ZN2), so now you have a structure that is only that group and a tpr that has only that group, and rerun the analysis with this new tpr.

Also, why is your trajectory a .pdb file? I am not completely sure the analysis of trjconv will work for a .pdb containing multiple frames!

I converted the 500 ns-trajectory to 250 frames with -skip option by using the .tpr file and the DNA_Protein_ZN2 index without any problem. So, I don’t need to use the .tpr file again. I just want to fit the trajectory by using -fit rot+trans option and I get the Fatal Error above.

I guess your index file does not match your selected output. If you still need an index file (if you need to select a subset of the system) you will have to create a new one.

Yes, I tried to create a new index file from npt.gro but the DNA does not exist in the index group list although DNA molecules have been in npt.gro, as I mentioned above. So, I could not create a new index file.

If you don’t have a matching TPR it is difficult for gmx make_ndx to propose suitable selection groups. You can always make a new index file by hand (or using e.g. Python). Look at the one you’ve got and make something similar, but with the correct atom ranges for your current system.