-
Notifications
You must be signed in to change notification settings - Fork 15
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
[BUG] Unable to save to RST7 file #130
Comments
This is because the GROMACS coordinates/velocities overflow the formatting restriction of the AMBER RST7 format. As always, you can get the full error message with In [1]: import BioSimSpace as BSS
In [2]: BSS.setVerbose(True)
In [3]: s = BSS.IO.readMolecules("test.*")
In [4]: BSS.IO.saveMolecules("test", s, "rst7")
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/lester/Code/openbiosim/biosimspace/python/BioSimSpace/IO/_io.py:743 in saveMolecules │
│ │
│ 740 │ │ │ │ _os.rename(file, new_file) │
│ 741 │ │ │ │ file = [new_file] │
│ 742 │ │ │ else: │
│ ❱ 743 │ │ │ │ file = _SireIO.MoleculeParser.save( │
│ 744 │ │ │ │ │ system._sire_object, filebase, _property_map │
│ 745 │ │ │ │ ) │
│ 746 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: SireError::io_error: Cannot write the (perhaps some of the ) files as the following errors occurred:
Failed to write the file '/home/lester/Downloads/Archive/test.rst7' using the parser for fileformat 'RST7'. Errors reported by the parser are:
Errors converting the system to a Amber Rst7 format...
Could not write the float at index 3138, value '-1203.8' into the specified format AmberFormat( 6 x float[width = 12, precision = 7] ).
Could not write the float at index 4691, value '-1163.52' into the specified format AmberFormat( 6 x float[width = 12, precision = 7] ). (call
sire.error.get_last_error_details() for more info)
The above exception was the direct cause of the following exception:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1 │
│ │
│ /home/lester/Code/openbiosim/biosimspace/python/BioSimSpace/IO/_io.py:755 in saveMolecules │
│ │
│ 752 │ │ except Exception as e: │
│ 753 │ │ │ msg = "Failed to save system to format: '%s'" % format │
│ 754 │ │ │ if _isVerbose(): │
│ ❱ 755 │ │ │ │ raise IOError(msg) from e │
│ 756 │ │ │ else: │
│ 757 │ │ │ │ raise IOError(msg) from None │
│ 758 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: Failed to save system to format: 'rst7' |
In this case, it's the velocities, so the file can be written using: In [5]: BSS.IO.saveMolecules("test", s, "rst7", property_map={"velocity":"null"})
Out[5]: ['/home/lester/Downloads/Archive/test.rst7'] |
Duplicate of michellab/BioSimSpace#404. |
Why would the velocity be a problem in this case? It seems to me that the velocity is fine? |
The challenge is that rst7 is a fixed format file. Numbers are written using a 12.7 specifier, meaning there is only space for 4 columns before the decimal point, then a decimal point, then 7 columns after the decimal point. The velocity "-1203.8" needs 5 columns before the decimal point, so it can't be written using the 12.7 format specifier used by rst7. It would be better to use the binary Amber rst format if you want velocities. It is too easy for velocities to become larger than can be fitted into a rst7 file. |
@chryswoods Thanks. Do you know which atom is giving this velocity? I don't think any atom should have a velocity this high |
Ok, you are right. |
Yes - it is a challenge with rst7 formats. It is best treated as a "legacy" file format, and alternatives that store values as binary data should be preferred (e.g. rst, trr or xdr - note that xdr stores numbers at a much lower "compressed" precision) |
Describe the bug
I have a Gromacs topology and coordinate file and I tried to save it as RST7 file
To Reproduce
Expected behavior
It writes
Input files
Archive.zip
(please complete the following information):
dev
release]The text was updated successfully, but these errors were encountered: