gromacs.config – Configuration for GromacsWrapper

The config module provides configurable options for the whole package; eventually it might grow into a sophisticated configuration system such as matplotlib’s rc system but right now it mostly serves to define which gromacs tools and other scripts are offered in the package and where template files are located. If the user wants to change anything they will still have to do it here in source until a better mechanism with rc files has been implemented.

User-supplied templates are stored under gromacs.config.configdir. Eventually this will also contain the configuration options currently hard-coded in gromacs.config.

gromacs.config.configdir
Directory to store user templates and rc files. The default value is ~/.gromacswrapper.
gromacs.config.path
Search path for user queuing scripts and templates. The internal package-supplied templates are always searched last via gromacs.config.get_templates(). Modify gromacs.config.path directly in order to customize the template and qscript searching. By default it has the value ['.', qscriptdir, templatesdir]. (Note that it is not a good idea to have template files and qscripts with the same name as they are both searched on the same path.)

The user should execute gromacs.config.setup() at least once to prepare the user configurable area in their home directory:

import gromacs
gromacs.config.setup()

Logging

Gromacs commands log their invocation to a log file; typically at loglevel INFO (see the python logging module for details).

gromacs.config.logfilename
File name for the log file; all gromacs command and many utility functions (e.g. in gromacs.cbook and gromacs.setup) append messages there. Warnings and errors are also recorded here. The default is gromacs.log.
gromacs.config.loglevel_console
The default loglevel that is still printed to the console.
gromacs.config.loglevel_file
The default loglevel that is still written to the logfilename.

Gromacs tools and scripts

load_* variables are lists that contain instructions to other parts of the code which packages and scripts should be wrapped.

gromacs.config.load_tools
Python list of all tool file names. Automatically filled from gmx_tools and gmx_extra_tools, depending on the values in gmx_tool_groups.
gromacs.config.load_scripts

3rd party analysis scripts and tools; this is a list of triplets of

(script name/path, command name, doc string)

(See the source code for examples.)

load_tools is populated by listing gmx_* tool group variables in gmx_tool_groups.

gromacs.config.gmx_tool_groups
List of the variables in gromacs.tools that should be loaded. Possible values: gmx_tools, gmx_extra_tools. Right now these are variable names in gromacs.config, referencing gromacs.config.gmx_tools and gromacs.config.gmx_extra_tools.

The tool groups variables are strings that contain white-space separated file names of Gromacs tools. These lists determine which tools are made available as classes in gromacs.tools.

gromacs.config.gmx_tools

Contains the file names of all Gromacs tools for which classes are generated. Editing this list has only an effect when the package is reloaded. If you want additional tools then add the, to the source (config.py) or derive new classes manually from gromacs.core.GromacsCommand. (Eventually, this functionality will be in a per-user configurable file.) The current list was generated from Gromacs 4.0.99 (git). Removed (because of various issues)

  • g_kinetics
gromacs.config.gmx_extra_tools
Additional gromacs tools (add gmx_extra_tools to gromacs.config.gmx_tool_groups to enable them, provided the binaries have been provided on the PATH).

Location of template files

Template variables list files in the package that can be used as templates such as run input files. Because the package can be a zipped egg we actually have to unwrap these files at this stage but this is completely transparent to the user.

gromacs.config.qscriptdir
Directory to store user supplied queuing system scripts. The default value is ~/.gromacswrapper/qscripts.
gromacs.config.templatesdir
Directory to store user supplied template files such as mdp files. The default value is ~/.gromacswrapper/templates.
gromacs.config.templates

GromacsWrapper comes with a number of templates for run input files and queuing system scripts. They are provided as a convenience and examples but WITHOUT ANY GUARANTEE FOR CORRECTNESS OR SUITABILITY FOR ANY PURPOSE.

All template filenames are stored in gromacs.config.templates. Templates have to be extracted from the GromacsWrapper python egg file because they are used by external code: find the actual file locations from this variable.

Gromacs mdp templates

These are supplied as examples and there is NO GUARANTEE THAT THEY PRODUCE SENSIBLE OUTPUT — check for yourself! Note that only existing parameter names can be modified with gromacs.cbook.edit_mdp() at the moment; if in doubt add the parameter with its gromacs default value (or empty values) and modify later with edit_mdp().

The safest bet is to use one of the mdout.mdp files produced by gromacs.grompp() as a template as this mdp contains all parameters that are legal in the current version of Gromacs.

Queuing system templates

The queing system scripts are highly specific and you will need to add your own into gromacs.config.qscriptdir. See gromacs.qsub for the format and how these files are processed.
gromacs.config.qscript_template
The default template for SGE/PBS run scripts.
gromacs.config.setup()

Create the directories in which the user can store template and config files.

This function can be run repeatedly without harm.

Accessing configuration data

The following functions can be used to access configuration data. Note that files are searched first with their full filename, then in all directories listed in gromacs.config.path, and finally within the package itself.

gromacs.config.get_template(t)

Find template file t and return its real path.

t can be a single string or a list of strings. A string should be one of

  1. a relative or absolute path,
  2. a file in one of the directories listed in gromacs.config.path,
  3. a filename in the package template directory (defined in the template dictionary gromacs.config.templates) or
  4. a key into templates.

The first match (in this order) is returned. If the argument is a single string then a single string is returned, otherwise a list of strings.

Arguments:t : template file or key (string or list of strings)
Returns:os.path.realpath(t) (or a list thereof)
Raises:ValueError if no file can be located.
gromacs.config.get_templates(t)

Find template file(s) t and return their real paths.

t can be a single string or a list of strings. A string should be one of

  1. a relative or absolute path,
  2. a file in one of the directories listed in gromacs.config.path,
  3. a filename in the package template directory (defined in the template dictionary gromacs.config.templates) or
  4. a key into templates.

The first match (in this order) is returned for each input argument.

Arguments:t : template file or key (string or list of strings)
Returns:list of os.path.realpath(t)
Raises:ValueError if no file can be located.