Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Changes holetraj start/stop/step keywords (Issue #2513) #2514

Merged
merged 3 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ Enhancements
* Improve the distance search in water bridge analysis with capped_distance (PR #2480)

Changes
* Removes support for setting `start`/`stop`/`step` trajecotry slicing
keywords on :class:`HOLEtraj` construction. Also removes undocumented
support for passing :class:`HOLE` parameters to :meth:`HOLEtraj.run`
(Issue #2513).
* Removes the `nproc` keyword from
:class:`Waterdynamics.HydrogenBondLifetimes` as the multiprocessing functionality
did not work in some cases(Issues #2511).
Expand Down
44 changes: 26 additions & 18 deletions package/MDAnalysis/analysis/hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,9 +1172,9 @@ class HOLEtraj(BaseHOLE):
universe and feed it to HOLE. It sequentially creates a temporary PDB for
each frame and runs HOLE on the frame.

The trajectory can be sliced with the `start`, `stop`, and `step`
keywords. (:program:`hole` is not fast so slicing a trajectory is
recommended.)
The trajectory can be sliced by passing the `start`, `stop`, and `step`
keywords to :meth:`HOLEtraj.run`. (:program:`hole` is not fast so slicing a
trajectory is recommended.)

Frames of the trajectory can be associated with order parameters (e.g.,
RMSD) in order to group the HOLE profiles by order parameter (see the
Expand All @@ -1195,10 +1195,6 @@ def __init__(self, universe, **kwargs):
orderparameters : array_like or string, optional
Sequence or text file containing order parameters (float
numbers) corresponding to the frames in the trajectory.
start, stop, step : int, optional
slice the trajectory as
``universe.trajectory[start:stop:step]``. The default is ``None``
so that the whole trajectory is analyzed
selection : string, optional
selection string for
:meth:`~MDAnalysis.core.universe.Universe.select_atoms` to select
Expand All @@ -1218,16 +1214,16 @@ def __init__(self, universe, **kwargs):
All other keywords are passed on to :class:`HOLE` (see there for
description).


.. versionchanged:: 1.0.0
Support for the `start`, `stop`, and `step` keywords has been
removed. These should instead be passed to :meth:`HOLEtraj.run`.
"""

self.universe = universe
self.selection = kwargs.pop("selection", "protein")
self.orderparametersfile = kwargs.pop("orderparameters", None)

self.start = kwargs.pop('start', None)
self.stop = kwargs.pop('stop', None)
self.step = kwargs.pop('step', None)

self.cpoint = kwargs.pop('cpoint', None)
if self.cpoint is True:
self.cpoint = self.guess_cpoint(selection=self.selection)
Expand Down Expand Up @@ -1275,17 +1271,29 @@ def _process_orderparameters(self, data):
raise ValueError(errmsg)
return q

def run(self, **kwargs):
def run(self, start=None, stop=None, step=None):
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
"""Run HOLE on the whole trajectory and collect profiles.

Keyword arguments `start`, `stop`, and `step` can be used to only
analyse part of the trajectory.
Parameters
----------
start : int, optional
First frame of trajectory to analyse, Default: None (first frame)
stop : int, optional
Last frame of trajectory to analyse, Default: None (last frame)
step : int, optional
Step between frames to analyse, Default: None (use every frame)

.. versionchanged:: 1.0.0
Undocumented support for setting :class:`HOLE` parameters via
:meth:`HOLEtraj.run` has been removed. This should now exclusively
be done on :class:`HOLEtraj` construction.
"""
start = kwargs.pop('start', self.start)
stop = kwargs.pop('stop', self.stop)
step = kwargs.pop('step', self.step)
start, stop, step = self.universe.trajectory.check_slice_indices(
start,
stop,
step
)
hole_kw = self.hole_kwargs.copy()
hole_kw.update(kwargs)

profiles = OrderedDict() # index by orderparameters: NOTE: can overwrite!

Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/analysis/test_hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def universe(self):
@pytest.fixture()
def H(self, universe, tmpdir):
with tmpdir.as_cwd():
H = HOLEtraj(universe, start=self.start, stop=self.stop, raseed=31415)
H.run()
H = HOLEtraj(universe, raseed=31415)
H.run(start=self.start, stop=self.stop)
return H

@pytest.fixture()
Expand Down