Package gromacs :: Module formats :: Class MDP
[hide private]
[frames] | no frames]

Class MDP

source code

     object --+        
              |        
           dict --+    
                  |    
        odict.odict --+
                      |
         object --+   |
                  |   |
utilities.FileUtils --+
                      |
                     MDP

Class that represents a Gromacs mdp run input file.

The MDP instance is an ordered dictionary.

  - *Parameter names* are keys in the dictionary.
  - *Comments* are sequentially numbered with keys Comment0001,
    Comment0002, ...
  - *Empty lines* are similarly preserved as Blank0001, ....

When writing, the dictionary is dumped in the recorded order to a
file. Inserting keys at a specific position is not possible.

Currently, comments after a parameter on the same line are
discarded. Leading and trailing spaces are always stripped.

.. SeeAlso:: For editing a mdp file one can also use
            :func:`gromacs.cbook.edit_mdp` (which works like a
            poor replacement for sed).

Instance Methods [hide private]
new empty dictionary

__init__(self, filename=None, autoconvert=True, **kwargs)
Initialize mdp structure.
source code
 
_transform(self, value) source code
 
read(self, filename=None)
Read and parse mdp file filename.
source code
 
write(self, filename=None, skipempty=False)
Write mdp file to filename.
source code

Inherited from odict.odict: __cmp__, __copy__, __deepcopy__, __delitem__, __eq__, __getstate__, __iter__, __ne__, __repr__, __reversed__, __setitem__, __setstate__, byindex, clear, copy, index, items, iteritems, iterkeys, itervalues, keys, pop, popitem, reverse, setdefault, sort, update, values

Inherited from dict: __contains__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __le__, __len__, __lt__, __new__, get, has_key

Inherited from utilities.FileUtils: check_file_exists, filename, infix_filename

Inherited from utilities.FileUtils (private): _init_filename

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Methods [hide private]

Inherited from odict.odict: fromkeys

Class Variables [hide private]
  default_extension = 'mdp'
Default extension for files read/written by this class.
  logger = logging.getLogger('gromacs.formats.MDP')
  COMMENT = re.compile(r'\s*;\s*(?P<value>.*)')
  PARAMETER = re.compile(r'(?x)\s*(?P<parameter>[^=]+?)\s*=\s*(?...
Instance Variables [hide private]

Inherited from utilities.FileUtils: real_filename

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename=None, autoconvert=True, **kwargs)
(Constructor)

source code 
Initialize mdp structure.
Returns:
new empty dictionary

Overrides: object.__init__

Arguments:

filename
read from mdp file
autoconvert : boolean
True converts numerical values to python numerical types; False keeps everything as strings [True]
kwargs
Populate the MDP with key=value pairs. (NO SANITY CHECKS; and also does not work for keys that are not legal python variable names such as anything that includes a minus '-' sign or starts with a number).

write(self, filename=None, skipempty=False)

source code 

Write mdp file to filename.

Note

Overwrites the file that the mdp was read from if no filename supplied.

Keywords:

filename
output mdp file; default is the filename the mdp was read from
skipempty : boolean
True removes any parameter lines from output that contain empty values [False]


Class Variable Details [hide private]

PARAMETER

Value:
re.compile(r'(?x)\s*(?P<parameter>[^=]+?)\s*=\s*(?P<value>[^;]*)(?P<co\
mment>\s*;.*)?')