Skip to content

Commit

Permalink
Merge pull request #71 from DrDomenicoMarson/add-amber-mbar-none-non-…
Browse files Browse the repository at this point in the history
…finished

Added the capability of loading a single test case for AMBER
  • Loading branch information
xiki-tempula authored Oct 16, 2022
2 parents 57458ef + f711a06 commit 6407137
Show file tree
Hide file tree
Showing 56 changed files with 130 additions and 315,930 deletions.
10 changes: 9 additions & 1 deletion docs/amber.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ They can be accessed using the following accessor functions:
load_bace_example
load_simplesolvated
load_invalidfiles
load_testfiles


.. _amber_bace_improper:
Expand All @@ -44,6 +45,13 @@ They can be accessed using the following accessor functions:

.. _amber_invalidfiles:

.. include:: ../src/alchemtest/amber/invalidfiles/descr.rst
.. include:: ../src/alchemtest/amber/testfiles/descr_invalid.rst

.. autofunction:: alchemtest.amber.load_invalidfiles


.. _load_testfiles:

.. include:: ../src/alchemtest/amber/testfiles/descr.rst

.. autofunction:: alchemtest.amber.load_testfiles
1 change: 1 addition & 0 deletions src/alchemtest/amber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from .access import load_bace_example
from .access import load_simplesolvated
from .access import load_invalidfiles
from .access import load_testfiles
90 changes: 68 additions & 22 deletions src/alchemtest/amber/access.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Accessors for Amber TI datasets.
"""

from os.path import dirname, join
from glob import glob

import warnings
from pathlib import Path
from .. import Bunch


Expand All @@ -20,10 +18,10 @@ def load_bace_improper():
- 'data' : the data files for improper solvated vdw alchemical leg
"""
module_path = dirname(__file__)
data = {'vdw': glob(join(module_path, 'bace_improper/solvated/vdw/*/ti-*.out.bz2'))}
module_path = Path(__file__).parent
data = {'vdw': list(map(str, module_path.glob('bace_improper/solvated/vdw/*/ti-*.out.bz2')))}

with open(join(module_path, 'bace_improper', 'descr.rst')) as rst_file:
with open(module_path / 'bace_improper' / 'descr.rst') as rst_file:
fdescr = rst_file.read()

return Bunch(data=data,
Expand All @@ -41,20 +39,20 @@ def load_bace_example():
- 'data' : the data files by system and alchemical leg
"""
module_path = dirname(__file__)
module_path = Path(__file__).parent
data = {'complex':
{'decharge': glob(join(module_path, 'bace_CAT-13d~CAT-17a/complex/decharge/*/ti-*.out.bz2')),
'recharge': glob(join(module_path, 'bace_CAT-13d~CAT-17a/complex/recharge/*/ti-*.out.bz2')),
'vdw': glob(join(module_path, 'bace_CAT-13d~CAT-17a/complex/vdw/*/ti-*.out.bz2'))
{'decharge': list(map(str, module_path.glob('bace_CAT-13d~CAT-17a/complex/decharge/*/ti-*.out.bz2'))),
'recharge': list(map(str, module_path.glob('bace_CAT-13d~CAT-17a/complex/recharge/*/ti-*.out.bz2'))),
'vdw': list(map(str, module_path.glob('bace_CAT-13d~CAT-17a/complex/vdw/*/ti-*.out.bz2')))
},
'solvated':
{'decharge': glob(join(module_path, 'bace_CAT-13d~CAT-17a/solvated/decharge/*/ti-*.out.bz2')),
'recharge': glob(join(module_path, 'bace_CAT-13d~CAT-17a/solvated/recharge/*/ti-*.out.bz2')),
'vdw': glob(join(module_path, 'bace_CAT-13d~CAT-17a/solvated/vdw/*/ti-*.out.bz2'))
{'decharge': list(map(str, module_path.glob('bace_CAT-13d~CAT-17a/solvated/decharge/*/ti-*.out.bz2'))),
'recharge': list(map(str, module_path.glob('bace_CAT-13d~CAT-17a/solvated/recharge/*/ti-*.out.bz2'))),
'vdw': list(map(str, module_path.glob('bace_CAT-13d~CAT-17a/solvated/vdw/*/ti-*.out.bz2')))
}
}

with open(join(module_path, 'bace_CAT-13d~CAT-17a', 'descr.rst')) as rst_file:
with open(module_path / 'bace_CAT-13d~CAT-17a' / 'descr.rst') as rst_file:
fdescr = rst_file.read()

return Bunch(data=data,
Expand All @@ -74,11 +72,11 @@ def load_simplesolvated():
"""

module_path = dirname(__file__)
data = {'charge': glob(join(module_path, 'simplesolvated/charge/*/ti-*.out')),
'vdw': glob(join(module_path, 'simplesolvated/vdw/*/ti-*.out'))}
module_path = Path(__file__).parent
data = {'charge': list(map(str, module_path.glob('simplesolvated/charge/*/ti-*.tar.bz2'))),
'vdw': list(map(str, module_path.glob('simplesolvated/vdw/*/ti-*.tar.bz2')))}

with open(join(module_path, 'simplesolvated', 'descr.rst')) as rst_file:
with open(module_path / 'simplesolvated' / 'descr.rst') as rst_file:
fdescr = rst_file.read()

return Bunch(data=data,
Expand All @@ -96,12 +94,60 @@ def load_invalidfiles():
- 'data' : the example of invalid data files
- 'DESCR': the full description of the dataset
.. deprecated:: 0.7
use :func:`load_testfiles` instead
"""

module_path = dirname(__file__)
data = [glob(join(module_path, 'invalidfiles/*.out.bz2'))]
warnings.warn(
"load_invalidfiles() was deprecated in 0.7.0 and will be removed in the following release."
" Use load_testfiles() instead",
DeprecationWarning)
module_path = Path(__file__).parent
data = [[
module_path / 'testfiles' / 'no_useful_data.out.bz2',
module_path / 'testfiles' / 'no_control_data.out.bz2',
module_path / 'testfiles' / 'no_temp0_set.out.bz2',
module_path / 'testfiles' / 'no_free_energy_info.out.bz2',
module_path / 'testfiles' / 'no_atomic_section.out.bz2',
module_path / 'testfiles' / 'no_results_section.out.bz2']]

with open(module_path / 'testfiles' / 'descr_invalid.rst') as rst_file:
fdescr = rst_file.read()

return Bunch(data=data,
DESCR=fdescr)


def load_testfiles():
"""Load incomplete or wrongly formatted files to be used to test the AMBER parsers.
Returns
-------
data : Bunch
Dictionary-like object, the interesting attributes are:
- 'data' : the data files
- 'DESCR': the full description of all the files
"""

with open(join(module_path, 'invalidfiles', 'descr.rst')) as rst_file:
testfiles_path = Path(__file__).parent / 'testfiles'

data = {
"not_finished_run": [testfiles_path / "not_finished_run.out.bz2"],
"none_in_mbar": [testfiles_path / "none_in_mbar.out.bz2"],
"no_useful_data": [testfiles_path / "no_useful_data.out.bz2"],
"no_temp0_set": [testfiles_path / "no_temp0_set.out.bz2"],
"no_results_section": [testfiles_path / "no_results_section.out.bz2"],
"no_free_energy_info": [testfiles_path / "no_free_energy_info.out.bz2"],
"no_dHdl_data_points": [testfiles_path / "no_dHdl_data_points.out.bz2"],
"no_control_data": [testfiles_path / "no_control_data.out.bz2"],
"no_atomic_section": [testfiles_path / "no_atomic_section.out.bz2"],
}

with open(testfiles_path / 'descr.rst') as rst_file:
fdescr = rst_file.read()

return Bunch(data=data,
Expand Down
14 changes: 0 additions & 14 deletions src/alchemtest/amber/invalidfiles/descr.rst

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 6407137

Please sign in to comment.