pygromacs package

Submodules

pygromacs.gmxfiles module

class pygromacs.gmxfiles.MdpFile(path='')[source]

Bases: builtins.object

Container for MDP files.

Parameters:path (str, optional) – Read from file at this path
path

Path to the last-read file. Used as default by save() when writing changes to disk.

lines

This is an ordered list of MdpOption objects, containing the parameters, values, and comments which together make up a file. It is a list to keep a read file as close to the original as possible when modifying it.

options

This is a dictionary of parameters, linking to objects in lines. Used internally to quickly access any parameter of that list and thus file.

class MdpOption(parameter='', value='', comment='', index=None)[source]

Bases: builtins.object

Container for an MDP option.

Parameters:
  • parameter (str) – A parameter,
  • value (str) – its value
  • comment (str) – and comment
  • index (int) – Index of option in MdpFile.lines
print(comment=True)[source]

Print option as a line.

Uses a standard MDP format. Use comment to print or ignore a comment.

MdpFile.get_option(parameter)[source]

Return the value of a parameter.

Parameters:parameter (str) – A parameter
Returns:The parameter value, empty if not found
Return type:str
MdpFile.print(comment=True)[source]

Print the current file.

Parameters:comment (bool, optional) – Print or ignore comments
MdpFile.print_option(parameter)[source]

Print a parameter, its value and comment.

MdpFile.read(path)[source]

Read an MDP file at path.

Updates path to given value. Parameters and lines are stored in lines and options.

MdpFile.remove_option(parameter)[source]

Remove a parameter from the file.

MdpFile.save(path='', verbose=True, ext='mdp')[source]

Save current MDP file.

The written content is set in lines.

Parameters:
  • path (str, optional) – Write file to this path (default: path)
  • verbose (bool, optional) – Print information about save
  • ext (str, optional) – Use this file extension (default: ‘mdp’)
MdpFile.search(parameter)[source]

Search for a parameter in the file.

Prints any matching option and its value.

Returns:Number of options found
Return type:int
MdpFile.set_comment(parameter, comment)[source]

Add a comment to a parameter.

MdpFile.set_option(parameter, value, comment='')[source]

Set a parameter value.

If the parameter is not set the option is appended to end of lines.

Parameters:
  • parameter (str) – A parameter to set,
  • value (str) – its new value
  • comment (str, optional) – and comment
class pygromacs.gmxfiles.Topol(**kwargs)[source]

Bases: builtins.object

pygromacs.utils module

pygromacs.utils.prepare_path(path, verbose=True)[source]

Prepare a path for writing.

Creates required directories and backs up any conflicting file.

Parameters:
  • path (str) – Path to file
  • verbose (bool, optional) – Whether or not to print information about a performed backup
Returns:

The path to a backed up file, empty if no backup was taken

Return type:

str

Module contents