Project

General

Profile

Bug #338

gro files incorrectly written

Added by Erik Marklund about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Erik Lindahl
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

The final structure after a vacuum simulation is written in a bad way that makes it unreadable by the analysis tools. Water molecules that evaporate from the analyte get large absolute coordinates that, when written by mdrun, violates the fixed gro-format. The same thing happens when gro files are written as output from analysis tools such as g_cluster. Here's an example:

...
20CSER OC1 303 0.091 0.143 0.936
20CSER OC2 304 -0.035 0.296 0.834
21SOL OW 305-8527.5105846.6585201.934
21SOL HW1 306-8527.5635846.6335202.012
21SOL HW2 307-8527.4415846.7145201.968
22SOL OW 308 -0.645 0.299 0.495
22SOL HW1 309 -0.632 0.209 0.526
...

This was done using gmx 4.0.4 btw.

History

#1 Updated by Erik Marklund about 10 years ago

If anyone's interested, here's a semi-dirty workaround to use until this gets fixed in gromacs. It's written in python, and will read the file f and write the fixed file fo. The large coordinates will be somewhat mangled. (Some lines may be wrapped below)

def groFixer(f, fo):
if os.path.exists(f): # Do the fix
try:
infile = open(f, 'r')
except:
print "An error occured when opening file "+f
return False
try:
outfile = open(fo, 'w')
except:
print "An error occured when opening file "+fo
return False

lnr = 0
try:
for line in infile:
if lnr >= 2 and len(line.strip('. 0123456789\n'))!=0:
coords = line[20:]
xdot = coords.index('.')
ydot = coords[xdot+1:].index('.')+xdot+1
zdot = coords[ydot+1:].index('.')+ydot+1
x = coords[:xdot+1].rjust(5)[-5:]+coords[xdot+1:].ljust(3)[:3]
y = coords[:ydot+1].rjust(5)[-5:]+coords[ydot+1:].ljust(3)[:3]
z = coords[:zdot+1].rjust(5)[-5:]+coords[zdot+1:].ljust(3)[:3]
nline = line[:20] x+y+z'\n'
else:
nline = line
try:
outfile.write(nline)
except:
print "An error occured when writing to file "+fo
infile.close()
outfile.close()
return False
lnr = lnr + 1
infile.close()
outfile.close()
return True
except:
print "An error occured when reading from file "+f
infile.close()
outfile.close()
return False
else:
print "No such file "+f
return False

#2 Updated by David van der Spoel about 10 years ago

There is no real solution to this problem, because this is a fixed format, i.e. we cannot make the columns wider. We should abolish the file format. You can use .g96 or .xyz instead.

#3 Updated by Erik Marklund about 10 years ago

Agreed. Sort of. You're probably right, that the file format should be abandoned, but as long as it's still supported it's problematic that gromacs writes files that gromacs can't read. Rethorical: And as you say, it's fixed format; why then isn't gromacs sticking to it in this case?

Perhaps capping the written coordinates, or wrapping them periodically at 9999.999 and -999.999. It's certainly not pretty, potentially dangerous, and a warning should be issued. But the present case isn't good either, and a warning should be printed even if we keep on writing the files the way we do imho.

Also available in: Atom PDF