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

Remove save() and changes filename in AlignTraj #2486

Merged
merged 7 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -76,6 +76,8 @@ Enhancements
convert between a parmed.Structure and MDAnalysis Universe (PR #2404)

Changes
* AlignTraj `save()` method has been removed and the `filename` variable now
defaults to the current working directory (Issues #2099, #1745, #2443)
* The fasta2select now always assumes that the gap character in a sequence
is "-" (Issue #2448, PR #2457)

Expand Down
26 changes: 10 additions & 16 deletions package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
from MDAnalysis.exceptions import SelectionError, SelectionWarning
import MDAnalysis.analysis.rms as rms
from MDAnalysis.coordinates.memory import MemoryReader
from MDAnalysis.lib.util import get_weights, deprecate
from MDAnalysis.lib.util import get_weights

from .base import AnalysisBase

Expand Down Expand Up @@ -536,6 +536,10 @@ class AlignTraj(AnalysisBase):
`filename`. One can also use the same universe if one wants to fit to the
current frame.

.. versionchanged:: 1.0.0
``save()`` has now been removed, as an alternative use ``np.savetxt()``
on :attr:`rmsd`.

"""

def __init__(self, mobile, reference, select='all', filename=None,
Expand Down Expand Up @@ -613,6 +617,9 @@ def __init__(self, mobile, reference, select='all', filename=None,
already a :class:`MemoryReader` then it is *always* treated as if
``in_memory`` had been set to ``True``.

.. versionchanged:: 1.0.0
Default ``filename`` has now been changed to the current directory.

.. deprecated:: 0.19.1
Default ``filename`` directory will change in 1.0 to the current directory.

Expand All @@ -635,13 +642,8 @@ def __init__(self, mobile, reference, select='all', filename=None,
logger.info("Moved mobile trajectory to in-memory representation")
else:
if filename is None:
# DEPRECATED in 0.19.1
# Change in 1.0
#
# fn = os.path.split(mobile.trajectory.filename)[1]
# filename = prefix + fn
path, fn = os.path.split(mobile.trajectory.filename)
filename = os.path.join(path, prefix + fn)
fn = os.path.split(mobile.trajectory.filename)[1]
filename = prefix + fn
logger.info('filename of rms_align with no filename given'
': {0}'.format(filename))

Expand Down Expand Up @@ -699,14 +701,6 @@ def _conclude(self):
if not self._verbose:
logging.disable(logging.NOTSET)

@deprecate(release="0.19.0", remove="1.0")
def save(self, rmsdfile):
"""save rmsd as a numpy array
"""
# these are the values of the new rmsd between the aligned trajectory
# and reference structure
np.savetxt(rmsdfile, self.rmsd)
logger.info("Wrote RMSD timeseries to file %r", rmsdfile)

class AverageStructure(AnalysisBase):
"""RMS-align trajectory to a reference structure using a selection,
Expand Down
11 changes: 0 additions & 11 deletions testsuite/MDAnalysisTests/analysis/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,13 @@ def test_rmsd_custom_weights(self, universe, reference):
assert_almost_equal(rmsd[1], rmsd_weights[1], 6)

def test_AlignTraj_outfile_default(self, universe, reference):
# NOTE: Remove the line os.remove() with release 1.0,
# when the default behavior of AlignTraj changes.
with tempdir.in_tempdir():
reference.trajectory[-1]
x = align.AlignTraj(universe, reference)
try:
assert os.path.basename(x.filename) == 'rmsfit_adk_dims.dcd'
finally:
x._writer.close()
os.remove(x.filename)

def test_AlignTraj_outfile_default_exists(self, universe, reference, tmpdir):
reference.trajectory[-1]
Expand Down Expand Up @@ -250,9 +247,6 @@ def test_AlignTraj(self, universe, reference, tmpdir):
x = align.AlignTraj(universe, reference, filename=outfile).run()
fitted = mda.Universe(PSF, outfile)

rmsd_outfile = str(tmpdir.join('rmsd'))
x.save(rmsd_outfile)

assert_almost_equal(x.rmsd[0], 6.9290, decimal=3)
assert_almost_equal(x.rmsd[-1], 5.2797e-07, decimal=3)

Expand All @@ -262,11 +256,6 @@ def test_AlignTraj(self, universe, reference, tmpdir):
self._assert_rmsd(reference, fitted, 0, 6.929083044751061)
self._assert_rmsd(reference, fitted, -1, 0.0)

# superficially check saved file rmsd_outfile
rmsd = np.loadtxt(rmsd_outfile)
assert_array_almost_equal(rmsd, x.rmsd,
err_msg="saved RMSD not correct")

def test_AlignTraj_weighted(self, universe, reference, tmpdir):
outfile = str(tmpdir.join('align_test.dcd'))
x = align.AlignTraj(universe, reference,
Expand Down