Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRO coordinate files have fixed-column width format #115

Closed
GoogleCodeExporter opened this issue Apr 4, 2015 · 4 comments
Closed

GRO coordinate files have fixed-column width format #115

GoogleCodeExporter opened this issue Apr 4, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

If you try to read any .gro file in which columns are not separated by blanks, 
for instance with a line like this:
12875SOL    HW151606   9.098   4.794   2.060-16.9931 -3.6174 -9.4839
the program crashes:
Traceback (most recent call last):
  ...
  File ".../MDAnalysis/core/AtomGroup.py", line 1800, in __init__
    self.load_new(coordinatefile, **kwargs)
  File ".../MDAnalysis/core/AtomGroup.py", line 1862, in load_new
    self.trajectory = TRJReader(filename, **kwargs)    # unified trajectory API
  File ".../MDAnalysis/coordinates/GRO.py", line 94, in __init__
    coords_list.append( numpy.array( map( float , line[20:].split()[0:3] ) ) )
ValueError: invalid literal for float(): 2.060-16.9931

data in .gro files is disposed in fixed width columns, a reader method should 
not rely on blank line splitting as currently does the implementation found in 
MDAnalysis/coordinates/GRO.py

MDAnalysis-0.7.6, python implementation error, platform independent

Original issue reported on code.google.com by pedro...@gmail.com on 10 Jul 2012 at 4:15

@GoogleCodeExporter
Copy link
Author

Thanks. Could you attach a small GRO file for testing? (We will include the 
file with the MDAnalysis test suite so you by sending it you licence it under 
the GPL and you should not send anything confidential)

Original comment by orbeckst on 10 Jul 2012 at 6:00

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

Here it is. According to the specification,
http://manual.gromacs.org/online/gro.html
things can become even more complicated. For parsing fixed column fields in 
python the module struct might be useful

Original comment by pedro...@gmail.com on 11 Jul 2012 at 9:00

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks for the example. 

We also have MDAnalysis.core.util.FORTRANReader (see 
http://packages.python.org/MDAnalysis/documentation_pages/core/util.html#MDAnaly
sis.core.util.FORTRANReader ) to parse fixed columns with FORTRAN editstrings 
(3F8.3 1X 3A ...) but that came after the GRO reader :-).

Original comment by orbeckst on 11 Jul 2012 at 10:50

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Fixed - should work with any precision now.
Also, I didn't attach the column_test.gro - I just modified 
sample_velocity_file.gro so that it tests for the same problem.

Original comment by Danny.Pa...@gmail.com on 12 Jul 2012 at 4:21

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant