AMBER dVdl convert to pandas error
See original GitHub issueHello all,
I’m having trouble forming my pandas data frame using the Amber parser in alchemlyb. I’m still new to python programming and I’m not sure where I might have done wrong in the python script. I really appreciate guidance on handling this error. I have also attached the code I’m using below.
Thanks.
from pathlib import Path
import pandas as pd
from alchemtest import Bunch
import alchemlyb
from alchemlyb.parsing import amber
from alchemlyb.estimators import TI
from alchemlyb.parsing.amber import extract_dHdl
#extract data
def load_ligandsolvated():
"""Load the Amber solvated dataset.
Returns
-------
data : Bunch
Dictionary-like object, the interesting attributes are:
- 'data' : the data files by alchemical leg
"""
module_path = Path(__file__).parent
data = {'charge': list(map(str, module_path.glob('decharge/*/md7.out'))),
'vdw': list(map(str, module_path.glob('vdw_bonded/*/md7.out')))}
return Bunch(data=data)
dataset = load_ligandsolvated()
#print(dataset)
dHdl_coul = alchemlyb.concat([amber.extract_dHdl(filename, T=300)
for filename in dataset['data']['charge']])
Traceback (most recent call last): File “/home/srg/senal/Documents/Project-GQuad/MD/130mM/1-2-1/1-2-1Intercalated_Bottom/ReRun-2/TI/cuda/TI-3/ligands/ti_est.py”, line 37, in <module> dHdl_coul = alchemlyb.concat([amber.extract_dHdl(filename, T=300) File “/home/srg/senal/Documents/Project-GQuad/MD/130mM/1-2-1/1-2-1Intercalated_Bottom/ReRun-2/TI/cuda/TI-3/ligands/ti_est.py”, line 37, in <listcomp> dHdl_coul = alchemlyb.concat([amber.extract_dHdl(filename, T=300) File “/home/srg/senal/.local/lib/python3.9/site-packages/alchemlyb/parsing/init.py”, line 11, in wrapper dataframe = func(outfile, T, *args, **kwargs) File “/home/srg/senal/.local/lib/python3.9/site-packages/alchemlyb/parsing/amber.py”, line 390, in extract_dHdl df = convert_to_pandas(file_datum) File “/home/srg/senal/.local/lib/python3.9/site-packages/alchemlyb/parsing/amber.py”, line 36, in convert_to_pandas frame_time = file_datum.t0 + (frame_index + 1) * file_datum.dt * 1000 TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘float’
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (6 by maintainers)
Hi, I’ll have a look at it right now! Just a quick comment about the “two TI regions specified at the beginning of the simulation”.
It’s true indeed that amber saves the two TI regions (and it did so also before amber18, as far as I remember), but if you look at the file, especially at the end of the file, where the averages over the last N time-steps are reported, DV/DL values (the only value read by alchemlyb) and their RMS fluctuations are perfectly equal between TI region 1 and 2.
If you search in the AMBER mailing list you can find some better explanation on why values are reported like that, but I can’t remember where precisely.
PS: from your output file it seems you are printing values in the output file every 1 ps, and not 10 ps as you previously stated, as you have
dt=1 fs
and print everyntpr=1000 time-steps
(it’s not a problem for us, I just wanted to point it out just so you can be sure of what you are doing).The PR is merged to the master. Doing
pip install git+ssh://git@github.com:alchemistry/alchemlyb.git
should give you the alchemlyb with the fix. Please feel free to reopen this issue if there are other problems.