跳转到主要内容

读取Gromacs EDR文件并将它们公开为pandas Dataframes

项目描述

Github Actions Build Status Coverage Status

此存储库托管了Pyedr和Panedr软件包的源代码。

pyedr和panedr兼容Python 3.6及更高版本。

Pyedr

Pyedr提供了一种读取Gromacs EDR二进制XDR文件并将其内容作为numpy数组字典返回的方法。Pyedr公开以下函数

  • edr_to_dict:从给定的EDR文件路径返回按能量类型键控的NumPy数组字典。

  • read_edr:解析EDR文件并返回嵌套列表中的能量项

  • get_unit_dictionary:返回一个字典,其中包含在EDR文件中找到的每个能量项的单位。

Panedr

PaneDr 使用 Pyedr 库读取 Gromacs EDR 二进制能量 XDR 文件,并将其内容以 pandas DataFrame 的形式返回。PaneDr 提供以下功能:

  • edr_to_df:获取 EDR 文件的路径,并返回一个 pandas DataFrame。

  • get_unit_dictionary:返回一个字典,其中包含在EDR文件中找到的每个能量项的单位。

示例

使用 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"

使用 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"

安装

您可以使用 pip 安装 pyedrpanedr

pip install pyedr

# installing panedr automatically installs pyedr
pip install panedr

如果您使用 condaconda-forge,可以使用以下命令安装:

conda install -c conda-forge pyedr

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

测试

pyedr 和 panedr 存储库包含一系列测试。如果您从存储库下载或克隆了代码,可以运行测试。要这样做,请安装 pytest,并在 panedr 源代码目录中运行:

对于 pyedr

pytest -v pyedr/pyedr/tests

对于 panedr

pytest -v panedr/panedr/tests

许可

Pyedr 和 Panedr 将 Gromacs 的一部分源代码转换为 Python。因此,PaneDr 根据 Gromacs 的相同 GNU Lesser General Public License 2.1 许可证进行分发。有关详细信息,请参阅 许可证

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

panedr-0.8.0.tar.gz (17.0 kB 查看哈希)

上传时间

构建分发

panedr-0.8.0-py3-none-any.whl (16.1 kB 查看哈希)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面