Trjconv mismatch in the contents of your -f, -s and/or -n files, but using the same index

GROMACS version: 2022.2
GROMACS modification: No

I am trying to split the peptide trajectory from my complete trajectory using and index with the atom number of my peptide. First I use the following code:

gromacs_path=*** # Path to the gromacs directory
analysis_path=*** # Path to the analysis directory

reference=step6.6_equilibration.tpr # Reference structure
trajectory=production_0_150.trr # Not centralized trajectory
output_traj=production_0_150_oxt_center.trr # Oxytocin centralized trajectory output file
index_complex=$analysis_path/indices/special_indices/index_appendices.ndx # Index file

gmx trjconv -s $gromacs_path/$reference \
-f $analysis_path/trajectories/$trajectory \
-o $analysis_path/trajectories/$output_traj \
-n $index_complex \
-center -pbc mol -ur compact

Where “index_appendices.ndx” contains the auto generated indices, such as protein, backbone, etc, and also my the peptide index that I created. So a select protein to centralize and the peptide to output. This first step works. But, in the next step, I want to split the frame 0 of this new trajectory as a pdb file:

gromacs_path=*** # Path to the gromacs directory
analysis_path=*** # Path to the analysis directory

reference=step6.6_equilibration.tpr # Reference structure
trajectory=production_0_150_oxt_center.trr # Reference trajectory
output_str=oxt_center_dump_0.pdb # Oxytocin centralized structure output file in PDB
index_complex=$analysis_path/indices/special_indices/index_appendices.ndx # Index file

gmx trjconv -s $gromacs_path/$reference \
-f $analysis_path/trajectories/$trajectory \
-o $analysis_path/structures/$output_str \
-n $index_complex \
-dump 0

Where I use the trajectory that I generated in the above step, the same index file and the same tpr reference file. But when I select the peptide as output I receive the following error:

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

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

I am not understanding what is happening, because this same execution where used to split other elements from the whole dynamic without problems. See below (the “Complex” index contains the atom numbers of the protein + drug + one magnesium atom + one cholesterol molecule):

gromacs_path=*** # Path to the gromacs directory
analysis_path=*** # Path to the analysis directory

# Select first "Protein" and then "Complex"

reference=step6.6_equilibration.tpr # Reference structure
trajectory=production_0_150.trr # Not centralized trajectory
output_traj=production_0_150_complex_center.trr # Complex centralized trajectory output file
index_complex=$analysis_path/indices/special_indices/index_appendices.ndx # Complex index file

gmx trjconv -s $gromacs_path/$reference \
-f $analysis_path/trajectories/$trajectory \
-o $analysis_path/trajectories/$output_traj \
-n $index_complex \
-center -pbc mol -ur compact

# Select "Complex"

reference=step6.6_equilibration.tpr # Reference structure
trajectory=production_0_150_complex_center.trr # Reference trajectory
output_estr=complex_center_dump_0.pdb # Complex centralized structure output file in PDB
index_complex=$analysis_path/indices/special_indices/index_appendices.ndx # Complex index

gmx trjconv -s $gromacs_path/$reference \
-f $analysis_path/trajectories/$trajectory \
-o $analysis_path/structures/$output_estr \
-n $index_complex \
-dump 0

This one works perfectly.

HI,
I guess the problem is that you provide an index file (and tpr) that does not correspond to the system in the xtc. Index file lists numbers corresponding to the atoms in peptide group when you generate the index file (complete trajectory). That is that atom 1 in the peptide trajectory is not atom 1 in the original trajectory.
If you want just extract the first frame of the new trajectory use the first command and add option -dump 0 and save a gro file in place of xtc file.

I hope it helps
Alessandra

1 Like