Skip to main content

Read and manipulate Gromacs energy files to pandas Dataframes

Project description

Github Actions Build Status Coverage Status

This repository hosts the source files for both the Pyedr and Panedr packages.

pyedr and panedr are compatible with Python 3.6 and greater.

Pyedr

Pyedr provides a means of reading a Gromacs EDR binary XDR file and return its contents as a dictionary of numpy arrays. Pyedr exposes the following functions:

  • edr_to_dict: returns a dictionary of NumPy arrays keyed by the energy type from a given path to an EDR file.

  • read_edr: parses an EDR file and returns the energy terms in a nested list

  • get_unit_dictionary: Returns a dictionary that holds the units of each energy term found in the EDR file.

Panedr

Panedr uses the Pyedr library to read a Gromacs EDR binary energy XDR file and returns its contents as a pandas dataframe. Panedr exposes the following functions:

  • edr_to_df: which gets the path to an EDR file and returns a pandas DataFrame.

  • get_unit_dictionary: Returns a dictionary that holds the units of each energy term found in the EDR file.

Example

Using pyedr:

import pyedr

# Read the EDR file
path = 'ener.edr'
dic = pyedr.edr_to_dict(path)

# The `verbose` optional parameter can be set to True to display the
# progress on stderr
dic = pyedr.edr_to_dict(path, verbose=True)

# Get the average pressure after the first 10 ns
pressure_avg = dic['Pressure'][dic['Time'] > 10000].mean()

# Get the units of the EDR entries
unit_dict = pyedr.get_unit_dictionary(path)
unit_dict["Temperature"]  # returns "K"

Using panedr:

import panedr

# Read the EDR file
path = 'ener.edr'
df = panedr.edr_to_df(path)

# The `verbose` optional parameter can be set to True to display the
# progress on stderr
df = panedr.edr_to_df(path, verbose=True)

# Get the average pressure after the first 10 ns
pressure_avg = df['Pressure'][df['Time'] > 10000].mean()

# Get the units of the EDR entries
unit_dict = panedr.get_unit_dictionary(path)
unit_dict["Temperature"]  # returns "K"

Install

You can install pyedr and panedr using pip:

pip install pyedr

# installing panedr automatically installs pyedr
pip install panedr

If you are using conda and conda-forge, you can install with:

conda install -c conda-forge pyedr

# install panedr automatically installs pyedr
conda install -c conda-forge panedr

Tests

The pyedr and panedr repositories contains a series of tests. If you downloaded or cloned the code from the repository, you can run the tests. To do so, install pytest, and, in the directory of the panedr source code, run:

For pyedr:

pytest -v pyedr/pyedr/tests

For panedr:

pytest -v panedr/panedr/tests

License

Pyedr and Panedr translate part of the source code of Gromacs into Python. Therefore, Panedr is distributed under the same GNU Lesser General Public License version 2.1 as Gromacs. See the license for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panedr-0.7.2.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

panedr-0.7.2-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file panedr-0.7.2.tar.gz.

File metadata

  • Download URL: panedr-0.7.2.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for panedr-0.7.2.tar.gz
Algorithm Hash digest
SHA256 2181009a962dc35745348d1146608c64fb1ba3ef5ae74043416fef739d1409e4
MD5 c34d02c763352688eaeadc490cc26bb0
BLAKE2b-256 b6328323dde3376694fa9d19aaff0f0d0ef78ce7e82f85d3d039b070e4500738

See more details on using hashes here.

Provenance

File details

Details for the file panedr-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: panedr-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for panedr-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe8ba7071eae60db38b1d6307866baaf4f8ccd1b18d38708659b05ff078fe89b
MD5 adba4564c5c0f0bc104ee3c6a15e321d
BLAKE2b-256 c1e93f7a09dc2ceb866e143c47f32486913eded2013525a0e3c2798a7aaa136c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page