Error due to line in input file longer than 4095 characters

GROMACS version: 2020.2
GROMACS modification: No

Hey guys!

I’m currently attempting to run a coarse-grained MD simulation on a large protein (>15000 residues) on Gromacs 2020.2, but I get the following error after minimization (attached below). There seems to be a few lines (one denoting the residue codes in order, and one denoting the secondary structure designations for all of them) that exceed 4095 lines, and I think they’re causing this error. Does anyone know how I can fix this?

I’ve seen other posts with the same issue in Gromacs 4.6.5, and some comments mention to edit the file “src/gromacs/gmxpreprocess/readir.cpp.” However, I couldn’t find this file in the Gromacs directory.

Thanks,
Surya


Program: gmx grompp, version 2020.2
Source file: src/gromacs/utility/cstringutil.cpp (line 97)

Fatal error:
An input file contains a line longer than 4095 characters, while the buffer
passed to fgets2 has size 4095. The line starts with: ‘; NKSQLYPDSPLTDQDFNQ’

For more information and tips for troubleshooting, please check the GROMACS
website at Errors - Gromacs

What input files and which type of input them are causing the issues?

Hello,

It seems that the *.itp files that my *.top file is referencing have extremely long lines, due to the number of residues in my protein structure. The issue arises when I try to create a *.tpr file for minimization (before solvating the structure).

Thanks,
Surya

I don’t see how a line in the topology can get beyond 4095 characters because you have residue number requiring 5 digits. Could you post a problematic line?

Hello,
It seems that the long line in the *.itp file is there because Martini (which I’m using for coarse-graining) automatically adds a sequence and secondary structure codes for each residue at the beginning of the file:

; MARTINI (martini22) Coarse Grained topology file for “Protein_A”
; Created by py version 2.6
; Using the following options: -f enc_clean.pdb -o enc.top -x enc-cg.pdb -p backbone -ff martini22
; Sequence:

; NKSQLYPDSPLTDQDFNQLDQTVIEAA…

; Secondary Structure:

; CCCCCCCCCCCCCCCCCCCCCCCCC…

I guess this part of the file is not crucial for the run, so I think I’ll remove it for now, but then use it again when generating the trajectory files at the end, so that all atoms appear (and not just the backbone).

Thanks,
Surya

Hi, I am having the same problem.

I am trying to rerun an old simulation, using the files used then. I have an error:


 :-) GROMACS - gmx grompp, 2024.3-Homebrew (-:

Executable:   /usr/local/bin/../Cellar/gromacs/2024.3/bin/gmx
Data prefix:  /usr/local/bin/../Cellar/gromacs/2024.3
Working dir:  /Volumes/Erastova/Members/Kacper_eddie/2021/model/neu/tip4pq/layer_02
Command line:
  gmx grompp -f em.mdp -c layer -p layer

Ignoring obsolete mdp entry 'ns_type'
Setting the LD random seed to -16911425

-------------------------------------------------------
Program:     gmx grompp, version 2024.3-Homebrew
Source file: src/gromacs/utility/cstringutil.cpp (line 93)

Fatal error:
An input file contains a line longer than 4095 characters, while the buffer
passed to fgets2 has size 4095. The line starts with: '                    '

For more information and tips for troubleshooting, please check the GROMACS
website at https://manual.gromacs.org/current/user-guide/run-time-errors.html
-------------------------------------------------------

these were previously run on the GROMACS 2019.2, on a different machine.

(I am on a mac laptop right now)

If the files have worked before, but possibly in a different operating system, it is worth checking if it is just a problem with line endings, see https://discussions.apple.com/thread/6843546?sortBy=rank. Of course, you should back-up the original files beforehand.

If that does not help, then I think it would be easiest to open the three input files (em.mdp, layer.gro and layer.top) using less in the terminal and look for lines that are very long. More sophisticated text editors may hide such a errors by detecting what line endings are used in the file, so they may not help you.

Hi Magnus,

Yep, you are right about fancy text editors. I have checked all the files (incl. all the .itp) already - all good there. I always use either vi or sublime - I am sure we all have had experience of running for the help to dos2unix after recieving windows-touched files :D

I think I got to the bottom of this problem. For those coming to this page looking for the solution:
I am suspecting the issue is not in the files per se or my Mac or Gromacs version (I have updated it yesterday from 2023.1 to 2024.3 searching for solution), but it is in the location of the files. In my case, those files were on an university storage, mounted to my laptop as smb.

Another wierd thing I observed last night was gromacs outputting occasional .gro and .pdb files as binary!
(base) /V/E/M/K/2/m/z/t/layer_02 ❯❯❯ more zw_gly_c.pdb “zw_gly_c.pdb” may be a binary file. See it anyway? %
But then my VMD also started to spit out .pdb and .xyz as binaries - this is when it hinted to me the issue was not with gromacs.
Moving files from smb: into the directories on my actual computer have solved this issue.

Hope this is helpful for others running into this issue:)

Great that you found the problem and a solution. Thanks for sharing the details, I’m sure others might have use for this.

1 Like