Becksteinlab / GromacsWrapper

GromacsWrapper wraps system calls to GROMACS tools into thin Python classes (GROMACS 4.6.5 - 2024 supported).
https://gromacswrapper.readthedocs.org
GNU General Public License v3.0
169 stars 54 forks source link

"Unknown command-line option -include" with cbook.add_mdp_includes() #276

Open a-ws-m opened 2 months ago

a-ws-m commented 2 months ago

When I use gromacs.setup.energy_minimize() or gromacs.setup.MD(), I get the following error:

Program:     gmx grompp, version 2023.1
Source file: src/gromacs/commandline/cmdlineparser.cpp (line 271)
Function:    void gmx::CommandLineParser::parse(int*, char**)

Error in user input:
Invalid command-line options
    Unknown command-line option -include

For more information and tips for troubleshooting, please check the GROMACS
website at http://www.gromacs.org/Documentation/Errors

If I remove the contents of gromacs.cbook.add_mdp_includes(), the code works fine. Presumably it's necessary for some use cases, but I think the arguments need to be added to the MDP file, rather than on the command line.

orbeckst commented 2 months ago

The include = -I. -I.. line is always added so it's always present as an mdp_kwarg. However, any mdp_kwargs that have not been used are assumed to be options for gmx grompp https://github.com/Becksteinlab/GromacsWrapper/blob/463820c492fd2bdf989040626bf99514df605ff9/gromacs/setup.py#L881-L882

It's very ugly hack but about 15 years ago I couldn't think of anything better and obviously haven't thought about it since then.

So if you get gmx grompp -include ... (which you could verify by writing a log file with

gromacs.start_logging()

before your code starts) then I think the reason is that whatever you are using as a template for the MDP file does not contain a line

include = ...

Thus, the gw code above does not find a line in the mdp file to edit with the include, the include key is not removed from the kwargs dict, and check_mdpargs() finds stuff that it then repurposes as commandline options.

I'd try adding a include line to your MDP file.