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

Unable to generate GROMACS binary run input file #20

Closed
fjclark opened this issue Mar 10, 2023 · 7 comments
Closed

Unable to generate GROMACS binary run input file #20

fjclark opened this issue Mar 10, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@fjclark
Copy link
Contributor

fjclark commented Mar 10, 2023

I have some AMBER input files which can be loaded without issue by SOMD and AMBER, but cannot be used with GROMACS.

When I run:

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ["BSS_VERBOSE_ERRORS"] = "1"
import BioSimSpace as BSS

system = BSS.IO.readMolecules(["bound_preequil.prm7", "bound_preequil.rst7"])

protocol = BSS.Protocol.Production( runtime=1*BSS.Units.Time.nanosecond)

# SOMD - works fine
process = BSS.Process.Somd(system, protocol, platform="CUDA",  work_dir="output", extra_options={"nmoves": 500_000, "ncycles":1})
print("SOMD successful")
# Amber
process = BSS.Process.Amber(system, protocol, work_dir="output")
print("Amber successful")
# Gromacs - does not start
process = BSS.Process.Gromacs(system, protocol, work_dir="output")
print("Gromacs successful")

This gives:

SOMD successful
Amber successful
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/finlayclark/Documents/research/adaptive_sampling/full_run_test/test_gromacs_failure/test_g │
│ romacs.py:17 in <module>                                                                         │
│                                                                                                  │
│   14 process = BSS.Process.Amber(system, protocol, work_dir="output")                            │
│   15 print("Amber successful")                                                                   │
│   16 # Gromacs - does not start                                                                  │
│ ❱ 17 process = BSS.Process.Gromacs(system, protocol, work_dir="output")                          │
│   18 print("Gromacs successful")                                                                 │
│   19                                                                                             │
│                                                                                                  │
│ /home/finlayclark/anaconda3/envs/mamba/envs/openbiosim-dev/lib/python3.9/site-packages/BioSimSpa │
│ ce/Process/_gromacs.py:217 in __init__                                                           │
│                                                                                                  │
│    214 │   │   │   │   │   )                                                                     │
│    215 │   │                                                                                     │
│    216 │   │   # Now set up the working directory for the process.                               │
│ ❱  217 │   │   self._setup()                                                                     │
│    218 │                                                                                         │
│    219def _setup(self):                                                                     │
│    220 │   │   """Setup the input files and working directory ready for simulation."""           │
│                                                                                                  │
│ /home/finlayclark/anaconda3/envs/mamba/envs/openbiosim-dev/lib/python3.9/site-packages/BioSimSpa │
│ ce/Process/_gromacs.py:268 in _setup                                                             │
│                                                                                                  │
│    265 │   │   if isinstance(self._protocol, _Protocol.Custom):                                  │
│    266 │   │   │   self.setConfig(self._protocol.getConfig())                                    │
│    267 │   │   else:                                                                             │
│ ❱  268 │   │   │   self._generate_config()                                                       │
│    269 │   │   self.writeConfig(self._config_file)                                               │
│    270 │   │                                                                                     │
│    271 │   │   # Generate the dictionary of command-line arguments.                              │
│                                                                                                  │
│ /home/finlayclark/anaconda3/envs/mamba/envs/openbiosim-dev/lib/python3.9/site-packages/BioSimSpa │
│ ce/Process/_gromacs.py:376 in _generate_config                                                   │
│                                                                                                  │
│    373 │   │   gromacs_config = _GromacsConfig(                                                  │
│    374 │   │   │   self._system, self._protocol, self._property_map                              │
│    375 │   │   )                                                                                 │
│ ❱  376 │   │   self.setConfig(                                                                   │
│    377 │   │   │   gromacs_config.createConfig(                                                  │
│    378 │   │   │   │   version=_gmx_version,                                                     │
│    379 │   │   │   │   extra_options={**config_options, **self._extra_options},                  │
│                                                                                                  │
│ /home/finlayclark/anaconda3/envs/mamba/envs/openbiosim-dev/lib/python3.9/site-packages/BioSimSpa │
│ ce/Process/_gromacs.py:540 in setConfig                                                          │
│                                                                                                  │
│    537 │   │   super().setConfig(config)                                                         │
│    538 │   │                                                                                     │
│    539 │   │   # Use grompp to generate the portable binary run input file.                      │
│ ❱  540 │   │   self._generate_binary_run_file()                                                  │
│    541 │                                                                                         │
│    542def start(self):                                                                      │
│    543 │   │   """                                                                               │
│                                                                                                  │
│ /home/finlayclark/anaconda3/envs/mamba/envs/openbiosim-dev/lib/python3.9/site-packages/BioSimSpa │
│ ce/Process/_gromacs.py:491 in _generate_binary_run_file                                          │
│                                                                                                  │
│    488 │   │   │   │   │   │   + "\nUse 'ignore_warnings' to ignore warnings."                   │
│    489 │   │   │   │   │   )                                                                     │
│    490 │   │   │   │                                                                             │
│ ❱  491 │   │   │   │   raise RuntimeError(exception_string)                                      │
│    492 │   │   │                                                                                 │
│    493 │   │   │   else:                                                                         │
│    494 │   │   │   │   raise RuntimeError(                                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Unable to generate GROMACS binary run input file.

'gmx grompp' reported the following errors:
ERROR 1 [file gromacs.top, line 62]:
  Expected a molecule type name and nrexcl
  ERROR 2 [file gromacs.top, line 18167]:
  Expected a molecule type name and nrexcl
  ERROR 3 [file gromacs.top, line 18167]:
  moleculetype BioSimSpace is redefined

Please see the input.

OS: Ubuntu 22
Version of Python: 3.9.15
Version of BioSimSpace: latest dev release, installed this morning

Thanks.

@fjclark fjclark added the bug Something isn't working label Mar 10, 2023
@lohedges
Copy link
Contributor

lohedges commented Mar 10, 2023

This is because the molecule name has a space in it. I thought I fixed this issue recently, but must have not updated the code in all the correct places. Hopefully an easy fix. For example:

[ moleculetype ]
; name  nrexcl
BioSimSpace Syst  3

When creating a system, I now name as BioSimSpace_System. Will figure out where I've forgotten to do this.

@lohedges
Copy link
Contributor

Just to check. I assume that this system was previously solvated with BioSImSpace? The only place where I seem to have missed during the solvation, although I don't think this is used. Is this a recent file? Perhaps it was created a while ago and you are only just using it with GROMACS?

@lohedges
Copy link
Contributor

I've updated the name in BIoSimSpace.Solvent, but I don't think that's causing the issue. If you did generate the files a while ago, you might need to edit the names in the prm7 file. I might be able to add functionality to do this automatically when writing to GROMACS format within the sire.legacy.IO.GroTop parser, i.e. make sure that the names in the moleculetype records don't have spaces. @chryswoods: What do you think?

@chryswoods
Copy link
Contributor

Yes - I think the GroTop parser should be modified to automatically replace spaces in molecule names with underscores.

@chryswoods
Copy link
Contributor

(especially as the molecule type isn't a value that is read back into the system when you read from a gromacs topology file - it is just an identifier into the "database" of molecular topologies)

@fjclark
Copy link
Contributor Author

fjclark commented Mar 10, 2023

Thanks very much for this.

Just to check. I assume that this system was previously solvated with BioSImSpace? The only place where I seem to have missed during the solvation, although I don't think this is used. Is this a recent file? Perhaps it was created a while ago and you are only just using it with GROMACS?

Yes, this is an old input file generated with BioSimSpace a while ago which I've never used with GROMACS - I'll sort the names, thanks.

@fjclark fjclark closed this as completed Mar 10, 2023
@lohedges
Copy link
Contributor

The weird thing is that things were named as "BioSimSpace System" for a long time. I can only assume that gmx grompp was updated at some point (I'm not sure when) to split certain records on whitespace rather than using a fixed width. Annoyingly, this means that old files written by BioSImSpace can no longer be run without editing. I agree that the correct approach is to fix this in the GroTop parser by enforcing that molecule names have no spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants