Skip to content

Commit

Permalink
remove fetch_mmtf and add deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay committed Jul 22, 2024
1 parent b4d5684 commit 36fd5cb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 43 deletions.
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
44 changes: 17 additions & 27 deletions package/MDAnalysis/coordinates/MMTF.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
.. autoclass:: MMTFReader
:members:
.. autofunction:: fetch_mmtf
.. _MMTF: https://mmtf.rcsb.org/
"""
import warnings
import mmtf

from . import base
Expand All @@ -56,9 +56,24 @@ 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__(**kwargs)

@staticmethod
def _format_hint(thing):
"""Can this Reader read *thing*?
Expand Down Expand Up @@ -90,28 +105,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))
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 36fd5cb

Please sign in to comment.