diff --git a/package/MDAnalysis/coordinates/PDB.py b/package/MDAnalysis/coordinates/PDB.py index c72411974d0..d83c8cff4d9 100644 --- a/package/MDAnalysis/coordinates/PDB.py +++ b/package/MDAnalysis/coordinates/PDB.py @@ -56,15 +56,13 @@ Implementations --------------- -PDB I/O is available in the form of the":ref:`permissive`" -Reader/Writers. +PDB I/O is available in the form of the Simple PDB Reader/Writers. -..deprecated:: 0.14.1 -Only available in the form of the ":ref:":ref:`permissive`" -Readers and Writers, see below +..deprecated:: 0.15.0 +Readers amd writers solely available in the form of +Simple Readers and Writers, see below. -.. _permissive: -Simple (permissive) PDB Reader and Writer +Simple PDB Reader and Writer ----------------------------------------- A pure-Python implementation for PDB files commonly encountered in MD simulations comes under the names :class:`PDBReader` and @@ -132,7 +130,7 @@ :members: -..deprecated:: 0.14.1 +..deprecated:: 0.15.0 Setting the flag "permissive_pdb_reader" in :data:`MDAnalysis.core.flags` (see :ref:`flags-label`) to ``False``:: @@ -262,7 +260,7 @@ def __init__(self, filename, **kwargs): with util.openany(filename, 'rt') as pdbfile: for i, line in enumerate(pdbfile): line = line.strip() # Remove extra spaces - if len(line) == 0: # Skip line if empty + if not line: # Skip line if empty continue record = line[:6].strip() @@ -326,7 +324,7 @@ def __init__(self, filename, **kwargs): self.convert_pos_from_native(self.ts._unitcell[:3]) # in-place ! (only lengths) # No 'MODEL' entries - if len(frames) == 0: + if not frames: frames[0] = 0 self.frames = frames @@ -736,12 +734,12 @@ def _update_frame(self, obj): Attributes initialized/updated: - * :attr:`PrimitivePDBWriter.obj` (the entity that provides topology information *and* + * :attr:`PDBWriter.obj` (the entity that provides topology information *and* coordinates, either a :class:`~MDAnalysis.core.AtomGroup.AtomGroup` or a whole :class:`~MDAnalysis.core.AtomGroup.Universe`) - * :attr:`PrimitivePDBWriter.trajectory` (the underlying trajectory + * :attr:`PDBWriter.trajectory` (the underlying trajectory :class:`~MDAnalysis.coordinates.base.Reader`) - * :attr:`PrimitivePDBWriter.timestep` (the underlying trajectory + * :attr:`PDBWriter.timestep` (the underlying trajectory :class:`~MDAnalysis.coordinates.base.Timestep`) Before calling :meth:`write_next_timestep` this method **must** be @@ -855,14 +853,14 @@ def write_next_timestep(self, ts=None, **kwargs): :Keywords: *ts* :class:`base.Timestep` object containing coordinates to be written to trajectory file; - if ``None`` then :attr:`PrimitivePDBWriter.ts`` is tried. + if ``None`` then :attr:`PDBWriter.ts`` is tried. *multiframe* ``False``: write a single frame (default); ``True`` behave as a trajectory writer .. Note:: Before using this method with another :class:`base.Timestep` in the *ts* - argument, :meth:`PrimitivePDBWriter._update_frame` *must* be called + argument, :meth:`PDBWriter._update_frame` *must* be called with the :class:`~MDAnalysis.core.AtomGroup.AtomGroup.Universe` as its argument so that topology information can be gathered. ''' @@ -1027,7 +1025,7 @@ def END(self): Only a single END record is written. Calling END multiple times has no effect. Because :meth:`~PDBWriter.close` also calls this method right before closing the file it is recommended to *not* call - :meth:`~PrimitivePDBWriter.END` explicitly. + :meth:`~PDBWriter.END` explicitly. .. _END: http://www.wwpdb.org/documentation/format32/sect11.html#END @@ -1055,16 +1053,23 @@ def CONECT(self, conect): conect = "".join(conect) self.pdbfile.write(self.fmt['CONECT'].format(conect)) -warnings.warn('PrimitivePDBReader is identical to the PDBReader,' - 'it is deprecated in favor of the shorter name', - category=DeprecationWarning) + class PrimitivePDBReader(PDBReader): + def __init__(self, filename, *args, **kwargs): + warnings.warn('PrimitivePDBReader is identical to the PDBReader,' + ' it is deprecated in favor of the shorter name' + ' removal targeted for version 0.16.0', + category=DeprecationWarning) + super(PrimitivePDBReader, self).__init__(filename, *args, **kwargs) format = 'Permissive_PDB' -warnings.warn('PrimitivePDBWriter is now identical to the PDBWriter,' - 'it is deprecated in favor of the shorter name', - category=DeprecationWarning) class PrimitivePDBWriter(PDBWriter): + def __init__(self, filename, *args, **kwargs): + warnings.warn('PrimitivePDBWriter is identical to the Writer,' + 'it is deprecated in favor of the shorter name' + ' removal targeted for version 0.16.0', + category=DeprecationWarning) + super(PrimitivePDBWriter, self).__init__(filename, *args, **kwargs) format = 'Permissive_PDB' class ExtendedPDBReader(PDBReader): diff --git a/package/MDAnalysis/core/AtomGroup.py b/package/MDAnalysis/core/AtomGroup.py index eb00c28d541..8aca895d1a4 100644 --- a/package/MDAnalysis/core/AtomGroup.py +++ b/package/MDAnalysis/core/AtomGroup.py @@ -1429,7 +1429,7 @@ def ids(self): """ out = np.array([atom.serial for atom in self._atoms]) - + if not any(out): out = np.array([atom.id for atom in self._atoms]) @@ -3334,7 +3334,7 @@ def split(self, level): return [AtomGroup([a]) for a in self] if level in ('resid', 'segid'): - warnings.warn("'resid' or 'segid' are no longer allowed levels " + warnings.warn("'resid' or 'segid' are no longer allowed levels " "in version 0.16.0; instead give " "'residue' or 'segment', respectively.", DeprecationWarning) @@ -4196,8 +4196,12 @@ def __init__(self, *args, **kwargs): *permissive* currently only relevant to PDBs, Readers and Writers and Parsers - returned by setting ::permisive = False are depecrated in favor + returned by setting ::permisive = False are deprecated in favor of their ::permissive = True counterparts + ..deprecated:: 0.15.0 + Readers amd writers solely available in the form of + Simple Readers and Writers, see below. Permissive flag + will soon be removed. *topology_format* provide the file format of the topology file; ``None`` guesses it from the file @@ -4260,7 +4264,7 @@ def __init__(self, *args, **kwargs): .. versionchanged:: 0.11.0 Added the *is_anchor* and *anchor_name* keywords for finer behavior control when unpickling instances of :class:`MDAnalysis.core.AtomGroup.AtomGroup`. - .. versionchanged:: 0.14.1 + .. versionchanged:: 0.15.0 *permissive* set to ``True`` and set to ``False`` both yield permissive PDB readers, writers and parsers """ diff --git a/package/MDAnalysis/topology/PDBParser.py b/package/MDAnalysis/topology/PDBParser.py index 699fc072405..6683b7abef9 100644 --- a/package/MDAnalysis/topology/PDBParser.py +++ b/package/MDAnalysis/topology/PDBParser.py @@ -100,7 +100,7 @@ def _parseatoms(self): resid_prev = 0 # resid looping hack for i, line in enumerate(f): line = line.strip() # Remove extra spaces - if len(line) == 0: # Skip line if empty + if not line: # Skip line if empty continue record = line[:6].strip() diff --git a/package/MDAnalysis/topology/PrimitivePDBParser.py b/package/MDAnalysis/topology/PrimitivePDBParser.py index d39c5324366..71b6a5e0030 100644 --- a/package/MDAnalysis/topology/PrimitivePDBParser.py +++ b/package/MDAnalysis/topology/PrimitivePDBParser.py @@ -45,9 +45,8 @@ :members: :inherited-members: -..deprecated:: 0.14.1 - PrimitivePDBParser now has the same behavior as PDBParser, and will be - absent from future versions +..deprecated:: 0.15.0 + PDBParser has been replaced with PrimitivePDBParser. """ from __future__ import absolute_import, print_function @@ -62,17 +61,17 @@ from .base import TopologyReader -warnings.warn('PrimitivePDBParser is identical to the PDBParser,' - 'it is deprecated in favor of the shorter name', - category=DeprecationWarning) + class PrimitivePDBParser(PDBParser.PDBParser): + def __init__(self, *args, **kwargs): + warnings.warn('PrimitivePDBParser is identical to the PDBParser,' + ' it is deprecated in favor of the shorter name', + category=DeprecationWarning) + super(PDBParser.PDBParser, self).__init__(*args, **kwargs) format = 'Permissive_PDB' -warnings.warn('PrimitivePDBParser is identical to the PDBParser,' - 'it is deprecated in favor of the shorter name,' - 'please use the parse_conect function of that class', - category=DeprecationWarning) def _parse_conect(conect): + """parse a CONECT record from pdbs Parameters diff --git a/testsuite/CHANGELOG b/testsuite/CHANGELOG index 61cc9c9d78a..9a2ff55f89d 100644 --- a/testsuite/CHANGELOG +++ b/testsuite/CHANGELOG @@ -16,6 +16,7 @@ and https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests ??/??/16 orbeckst, jbarnoud, pedrishi, fiona-naughton, jdetle * 0.15.0 - Added test for weighted rmsd (issue #814) + - removed biopython PDB parser for coordinates and topology (Issue #777) - metadata update: link download_url to GitHub releases so that Depsy recognizes contributors (issue #749) and added @richardjgowers as maintainer diff --git a/testsuite/MDAnalysisTests/coordinates/test_pdb.py b/testsuite/MDAnalysisTests/coordinates/test_pdb.py index 903a1f95f0b..1c02a6c4b0f 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_pdb.py +++ b/testsuite/MDAnalysisTests/coordinates/test_pdb.py @@ -30,18 +30,19 @@ def setUp(self): # http://www.wwpdb.org/documentation/format32/sect9.html#ATOM self.prec = 3 - def test_uses_Biopython(self): + + def test_uses_PDBReader(self): from MDAnalysis.coordinates.PDB import PDBReader assert_(isinstance(self.universe.trajectory, PDBReader), - "failed to choose Biopython PDBReader") + "failed to choose PDBReader") + - @knownfailure("Biopython PDB reader does not parse CRYST1", AssertionError) def test_dimensions(self): assert_almost_equal( self.universe.trajectory.ts.dimensions, RefAdKSmall.ref_unitcell, self.prec, - "Biopython reader failed to get unitcell dimensions from CRYST1") + "PDBReader failed to get unitcell dimensions from CRYST1") class _PDBMetadata(TestCase, Ref4e43): @@ -712,11 +713,11 @@ def setUp(self): # http://www.wwpdb.org/documentation/format32/sect9.html#ATOM self.prec = 3 - def test_uses_Biopython(self): + def test_uses_PDBReader(self): from MDAnalysis.coordinates.PDB import PDBReader assert_(isinstance(self.universe.trajectory, PDBReader), - "failed to choose Biopython PDBReader") + "failed to choose PDBReader") class TestPDBWriterOccupancies(object): diff --git a/testsuite/MDAnalysisTests/test_streamio.py b/testsuite/MDAnalysisTests/test_streamio.py index 657c8dd9f7c..9b48a6b3f04 100644 --- a/testsuite/MDAnalysisTests/test_streamio.py +++ b/testsuite/MDAnalysisTests/test_streamio.py @@ -333,7 +333,7 @@ def test_PrimitivePDBReader(self): u = MDAnalysis.Universe(streamData.as_NamedStream('PDB')) assert_equal(u.atoms.n_atoms, self.ref_n_atoms) - @knownfailure() + def test_PDBReader(self): try: u = MDAnalysis.Universe(streamData.as_NamedStream('PDB'), permissive=False)