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

Deprecate hole2 class in favour of MDAKit #4200

Merged
merged 2 commits into from
Jul 16, 2023
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
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Changes
(PR #4174, Issue #3819)

Deprecations
* The hole2 module is deprecated in favour of the the MDAKit:
https://github.com/MDAnalysis/hole2-mdakit (Issue #4179, PR #4200)
* MDAnalysis no longer officially supports 32 bit installations (they are
no longer tested in our continuous integration pipelines). Note: whilst
no code changes have been made to disable 32 bit, although it is known that
Expand Down
15 changes: 15 additions & 0 deletions package/MDAnalysis/analysis/hole2/hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import matplotlib.pyplot as plt
from collections import OrderedDict

from MDAnalysis.lib.util import deprecate
from ...exceptions import ApplicationError
from ..base import AnalysisBase
from ...lib import util
Expand All @@ -46,6 +47,9 @@
logger = logging.getLogger(__name__)


@deprecate(release="2.6.0", remove="3.0.0",
message=("This method has been moved to the MDAKit hole2-mdakit: "
"https://github.com/MDAnalysis/hole2-mdakit"))
def hole(pdbfile,
infile_text=None,
infile=None,
Expand Down Expand Up @@ -429,6 +433,11 @@
are now stored in a :class:`MDAnalysis.analysis.base.Results`
instance.

.. deprecated:: 2.6.0
This class has been moved to the MDAKit
`hole2-mdakit <https://github.com/MDAnalysis/hole2-mdakit>`_ and will
be removed for the core MDAnalysis library in version 3.0

"""

input_file = '{prefix}hole{i:03d}.inp'
Expand Down Expand Up @@ -478,6 +487,12 @@
write_input_files=False):
super(HoleAnalysis, self).__init__(universe.universe.trajectory,
verbose=verbose)

wmsg = ("This class has been moved to the MDAKit `hole2-mdakit` "

Check warning on line 491 in package/MDAnalysis/analysis/hole2/hole.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/analysis/hole2/hole.py#L491

Added line #L491 was not covered by tests
"(https://github.com/MDAnalysis/hole2-mdakit) and will be "
"removed in version 3.0.")
warnings.warn(wmsg, DeprecationWarning)

Check warning on line 494 in package/MDAnalysis/analysis/hole2/hole.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/analysis/hole2/hole.py#L494

Added line #L494 was not covered by tests

if output_level > 3:
msg = 'output_level ({}) needs to be < 3 in order to extract a HOLE profile!'
warnings.warn(msg.format(output_level))
Expand Down
49 changes: 34 additions & 15 deletions testsuite/MDAnalysisTests/analysis/test_hole2.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ class TestHole(object):

def test_correct_input(self, tmpdir):
with tmpdir.as_cwd():
hole2.hole(self.filename, random_seed=self.random_seed,
infile='hole.inp')
with pytest.warns(DeprecationWarning, match="to the MDAKit"):
hole2.hole(self.filename, random_seed=self.random_seed,
infile='hole.inp')

infile = str(tmpdir.join('hole.inp'))
with open(infile, 'r') as f:
Expand All @@ -135,9 +136,10 @@ def test_input_options(self, tmpdir):
cog = u.select_atoms('protein').center_of_geometry()

with tmpdir.as_cwd():
hole2.hole(self.filename, random_seed=self.random_seed,
infile='hole.inp', cpoint=cog,
ignore_residues=[])
with pytest.warns(DeprecationWarning, match="to the MDAKit"):
hole2.hole(self.filename, random_seed=self.random_seed,
infile='hole.inp', cpoint=cog,
ignore_residues=[])

infile = str(tmpdir.join('hole.inp'))
with open(infile, 'r') as f:
Expand All @@ -159,7 +161,9 @@ def test_input_options(self, tmpdir):

def test_correct_profile_values(self, tmpdir):
with tmpdir.as_cwd():
profiles = hole2.hole(self.filename, random_seed=self.random_seed)
with pytest.warns(DeprecationWarning, match="to the MDAKit"):
profiles = hole2.hole(self.filename,
random_seed=self.random_seed)

values = list(profiles.values())
assert_equal(len(values), 1,
Expand Down Expand Up @@ -195,11 +199,13 @@ def test_correct_profile_values(self, tmpdir):

# assert_equal(len(profiles), int(keep_frames/step))

@pytest.mark.filterwarnings("ignore: `hole` is deprecated")
def test_application_error(self, tmpdir):
with tmpdir.as_cwd():
with pytest.raises(ApplicationError):
hole2.hole(self.filename, dcd=DCD)

@pytest.mark.filterwarnings("ignore: `hole` is deprecated")
def test_output_level(self, tmpdir):
with tmpdir.as_cwd():
with pytest.warns(UserWarning, match="needs to be < 3"):
Expand All @@ -210,9 +216,10 @@ def test_output_level(self, tmpdir):

def test_keep_files(self, tmpdir):
with tmpdir.as_cwd():
hole2.hole(self.filename, random_seed=self.random_seed,
infile='hole.inp',
keep_files=False)
with pytest.warns(DeprecationWarning, match="to the MDAKit"):
hole2.hole(self.filename, random_seed=self.random_seed,
infile='hole.inp',
keep_files=False)
sphpdbs = tmpdir.join('*.sph')
assert len(glob.glob(str(sphpdbs))) == 0
outfiles = tmpdir.join('*.out')
Expand Down Expand Up @@ -243,7 +250,8 @@ def universe(self):
@pytest.fixture()
def hole(self, universe, tmpdir):
with tmpdir.as_cwd():
h = hole2.HoleAnalysis(universe)
with pytest.warns(DeprecationWarning, match='This class has been'):
h = hole2.HoleAnalysis(universe)
h.run(start=self.start, stop=self.stop,
random_seed=self.random_seed)
return h
Expand Down Expand Up @@ -274,21 +282,25 @@ class TestOSError:
def universe(self):
return mda.Universe(MULTIPDB_HOLE)

@pytest.mark.filterwarnings("ignore: `hole` is deprecated")
def test_hole_method_oserror(self):
errmsg = exe_err.format(name='dummy_path', kw='executable')
with pytest.raises(OSError, match=errmsg):
h = hole2.hole(PDB_HOLE, executable='dummy_path')

@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_hole_oserror(self, universe):
errmsg = exe_err.format(name='dummy_path', kw='executable')
with pytest.raises(OSError, match=errmsg):
h = hole2.HoleAnalysis(universe, executable='dummy_path')

@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_sos_triangle_oserror(self, universe):
errmsg = exe_err.format(name='dummy_path', kw='sos_triangle')
with pytest.raises(OSError, match=errmsg):
h = hole2.HoleAnalysis(universe, sos_triangle='dummy_path')

@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_sph_process_oserror(self, universe):
errmsg = exe_err.format(name='dummy_path', kw='sph_process')
with pytest.raises(OSError, match=errmsg):
Expand Down Expand Up @@ -316,6 +328,7 @@ def test_min_radius(self, hole):
assert_almost_equal(hole.min_radius(), values,
err_msg="min_radius() array not correct")

@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_context_manager(self, universe, tmpdir):
with tmpdir.as_cwd():
with hole2.HoleAnalysis(universe) as h:
Expand All @@ -336,14 +349,16 @@ def test_context_manager(self, universe, tmpdir):
vmd_file = tmpdir.join('hole.vmd')
assert len(glob.glob(str(vmd_file))) == 1

@pytest.mark.filterwarnings("ignore: This class has been moved")
@pytest.mark.parametrize("start,stop,step", [
(1, 9, 2), (1, None, 3), (5, -2, None)])
def test_nonzero_start_surface(self, universe, tmpdir,
start, stop, step,
surface="hole.vmd"):
# Issue 3476
with tmpdir.as_cwd():
h = hole2.HoleAnalysis(universe)
with pytest.warns(DeprecationWarning, match='This class has been'):
h = hole2.HoleAnalysis(universe)
h.run(start=start, stop=stop, step=step)
h.create_vmd_surface(filename=surface)

Expand All @@ -358,6 +373,7 @@ def test_nonzero_start_surface(self, universe, tmpdir,
np.arange(len(universe.trajectory[start:stop:step])),
err_msg="wrong frame indices in VMD surface file")

@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_output_level(self, tmpdir, universe):
with tmpdir.as_cwd():
with pytest.warns(UserWarning, match='needs to be < 3'):
Expand All @@ -373,10 +389,11 @@ def test_cpoint_geometry(self, tmpdir, universe):
protein = universe.select_atoms('protein')
cogs = [protein.center_of_geometry() for ts in universe.trajectory]
with tmpdir.as_cwd():
h = hole2.HoleAnalysis(universe,
select='protein',
cpoint='center_of_geometry',
write_input_files=True)
with pytest.warns(DeprecationWarning, match='This class has been'):
h = hole2.HoleAnalysis(universe,
select='protein',
cpoint='center_of_geometry',
write_input_files=True)
h.run(start=self.start,
stop=self.stop, random_seed=self.random_seed)

Expand Down Expand Up @@ -469,6 +486,7 @@ def test_plot3D_rmax(self, hole, frames, profiles):
assert_almost_equal(z, radius)
assert line.get_label() == str(frame)

@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_none_filename(self, tmpdir):
universe_none_filename = mda.Universe(PDB_HOLE, in_memory=True)
universe_none_filename.trajectory.filename = None
Expand Down Expand Up @@ -722,6 +740,7 @@ def universe():

@pytest.mark.skipif(rlimits_missing,
reason="Test skipped because platform does not allow setting rlimits")
@pytest.mark.filterwarnings("ignore: This class has been moved")
def test_hole_module_fd_closure(self, universe, tmpdir):
"""test open file descriptors are closed (MDAnalysisTests.analysis.test_hole.TestHoleModule): Issue 129"""
# If Issue 129 isn't resolved, this function will produce an OSError on
Expand Down
Loading