The module defines some convenience functions and classes that are used in other modules; they do not make use of gromacs.tools or gromacs.cbook and can be safely imported at any time.
FileUtils provides functions related to filename handling. It can be used as a base or mixin class. The gromacs.analysis.Simulation class is derived from it.
Mixin class to provide additional file-related capabilities.
If a file exists then continue with the action specified in resolve.
resolve must be one of
Alternatively, set force for the following behaviour (which ignores resolve):
Default extension for files read/written by this class.
Supply a file name for the class object.
Typical uses:
fn = filename() ---> <default_filename>
fn = filename('name.ext') ---> 'name'
fn = filename(ext='pickle') ---> <default_filename>'.pickle'
fn = filename('name.inp','pdf') --> 'name.pdf'
fn = filename('foo.pdf',ext='png',use_my_ext=True) --> 'foo.pdf'
The returned filename is stripped of the extension (use_my_ext=False) and if provided, another extension is appended. Chooses a default if no filename is given.
Raises a ValueError exception if no default file name is known.
If set_default=True then the default filename is also set.
use_my_ext=True lets the suffix of a provided filename take priority over a default ext tension.
Unless name is provided, insert infix before the extension ext of default.
A dictionary with pythonic access to keys as attributes — useful for interactive work.
Extension of datetime.timedelta.
Provides attributes ddays, dhours, dminutes, dseconds to measure the delta in normal time units.
ashours gives the total time in fractional hours.
Some additional convenience functions that deal with files and directories:
Context manager to open a compressed (bzip2, gzip) or plain file (uses anyopen()).
Open datasource (gzipped, bzipped, uncompressed) and return a stream.
Arguments : |
|
---|
Join all args and return the real path, rooted at /.
Returns None if any of the args is none.
Context manager to execute a code block in a directory.
Find first filename with a suffix from suffices.
Arguments : |
|
---|---|
Returns : | The first match or None. |
Return list in which each element is guaranteed to start with os.path.extsep.
Functions that improve list processing and which do not treat strings as lists:
Returns True if obj can be iterated over and is not a string.
Returns obj so that it can be iterated over; a string is not treated as iterable
Returns the first entry of a sequence or the obj.
Treats strings as single objects.
Functions that help handling Gromacs files:
Unlink path but do not complain if file does not exist.
Unlink (remove) Gromacs file(s) and all corresponding backups.
Unlink (rm) all backup files corresponding to the listed files.
Rename pdbs x1.pdb ... x345.pdb –> x0001.pdb ... x0345.pdb
Arguments : |
|
---|
Functions that make working with matplotlib easier:
Make subplot numPlot active on the canvas.
Use this if a simple subplot(numRows, numCols, numPlot) overwrites the subplot instead of activating it.
Remove legend for axes or gca.
See http://osdir.com/ml/python.matplotlib.general/2005-07/msg00285.html
Miscellaneous functions:
Converts between 3-letter and 1-letter amino acid codes.
translation table for 1-letter codes –> 3-letter codes .. Note: This does not work for HISB and non-default charge state aa!