From d49eb11c8f11ea73afd128a8ef947ff207590659 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:56:07 +0200 Subject: [PATCH 01/11] Update test_bat.py Added clients --- testsuite/MDAnalysisTests/analysis/test_bat.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_bat.py b/testsuite/MDAnalysisTests/analysis/test_bat.py index c80353baff..5fb2603df6 100644 --- a/testsuite/MDAnalysisTests/analysis/test_bat.py +++ b/testsuite/MDAnalysisTests/analysis/test_bat.py @@ -41,16 +41,16 @@ def selected_residues(self): return ag @pytest.fixture() - def bat(self, selected_residues): + def bat(self, selected_residues, client_BAT): R = BAT(selected_residues) - R.run() + R.run(**client_BAT) return R.results.bat @pytest.fixture - def bat_npz(self, tmpdir, selected_residues): + def bat_npz(self, tmpdir, selected_residues, client_BAT): filename = str(tmpdir / 'test_bat_IO.npy') R = BAT(selected_residues) - R.run() + R.run(**client_BAT) R.save(filename) return filename @@ -73,8 +73,8 @@ def test_bat_coordinates(self, bat): atol=1.5e-5, err_msg="error: BAT coordinates should match test values") - def test_bat_coordinates_single_frame(self, selected_residues): - bat = BAT(selected_residues).run(start=1, stop=2).results.bat + def test_bat_coordinates_single_frame(self, selected_residues, client_BAT): + bat = BAT(selected_residues).run(start=1, stop=2, **client_BAT).results.bat test_bat = [np.load(BATArray)[1]] assert_allclose( bat, From 387104b171abf20214a1ef47680b66289fe839dd Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:56:57 +0200 Subject: [PATCH 02/11] Update conftest.py added bat to conftest.py --- testsuite/MDAnalysisTests/analysis/conftest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testsuite/MDAnalysisTests/analysis/conftest.py b/testsuite/MDAnalysisTests/analysis/conftest.py index 55bae7e6bd..bb3979a638 100644 --- a/testsuite/MDAnalysisTests/analysis/conftest.py +++ b/testsuite/MDAnalysisTests/analysis/conftest.py @@ -7,6 +7,7 @@ OldAPIAnalysis, ) from MDAnalysis.analysis.rms import RMSD, RMSF +from MDAnalysis.analysis.bat import BAT from MDAnalysis.lib.util import is_installed @@ -87,3 +88,7 @@ def client_RMSD(request): @pytest.fixture(scope='module', params=params_for_cls(RMSF)) def client_RMSF(request): return request.param + +@pytest.fixture(scope='module', params=params_for_cls(BAT)) +def client_BAT(request): + return request.param From 7108fae3bcd016145c4353e8df61107a5ffeeeca Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:59:04 +0200 Subject: [PATCH 03/11] Update bat.py Added parallelization to bat --- package/MDAnalysis/analysis/bat.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index 0c3e15a32e..68ec5fda47 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -164,7 +164,7 @@ class to calculate dihedral angles for a given set of atoms or residues import copy import MDAnalysis as mda -from .base import AnalysisBase +from .base import AnalysisBase, ResultsGroup from MDAnalysis.lib.distances import calc_bonds, calc_angles, calc_dihedrals from MDAnalysis.lib.mdamath import make_whole @@ -257,6 +257,13 @@ class BAT(AnalysisBase): @due.dcite(Doi("10.1002/jcc.26036"), description="Bond-Angle-Torsions Coordinate Transformation", path="MDAnalysis.analysis.bat.BAT") + + _analysis_algorithm_is_parallelizable = True + + @classmethod + def get_supported_backends(cls): + return ('serial', 'multiprocessing', 'dask',) + def __init__(self, ag, initial_atom=None, filename=None, **kwargs): r"""Parameters ---------- @@ -558,3 +565,6 @@ def Cartesian(self, bat_frame): def atoms(self): """The atomgroup for which BAT are computed (read-only property)""" return self._ag + + def _get_aggregator(self): + return ResultsGroup(lookup={'bat': ResultsGroup.ndarray_vstack}) From 725ff117d15a106614d5666f9adf481641a1998a Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:05:07 +0200 Subject: [PATCH 04/11] Update bat.py adjusted --- package/MDAnalysis/analysis/bat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index 68ec5fda47..9ea4b75c31 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -262,7 +262,11 @@ class BAT(AnalysisBase): @classmethod def get_supported_backends(cls): - return ('serial', 'multiprocessing', 'dask',) + return ( + "serial", + "multiprocessing", + "dask", + ) def __init__(self, ag, initial_atom=None, filename=None, **kwargs): r"""Parameters From 739da18d2b52c95b315ef8c781d198e26d20d274 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:05:55 +0200 Subject: [PATCH 05/11] Update conftest.py --- testsuite/MDAnalysisTests/analysis/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/MDAnalysisTests/analysis/conftest.py b/testsuite/MDAnalysisTests/analysis/conftest.py index bb3979a638..74a9d676d8 100644 --- a/testsuite/MDAnalysisTests/analysis/conftest.py +++ b/testsuite/MDAnalysisTests/analysis/conftest.py @@ -89,6 +89,7 @@ def client_RMSD(request): def client_RMSF(request): return request.param + @pytest.fixture(scope='module', params=params_for_cls(BAT)) def client_BAT(request): return request.param From d7a15f787f9f263795c6a591b710d0d5df3564ee Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:13:13 +0200 Subject: [PATCH 06/11] Update CHANGELOG Updated Changelog --- package/CHANGELOG | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index ede4ca29d8..14539d9bbf 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -17,7 +17,8 @@ The rules for this file: ??/??/?? IAlibay, HeetVekariya, marinegor, lilyminium, RMeli, ljwoods2, aditya292002, pstaerk, PicoCentauri, BFedder, tyler.je.reddy, SampurnaM, leonwehrhan, kainszs, orionarcher, - yuxuanzhuang, PythonFZ, laksh-krishna-sharma, orbeckst + yuxuanzhuang, PythonFZ, laksh-krishna-sharma, orbeckst, + talagayev * 2.8.0 @@ -56,6 +57,7 @@ Enhancements * Introduce parallelization API to `AnalysisBase` and to `analysis.rms.RMSD` class (Issue #4158, PR #4304) * explicitly mark `analysis.pca.PCA` as not parallelizable (Issue #4680) + * enables parallelization for analysis.bat.BAT (Issue #4663) * Improve error message for `AtomGroup.unwrap()` when bonds are not present.(Issue #4436, PR #4642) * Add `analysis.DSSP` module for protein secondary structure assignment, based on [pydssp](https://github.com/ShintaroMinami/PyDSSP) * Added a tqdm progress bar for `MDAnalysis.analysis.pca.PCA.transform()` From 91cf4757779fc36043f9cb2de277115b98e65d7e Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:29:07 +0200 Subject: [PATCH 07/11] Update bat.py --- package/MDAnalysis/analysis/bat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index 9ea4b75c31..e0d56b2b62 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -254,12 +254,12 @@ class BAT(AnalysisBase): the group of atoms and all frame in the trajectory belonging to `ag`. """ + _analysis_algorithm_is_parallelizable = True + @due.dcite(Doi("10.1002/jcc.26036"), description="Bond-Angle-Torsions Coordinate Transformation", path="MDAnalysis.analysis.bat.BAT") - _analysis_algorithm_is_parallelizable = True - @classmethod def get_supported_backends(cls): return ( From 759434396ee99f76b19b57928244020a9a9fd5a6 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:44:57 +0200 Subject: [PATCH 08/11] Update bat.py movement to lines --- package/MDAnalysis/analysis/bat.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index e0d56b2b62..b9052f86b4 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -256,10 +256,11 @@ class BAT(AnalysisBase): """ _analysis_algorithm_is_parallelizable = True - @due.dcite(Doi("10.1002/jcc.26036"), - description="Bond-Angle-Torsions Coordinate Transformation", - path="MDAnalysis.analysis.bat.BAT") - + @due.dcite( + Doi("10.1002/jcc.26036"), + description="Bond-Angle-Torsions Coordinate Transformation", + path="MDAnalysis.analysis.bat.BAT", + ) @classmethod def get_supported_backends(cls): return ( @@ -267,7 +268,7 @@ def get_supported_backends(cls): "multiprocessing", "dask", ) - + def __init__(self, ag, initial_atom=None, filename=None, **kwargs): r"""Parameters ---------- From 2200c5982a3dc42b774ad645ec843edd3dc6ba18 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:11:16 +0200 Subject: [PATCH 09/11] Update bat.py --- package/MDAnalysis/analysis/bat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index b9052f86b4..31dad3d981 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -261,6 +261,7 @@ class BAT(AnalysisBase): description="Bond-Angle-Torsions Coordinate Transformation", path="MDAnalysis.analysis.bat.BAT", ) + @classmethod def get_supported_backends(cls): return ( From 0b58c726c8c012f2918d40fc28ce2713999df2dc Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:35:17 +0200 Subject: [PATCH 10/11] Update bat.py trying to fix class static error --- package/MDAnalysis/analysis/bat.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index 31dad3d981..4f0305e037 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -255,13 +255,7 @@ class BAT(AnalysisBase): """ _analysis_algorithm_is_parallelizable = True - - @due.dcite( - Doi("10.1002/jcc.26036"), - description="Bond-Angle-Torsions Coordinate Transformation", - path="MDAnalysis.analysis.bat.BAT", - ) - + @classmethod def get_supported_backends(cls): return ( @@ -269,7 +263,13 @@ def get_supported_backends(cls): "multiprocessing", "dask", ) - + + @due.dcite( + Doi("10.1002/jcc.26036"), + description="Bond-Angle-Torsions Coordinate Transformation", + path="MDAnalysis.analysis.bat.BAT", + ) + def __init__(self, ag, initial_atom=None, filename=None, **kwargs): r"""Parameters ---------- From e917da175ea1618827d7cae16b2a5e8734d3c12e Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:31:04 +0200 Subject: [PATCH 11/11] Update bat.py Addition of versionchanged --- package/MDAnalysis/analysis/bat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/MDAnalysis/analysis/bat.py b/package/MDAnalysis/analysis/bat.py index 4f0305e037..5186cb6c88 100644 --- a/package/MDAnalysis/analysis/bat.py +++ b/package/MDAnalysis/analysis/bat.py @@ -253,6 +253,11 @@ class BAT(AnalysisBase): Bond-Angle-Torsions (BAT) internal coordinates will be computed for the group of atoms and all frame in the trajectory belonging to `ag`. + .. versionchanged:: 2.8.0 + Enabled **parallel execution** with the ``multiprocessing`` and ``dask`` + backends; use the new method :meth:`get_supported_backends` to see all + supported backends. + """ _analysis_algorithm_is_parallelizable = True