读取Gromacs EDR文件并将它们公开为pandas Dataframes
项目描述
此存储库托管了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 安装 pyedr 和 panedr。
pip install pyedr
# installing panedr automatically installs pyedr
pip install panedr
如果您使用 conda 和 conda-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 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 50ecac36810d12db77903048b4972a234b6e3b2c122ffa2a158eba0ff69effc4 |
|
MD5 | cc6ba7eb934d0a4dfee3c16a9fa647ed |
|
BLAKE2b-256 | 8ef9af3e6f5627a9c92f5577eda9e670992e35806b31155b4b371ee44b249436 |
panedr-0.8.0-py3-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e988c60ae02d9212692eaa03554d0c8c5042fcff7173082f0afa685117797634 |
|
MD5 | a46fdb26680843abb8c8480bb78ce8f8 |
|
BLAKE2b-256 | 638d9ecc9ccd64365c75be17ca7fe15234359c19f97220a29df68acc07e6c9dc |