Skip to content

Commit

Permalink
Deprecate fetch mmtf (#4639)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay authored Jul 24, 2024
1 parent b227f17 commit 780f958
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 43 deletions.
4 changes: 4 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Enhancements
DOI 10.1021/acs.jpcb.7b11988. (Issue #2039, PR #4524)

Changes
* The `fetch_mmtf` method has been removed as the REST API service
for MMTF files has ceased to exist (Issue #4634)
* MDAnalysis now builds against numpy 2.0 rather than the
minimum supported numpy version (PR #4620)
* As per SPEC0 the minimum supported Python version has been raised
Expand All @@ -82,6 +84,8 @@ Changes
numpy.testing.assert_allclose #4438)

Deprecations
* The MMTF Reader is deprecated and will be removed in version 3.0
as the MMTF format is no longer supported (Issue #4634)
* The MDAnalysis.analysis.waterdynamics module has been deprecated in favour
of the waterdynamics MDAKit and will be removed in version 3.0.0 (PR #4404)
* The MDAnalysis.analysis.psa module has been deprecated in favour of
Expand Down
3 changes: 1 addition & 2 deletions package/MDAnalysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"""

__all__ = ['Universe', 'Writer', 'fetch_mmtf',
__all__ = ['Universe', 'Writer',
'AtomGroup', 'ResidueGroup', 'SegmentGroup']

import logging
Expand Down Expand Up @@ -209,7 +209,6 @@
from .coordinates.core import writer as Writer

# After Universe import
from .coordinates.MMTF import fetch_mmtf
from . import converters

from .due import due, Doi, BibTeX
Expand Down
48 changes: 21 additions & 27 deletions package/MDAnalysis/coordinates/MMTF.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@
.. autoclass:: MMTFReader
:members:
.. autofunction:: fetch_mmtf
.. _MMTF: https://mmtf.rcsb.org/
"""
import warnings
import mmtf

from . import base
from ..core.universe import Universe
from ..lib.util import cached, store_init_arguments
from ..due import due, Doi


Expand All @@ -56,9 +57,27 @@ def _parse_mmtf(fn):


class MMTFReader(base.SingleFrameReaderBase):
"""Coordinate reader for the Macromolecular Transmission Format format (MMTF_)."""
"""Coordinate reader for the Macromolecular Transmission Format format (MMTF_).
.. deprecated:: 2.8.0
The MMTF format is no longer supported / serviced by the
Protein Data Bank. The Reader will be removed in version 3.0.
Users are encouraged to instead use alternative PDB formats.
"""
format = 'MMTF'

@store_init_arguments
def __init__(self, filename, convert_units=True, n_atoms=None, **kwargs):
wmsg = ("The MMTF Reader is deprecated and will be removed in "
"MDAnalysis version 3.0.0")
warnings.warn(wmsg, DeprecationWarning)

super(MMTFReader, self).__init__(
filename, convert_units, n_atoms,
**kwargs
)

@staticmethod
def _format_hint(thing):
"""Can this Reader read *thing*?
Expand Down Expand Up @@ -90,28 +109,3 @@ def _read_first_frame(self):
ts.dimensions = top.unit_cell

return ts


def fetch_mmtf(pdb_id):
"""Create a Universe from the RCSB Protein Data Bank using mmtf format
Parameters
----------
pdb_id : string
PDB code of the desired data, eg '4UCP'
Returns
-------
Universe
MDAnalysis Universe of the corresponding PDB system
See Also
--------
mmtf.fetch : Function for fetching raw mmtf data
.. versionadded:: 0.16.0
"""
return Universe(mmtf.fetch(pdb_id))
7 changes: 7 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_mmtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ def test_dimensionless():
r = MMTFReader(MMTF_skinny2)

assert r.ts.dimensions is None


def test_deprecation():
wmsg = "The MMTF Reader is deprecated"

with pytest.warns(DeprecationWarning, match=wmsg):
_ = MMTFReader(MMTF_skinny2)
4 changes: 0 additions & 4 deletions testsuite/MDAnalysisTests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def test_Universe():
assert mda.Universe is mda.core.universe.Universe


def test_fetch_mmtf():
assert mda.fetch_mmtf is mda.coordinates.MMTF.fetch_mmtf


def test_Writer():
assert mda.Writer is mda.coordinates.core.writer

Expand Down
10 changes: 0 additions & 10 deletions testsuite/MDAnalysisTests/topology/test_mmtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@ def u(self):
return mda.Universe(top)


class TestMMTFFetch(TestMMTFUniverse):
@pytest.fixture()
def u(self):
top = mmtf.parse(MMTF)
with mock.patch('mmtf.fetch') as mock_fetch:
mock_fetch.return_value = top

return mda.fetch_mmtf('173D') # string is irrelevant


class TestSelectModels(object):
# tests for 'model' keyword in select_atoms
@pytest.fixture()
Expand Down

0 comments on commit 780f958

Please sign in to comment.