Top Banner
MD Utilities Documentation Release 0.6.0 Chris Mayes November 22, 2015
54

MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

Jul 22, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities DocumentationRelease 0.6.0

Chris Mayes

November 22, 2015

Page 2: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates
Page 3: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

Contents

1 MD Utilities 31.1 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Installation 5

3 Usage 7

4 Documentation for the Code 94.1 calc_pka . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5 Contributing 115.1 Types of Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115.2 Get Started! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125.3 Pull Request Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125.4 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6 Credits 156.1 Development Lead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.2 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

7 History 17

8 0.6.0 (2015-11-22) 19

9 0.5.0 (2015-11-21) 21

10 0.4.2 (2015-10-24) 23

11 0.4.1 (2015-10-10) 25

12 0.4.0 (2015-10-01) 27

13 0.3.0 (2015-09-07) 29

14 0.2.0 (2015-09-03) 31

15 0.1.0 (2015-09-01) 33

16 md_utils package 3516.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

i

Page 4: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

16.2 md_utils.calc_pka module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3516.3 md_utils.calc_split_avg module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3616.4 md_utils.common module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3616.5 md_utils.fes_combo module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3916.6 md_utils.md_init module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4016.7 md_utils.wham module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4016.8 md_utils.wham_block module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4116.9 md_utils.wham_rad module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4216.10 md_utils.wham_split module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4316.11 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

17 Indices and tables 45

Python Module Index 47

ii

Page 5: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

Contents:

Contents 1

Page 6: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

2 Contents

Page 7: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 1

MD Utilities

Utility scripts for MD data

• Free software: BSD license

• Documentation: https://md_utils.readthedocs.org.

1.1 Scripts

fes_combo Combines multiple FES output files into a single file so that the first column’s value is sequential. Fileswith higher starting index numbers are favored.

wham_split Breaks wham input into increasingly smaller blocks (divide initial data set by 2, then 3, 4...) and createswham input (meta) files and submit scripts.

wham_rad Calculates the radially-corrected free energy values from WHAM output.

calc_pka From the wham_rad output, calculates the pKa.

path_bin Creates a summary VMD XYZ file (and separate log file) that averages a set of coordinates (one set of XYZcoordinates per line) from an input file.

press_dups Compresses lines in a given CSV based on duplicate values in a specified column (RMSD by default)Compressed lines have their values averaged.

lammps_dist Calculates the distances between a given set of atom pairs for each time step in a given LAMMPS dumpfile.

3

Page 8: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

4 Chapter 1. MD Utilities

Page 9: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 2

Installation

At the command line:

$ easy_install md_utils

Or, if you have virtualenvwrapper installed:

$ mkvirtualenv md_utils$ pip install md_utils

5

Page 10: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

6 Chapter 2. Installation

Page 11: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 3

Usage

To use MD Utilities in a project:

import md_utils

7

Page 12: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

8 Chapter 3. Usage

Page 13: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 4

Documentation for the Code

Molecular dynamics utilities.

4.1 calc_pka

This is something I want to say that is not in the docstring. Calculates the proton dissociation constant (PKA) for thegiven free energy data for a set of coordinates.

md_utils.calc_pka.calc_pka(file_data, kbt, coord_ts=None)Calculates the proton dissociation constant (PKA) for the given free energy data.

Parameters

• file_data – The list of dicts to process.

• kbt – The experimental temperature multiplied by Boltzmann’s Constant.

Returns The PKA for the given data set or an error string if no local max is found.

md_utils.calc_pka.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

md_utils.calc_pka.parse_cmdline(argv)Returns the parsed argument list and return code. :param argv: is a list of arguments, or None forsys.argv[1:].

md_utils.calc_pka.write_result(result, src_file, overwrite=False, basedir=None)Writes the result to a file named for the given source file.

Parameters

• result – The result to write.

• src_file – The original source file name.

• overwrite – Whether to overwrite an existing file name.

• basedir – The base directory to target (uses the source file’s base directory if not speci-fied)

9

Page 14: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

10 Chapter 4. Documentation for the Code

Page 15: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 5

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

5.1 Types of Contributions

5.1.1 Report Bugs

Report bugs at https://github.com/cmayes/md_utils/issues.

If you are reporting a bug, please include:

• Your operating system name and version.

• Any details about your local setup that might be helpful in troubleshooting.

• Detailed steps to reproduce the bug.

5.1.2 Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.

5.1.3 Implement Features

Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implementit.

5.1.4 Write Documentation

MD Utilities could always use more documentation, whether as part of the official MD Utilities docs, in docstrings, oreven on the web in blog posts, articles, and such.

5.1.5 Submit Feedback

The best way to send feedback is to file an issue at https://github.com/cmayes/md_utils/issues.

If you are proposing a feature:

11

Page 16: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

• Explain in detail how it would work.

• Keep the scope as narrow as possible, to make it easier to implement.

• Remember that this is a volunteer-driven project, and that contributions are welcome :)

5.2 Get Started!

Ready to contribute? Here’s how to set up md_utils for local development.

1. Fork the md_utils repo on GitHub.

2. Clone your fork locally:

$ git clone [email protected]:your_name_here/md_utils.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set upyour fork for local development:

$ mkvirtualenv md_utils$ cd md_utils/$ python setup.py develop

4. Create a branch for local development:

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing otherPython versions with tox:

$ flake8 md_utils tests$ python setup.py test$ tox

To get flake8 and tox, just pip install them into your virtualenv.

6. Commit your changes and push your branch to GitHub:

$ git add .$ git commit -m "Your detailed description of your changes."$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.

5.3 Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.

2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a functionwith a docstring, and add the feature to the list in README.rst.

3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/cmayes/md_utils/pull_requests and make sure that the tests pass for all supported Python versions.

12 Chapter 5. Contributing

Page 17: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

5.4 Tips

To run a subset of tests:

$ python -m unittest tests.test_md_utils

5.4. Tips 13

Page 18: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

14 Chapter 5. Contributing

Page 19: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 6

Credits

6.1 Development Lead

• Chris Mayes <[email protected]>

6.2 Contributors

• Heather Mayes <[email protected]>

15

Page 20: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

16 Chapter 6. Credits

Page 21: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 7

History

17

Page 22: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

18 Chapter 7. History

Page 23: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 8

0.6.0 (2015-11-22)

• Added lammps_dist to calculate atom pair distances as found in a LAMMPS dump file.

19

Page 24: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

20 Chapter 8. 0.6.0 (2015-11-22)

Page 25: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 9

0.5.0 (2015-11-21)

• Added press_dups to compress CSV rows that have duplicate values for a given column.

21

Page 26: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

22 Chapter 9. 0.5.0 (2015-11-21)

Page 27: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 10

0.4.2 (2015-10-24)

• Added path_bin for creating an averaged VMD file from a larger set of coordinates.

23

Page 28: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

24 Chapter 10. 0.4.2 (2015-10-24)

Page 29: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 11

0.4.1 (2015-10-10)

• Added max_loc and max_val columns to calc_pka output.

• Fixed problem with 0-start files in fes_combo.

25

Page 30: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

26 Chapter 11. 0.4.1 (2015-10-10)

Page 31: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 12

0.4.0 (2015-10-01)

• Changed wham_rad to set the zero point at the the largest CV free E, rather than the max CV

27

Page 32: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

28 Chapter 12. 0.4.0 (2015-10-01)

Page 33: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 13

0.3.0 (2015-09-07)

• Added wham_block.py

• Added wham_split.py

• Refactored common code to common and wham modules.

29

Page 34: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

30 Chapter 13. 0.3.0 (2015-09-07)

Page 35: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 14

0.2.0 (2015-09-03)

• Added wham_rad.py

31

Page 36: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

32 Chapter 14. 0.2.0 (2015-09-03)

Page 37: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 15

0.1.0 (2015-09-01)

• Renamed to md_utils

• Added fes_combo.py

33

Page 38: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

34 Chapter 15. 0.1.0 (2015-09-01)

Page 39: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 16

md_utils package

16.1 Submodules

16.2 md_utils.calc_pka module

Calculates the proton dissociation constant (PKA) for the given free energy data for a set of coordinates.

exception md_utils.calc_pka.NoMaxErrorBases: exceptions.Exception

md_utils.calc_pka.calc_pka(file_data, kbt, coord_ts=None)Calculates the proton dissociation constant (PKA) for the given free energy data.

Parameters

• file_data – The list of dicts to process.

• kbt – The experimental temperature multiplied by Boltzmann’s Constant.

Returns The PKA for the given data set or an error string if no local max is found.

md_utils.calc_pka.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

md_utils.calc_pka.parse_cmdline(argv)Returns the parsed argument list and return code. :param argv: is a list of arguments, or None forsys.argv[1:].

md_utils.calc_pka.write_result(result, src_file, overwrite=False, basedir=None)Writes the result to a file named for the given source file.

Parameters

• result – The result to write.

• src_file – The original source file name.

• overwrite – Whether to overwrite an existing file name.

• basedir – The base directory to target (uses the source file’s base directory if not speci-fied)

35

Page 40: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

16.3 md_utils.calc_split_avg module

Calculates the average and standard deviation for the given radially-corrected free energy data for a set of coordinates.

md_utils.calc_split_avg.bin_by_pattern(vals, pat=’rad_PMF.(\\d+)_\\d+’)Categorizes the given list of strings into bins where the strings have the same captured value from the givenpattern.

Parameters

• vals – The values to bin.

• pat – The pattern to use for matching. Should contain a capturing group.

Returns A dict of the values keyed by the matching captured substring.

md_utils.calc_split_avg.calc_avg_stdev(coord_bin)

md_utils.calc_split_avg.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

md_utils.calc_split_avg.parse_cmdline(argv)Returns the parsed argument list and return code. :param argv: is a list of arguments, or None forsys.argv[1:].

md_utils.calc_split_avg.write_avg_stdev(result, out_fname, overwrite=False,basedir=None)

Writes the result to a file named for the given source file.

Parameters

• result – The result to write.

• out_fname – The target out file.

• overwrite – Whether to overwrite an existing file name.

• basedir – The base directory to target (uses the source file’s base directory if not speci-fied)

16.4 md_utils.common module

Common methods for this project.

md_utils.common.allow_write(floc, overwrite=False)Returns whether to allow writing to the given location.

Parameters

• floc – The location to check.

• overwrite – Whether to allow overwriting an exisiting location.

Returns Whether to allow writing to the given location.

md_utils.common.calc_kbt(temp_k)Returns the given temperature in Kelvin multiplied by Boltzmann’s Constant.

36 Chapter 16. md_utils package

Page 41: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

Parameters temp_k – A temperature in Kelvin.

Returns The given temperature in Kelvin multiplied by Boltzmann’s Constant.

md_utils.common.chunk(seq, chunksize, process=<built-in function iter>)Yields items from an iterator in iterable chunks. From https://gist.github.com/ksamuel/1275417

Parameters

• seq – The sequence to chunk.

• chunksize – The size of the returned chunks.

• process – The function to use for creating the iterator. Useful for iterating over different

data structures. :return: Chunks of the given size from the given sequence.

md_utils.common.copytree(src, dst, symlinks=False, ignore=None)This is a copy of the standard Python shutil.copytree, but it allows for an existing destination directory.

Recursively copy a directory tree using copy2().

If exception(s) occur, an Error is raised with a list of reasons.

If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destinationtree; if it is false, the contents of the files pointed to by symbolic links are copied.

The optional ignore argument is a callable. If given, it is called with the src parameter, which is the directorybeing visited by copytree(), and names which is the list of src contents, as returned by os.listdir():

callable(src, names) -> ignored_names

Since copytree() is called recursively, the callable will be called once for each directory that is copied. It returnsa list of names relative to the src directory that should not be copied.

XXX Consider this example code rather than the ultimate tool.

Parameters

• src – The source directory.

• dst – The destination directory.

• symlinks – Whether to follow symbolic links.

• ignore – A callable for items to ignore at a given level.

md_utils.common.create_backup_filename(orig)

md_utils.common.create_out_fname(src_file, prefix, base_dir=None)Creates an outfile name for the given source file.

Parameters

• src_file – The file to process.

• prefix – The file prefix to prepend.

• base_dir – The base directory to use; defaults to src_file‘s directory

Returns The output file name.

md_utils.common.diff_lines(floc1, floc2)

md_utils.common.file_to_str(fname)Reads and returns the contents of the given file.

Parameters fname – The location of the file to read.

16.4. md_utils.common module 37

Page 42: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

Returns The contents of the given file.

Raises IOError if the file can’t be opened for reading.

md_utils.common.find_backup_filenames(orig)

md_utils.common.find_files_by_dir(tgt_dir, pat)Recursively searches the target directory tree for files matching the given pattern. The results are returned as adict with a list of found files keyed by the absolute directory name. :param tgt_dir: The target base directory.:param pat: The file pattern to search for. :return: A dict where absolute directory names are keys for lists offound file names

that match the given pattern.

md_utils.common.fmt_row_data(raw_data, fmt_str)Formats the values in the dicts in the given list of raw data using the given format string.

Parameters

• raw_data – The list of dicts to format.

• fmt_str – The format string to use when formatting.

Returns The formatted list of dicts.

md_utils.common.list_to_file(list_val, fname)Writes the list to the given file.

Parameters

• list_val – The list to write.

• fname – The location of the file to write.

md_utils.common.move_existing_file(floc)Renames an existing file using a timestamp based on the move time.

Parameters floc – The location to check.

md_utils.common.read_csv(src_file, data_conv=None, all_conv=None)Reads the given CSV (comma-separated with a first-line header row) and returns a list of dicts where each dictcontains a row’s data keyed by the header row.

Parameters

• src_file – The CSV to read.

• data_conv – A map of header keys to conversion functions. Note that values that throwa TypeError from an attempted conversion are left as strings in the result.

• all_conv – A function to apply to all values in the CSV. A specified data_conv valuetakes precedence.

Returns A list of dicts containing the file’s data.

md_utils.common.read_csv_header(src_file)Returns a list containing the values from the first row of the given CSV file or None if the file is empty.

Parameters src_file – The CSV file to read.

Returns The first row or None if empty.

md_utils.common.silent_remove(filename)Removes the target file name, catching and ignoring errors that indicate that the file does not exist.

Parameters filename – The file to remove.

38 Chapter 16. md_utils package

Page 43: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

md_utils.common.str_to_bool(s)Basic converter for Python boolean values written as a str. :param s: The value to convert. :return: The booleanvalue of the given string. :raises: ValueError if the string value cannot be converted.

md_utils.common.str_to_file(str_val, fname)Writes the string to the given file.

Parameters

• str_val – The string to write.

• fname – The location of the file to write.

md_utils.common.swarn(*objs)Writes a warning message to a target (stderr by default). :param objs: The elements of the message to write.

md_utils.common.swerr(*objs)Writes an error message to a target (stderr by default). :param objs: The elements of the message to write.

md_utils.common.write_csv(data, out_fname, fieldnames, extrasaction=’raise’)Writes the given data to the given file location.

Parameters

• data – The data to write.

• out_fname – The name of the file to write to.

• fieldnames – The sequence of field names to use for the header.

• extrasaction – What to do when there are extra keys. Acceptable values are “raise” or“ignore”.

16.5 md_utils.fes_combo module

Combines one or more FES files into a single file where each line has a timestep value unique to the combined file.Files with higher initial timestep values take precedence.

md_utils.fes_combo.combine(tgt_files)Reads in and combines target files, sorting for precedence by the largest timestep value in the first data row.Note that this function reads the entire contents of each file into memory and will therefore scale poorly for verylarge files.

Parameters tgt_files – A list of the absolute locations of the files to combine.

Returns A list of the combined lines of the target files.

md_utils.fes_combo.extract_header(tgt_file)Collects lines that don’t have a timestep and returns them.

Parameters tgt_file – The file to process.

Returns The headers for the given file.

md_utils.fes_combo.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

16.5. md_utils.fes_combo module 39

Page 44: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

md_utils.fes_combo.map_fes(tgt_file)Maps each line of the given FES output file to its timestep value. Lines that do not have a timestep for its firstelement are discarded.

Parameters tgt_file – The file location to process.

Returns A dict with each FES data line mapped to its int timestep value.

md_utils.fes_combo.parse_cmdline(argv)Returns the parsed argument list and return code. :param argv: A list of arguments, or None forsys.argv[1:].

md_utils.fes_combo.write_combo(headers, combo, combo_file)Writes the headers, then the combo, to the combo file location. :param headers: The headers to write. :paramcombo: A dict of combined file contents indexed by timestep. :param combo_file: The file location for theoutput.

16.6 md_utils.md_init module

Initializes a location for running md utilities. The contents of the “skel” subdirectory are copied into the target direc-tory. This currently includes a tpl directory.

md_utils.md_init.copy_skel(src, dest)Copies the contents of src to dest.

md_utils.md_init.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

md_utils.md_init.parse_cmdline(argv=None)Returns the parsed argument list and return code. :param argv: A list of arguments, or None forsys.argv[1:].

16.7 md_utils.wham module

Common WHAM logic.

exception md_utils.wham.TemplateNotReadableErrorBases: exceptions.Exception

md_utils.wham.fill_submit_wham(base_tpl, line_tpl, cur_step, use_part=False)Fills the base template with one or more lines from the filled line template and returns the result.

Parameters

• base_tpl – The base template to fill. Expected to have a {wham_block} element.

• line_tpl – The line template to fill. Expected to have one or more {step} elements.

• cur_step – The current step.

• use_part – Whether to add lines for each part of a split step.

Returns The results of filling the template.

md_utils.wham.read_meta(meta_file)Reads the given meta file, returning the parsed value as a dict containing:

40 Chapter 16. md_utils package

Page 45: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

•loc: A string with the original (possibly relative) location

•dir: A string with absolute path for the directory containing the meta file.

•lines: a list of four-element lists that represent each line in the meta file.

Parameters meta_file – The meta file to parse.

Returns The parsed contents of the meta file.

md_utils.wham.read_meta_rmsd(meta)Finds and parses the RMSD files described in the given parsed meta file’s contents.

Parameters meta – The result of calling read_meta with a meta file location.

Returns A dict of lists containing floats for each line in each found RMSD file keyed by the RMSDfile name (no directory info is included in the key)

md_utils.wham.read_rmsd(fname)Reads the RMSD file at the given file name.

Parameters fname – The file’s location.

Returns The values in the RMSD file.

md_utils.wham.write_rmsd(data, tgt_file)Writes the given RMSD data list into the given target location.

Parameters

• data – The list of data to write.

• tgt_file – The target file location.

16.8 md_utils.wham_block module

Block averages input data for WHAM.

md_utils.wham_block.block_average(meta_file, steps, tpl_dir=’/home/docs/checkouts/readthedocs.org/user_builds/md-utils/checkouts/latest/docs/tpl’, overwrite=False,base_dir=None)

Reads the given meta file, fetches the RMSD files in the inventory, computes the average over the given numberof cycles, and writes each computed RMSD and meta file for each cycle.

Parameters

• meta_file – The initial meta file.

• steps – The number of averaging steps to perform.

• overwrite – Whether to overwrite existing files.

• base_dir – The base directory to write to (defaults to the meta file’s dir)

md_utils.wham_block.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

16.8. md_utils.wham_block module 41

Page 46: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

md_utils.wham_block.pair_avg(vals)Returns a list of the average between pairs of numbers in the input list. If there is an odd final input value, it isdropped.

Parameters vals – A list of floats to pair and average.

Returns The average of adjacent pairs in the given input list.

md_utils.wham_block.parse_cmdline(argv=None)Returns the parsed argument list and return code. :param argv: A list of arguments, or None forsys.argv[1:].

md_utils.wham_block.rmsd_avg(rmsd, avg_func)Computes the average for the given RMSD value list using the given averaging function.

Parameters

• rmsd – The data to process keyed by file name.

• avg_func – The function to apply to the data.

Returns The averaged data keyed by file name.

md_utils.wham_block.write_avg_rmsd(tgt_dir, rmsd, overwrite=False)Writes out all of the described RMSD files into the given target directory.

Parameters

• tgt_dir – The data where the files will go.

• rmsd – A dict of an array of floats keyed by file name.

• overwrite – Whether to overwrite existing files.

md_utils.wham_block.write_meta(tgt_dir, meta, step, overwrite=False)Writes out the meta file using the original meta data structure as a beginning.

Parameters

• tgt_dir – The target directory for the meta file.

• meta – The parsed data from the original meta file.

• step – The step number being processed.

• overwrite – Whether to overwrite an existing meta file.

md_utils.wham_block.write_submit(tgt_dir, sub_tpl_base, sub_tpl_line, step, overwrite=False)Uses the given templates and step number to write a submit script to the given target file location.

Parameters

• sub_tpl_base – The base template.

• sub_tpl_line – The line template.

• step – The step number.

• tgt_dir – The target directory.

• overwrite – Whether to allow overwrites.

16.9 md_utils.wham_rad module

Creates a radial correction value for each line of the target file(s).

42 Chapter 16. md_utils package

Page 47: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

md_utils.wham_rad.calc_corr(coord, freng, kbt)Calculates the radial correction for the given free energy.

Parameters

• coord – The coordinates under consideration.

• freng – The free energy to correct.

• kbt – The experimental temperature in Kelvin multiplied by Boltzmann’s Constant.

Returns The radially corrected free energy. If there is an error, return freng because the most likelyerror is that freng is inf; in that case, just return freng, which is handled later.

md_utils.wham_rad.calc_rad(src_file, kbt)Applies radial correction to the free energy values in the given source file, returning a list of dicts containing thecorrected contents of the given file.

Parameters

• src_file – The file with the data to correct.

• kbt – The experimental temperature in Kelvin multiplied by Boltzmann’s Constant.

Returns The corrected contents of the file as a list of dicts.

md_utils.wham_rad.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

md_utils.wham_rad.parse_cmdline(argv)Returns the parsed argument list and return code. :param argv: is a list of arguments, or None forsys.argv[1:].

md_utils.wham_rad.to_zero_point(corr_res)# Sets the highest free energy value as zero for the given data set. Sets the free energy value at the furtherscoordinate as zero for the given data set.

Parameters corr_res – The data set to orient.

Returns The data set reoriented relative to the highest free energy value.

16.10 md_utils.wham_split module

Splits WHAM files and directories into 2-n partitions based on the number of steps specified.

md_utils.wham_split.main(argv=None)Runs the main program.

Parameters argv – The command line arguments.

Returns The return code for the program’s termination.

md_utils.wham_split.parse_cmdline(argv=None)Returns the parsed argument list and return code. :param argv: A list of arguments, or None forsys.argv[1:].

md_utils.wham_split.read_tpl(tpl_loc)Attempts to read the given template location and throws A TemplateNotReadableError if it can’t read the givenlocation.

16.10. md_utils.wham_split module 43

Page 48: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

Parameters tpl_loc – The template location to read.

Raises TemplateNotReadableError If there is an IOError reading the location.

md_utils.wham_split.rmsd_split(meta_file, steps, tpl_dir=’/home/docs/checkouts/readthedocs.org/user_builds/md-utils/checkouts/latest/docs/tpl’, overwrite=False,base_dir=None)

Reads the given meta file, fetches the RMSD files in the inventory, and creates a succession of directories thatsplit the original RMSD files into a larger number of chunks for each step such that step 1 will create a split of2 in 01_01 and 01_02, etc.

Parameters

• meta_file – The initial meta file.

• steps – The number of averaging steps to perform.

• tpl_dir – The directory that contains the submit templates.

• overwrite – Whether to overwrite existing files.

• base_dir – The base directory to write to (defaults to the meta file’s dir)

md_utils.wham_split.write_meta(tgt_dir, meta, step, overwrite=False)Writes out the meta file using the original meta data structure as a beginning.

Parameters

• tgt_dir – The target directory for the meta file.

• meta – The parsed data from the original meta file.

• step – The step number being processed.

• overwrite – Whether to overwrite an existing meta file.

md_utils.wham_split.write_submit(tgt_dir, sub_tpl_base, sub_tpl_line, step, overwrite=False)Uses the given templates and step number to write a submit script to the given target file location.

Parameters

• sub_tpl_base – The base template.

• sub_tpl_line – The line template.

• step – The step number.

• tgt_dir – The target directory.

• overwrite – Whether to allow overwrites.

16.11 Module contents

Molecular dynamics utilities.

44 Chapter 16. md_utils package

Page 49: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

CHAPTER 17

Indices and tables

• genindex

• modindex

• search

45

Page 50: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

46 Chapter 17. Indices and tables

Page 51: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

Python Module Index

mmd_utils, 44md_utils.calc_pka, 35md_utils.calc_split_avg, 36md_utils.common, 36md_utils.fes_combo, 39md_utils.md_init, 40md_utils.wham, 40md_utils.wham_block, 41md_utils.wham_rad, 42md_utils.wham_split, 43

47

Page 52: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

48 Python Module Index

Page 53: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

Index

Aallow_write() (in module md_utils.common), 36

Bbin_by_pattern() (in module md_utils.calc_split_avg), 36block_average() (in module md_utils.wham_block), 41

Ccalc_avg_stdev() (in module md_utils.calc_split_avg), 36calc_corr() (in module md_utils.wham_rad), 42calc_kbt() (in module md_utils.common), 36calc_pka() (in module md_utils.calc_pka), 9, 35calc_rad() (in module md_utils.wham_rad), 43chunk() (in module md_utils.common), 37combine() (in module md_utils.fes_combo), 39copy_skel() (in module md_utils.md_init), 40copytree() (in module md_utils.common), 37create_backup_filename() (in module md_utils.common),

37create_out_fname() (in module md_utils.common), 37

Ddiff_lines() (in module md_utils.common), 37

Eextract_header() (in module md_utils.fes_combo), 39

Ffile_to_str() (in module md_utils.common), 37fill_submit_wham() (in module md_utils.wham), 40find_backup_filenames() (in module md_utils.common),

38find_files_by_dir() (in module md_utils.common), 38fmt_row_data() (in module md_utils.common), 38

Llist_to_file() (in module md_utils.common), 38

Mmain() (in module md_utils.calc_pka), 9, 35

main() (in module md_utils.calc_split_avg), 36main() (in module md_utils.fes_combo), 39main() (in module md_utils.md_init), 40main() (in module md_utils.wham_block), 41main() (in module md_utils.wham_rad), 43main() (in module md_utils.wham_split), 43map_fes() (in module md_utils.fes_combo), 39md_utils (module), 9, 44md_utils.calc_pka (module), 9, 35md_utils.calc_split_avg (module), 36md_utils.common (module), 36md_utils.fes_combo (module), 39md_utils.md_init (module), 40md_utils.wham (module), 40md_utils.wham_block (module), 41md_utils.wham_rad (module), 42md_utils.wham_split (module), 43move_existing_file() (in module md_utils.common), 38

NNoMaxError, 35

Ppair_avg() (in module md_utils.wham_block), 41parse_cmdline() (in module md_utils.calc_pka), 9, 35parse_cmdline() (in module md_utils.calc_split_avg), 36parse_cmdline() (in module md_utils.fes_combo), 40parse_cmdline() (in module md_utils.md_init), 40parse_cmdline() (in module md_utils.wham_block), 42parse_cmdline() (in module md_utils.wham_rad), 43parse_cmdline() (in module md_utils.wham_split), 43

Rread_csv() (in module md_utils.common), 38read_csv_header() (in module md_utils.common), 38read_meta() (in module md_utils.wham), 40read_meta_rmsd() (in module md_utils.wham), 41read_rmsd() (in module md_utils.wham), 41read_tpl() (in module md_utils.wham_split), 43rmsd_avg() (in module md_utils.wham_block), 42

49

Page 54: MD Utilities Documentation · CHAPTER 4 Documentation for the Code Molecular dynamics utilities. 4.1calc_pka This is something I want to say that is not in the docstring. Calculates

MD Utilities Documentation, Release 0.6.0

rmsd_split() (in module md_utils.wham_split), 44

Ssilent_remove() (in module md_utils.common), 38str_to_bool() (in module md_utils.common), 38str_to_file() (in module md_utils.common), 39swarn() (in module md_utils.common), 39swerr() (in module md_utils.common), 39

TTemplateNotReadableError, 40to_zero_point() (in module md_utils.wham_rad), 43

Wwrite_avg_rmsd() (in module md_utils.wham_block), 42write_avg_stdev() (in module md_utils.calc_split_avg),

36write_combo() (in module md_utils.fes_combo), 40write_csv() (in module md_utils.common), 39write_meta() (in module md_utils.wham_block), 42write_meta() (in module md_utils.wham_split), 44write_result() (in module md_utils.calc_pka), 9, 35write_rmsd() (in module md_utils.wham), 41write_submit() (in module md_utils.wham_block), 42write_submit() (in module md_utils.wham_split), 44

50 Index