diff --git a/package/MDAnalysis/analysis/rms.py b/package/MDAnalysis/analysis/rms.py index 1d2bb7e392c..7d2e6586984 100644 --- a/package/MDAnalysis/analysis/rms.py +++ b/package/MDAnalysis/analysis/rms.py @@ -527,7 +527,7 @@ def save(self, filename=None): if filename is not None: if self.rmsd is None: raise NoDataError("rmsd has not been calculated yet") - np.savetxt(filename, self.rmsd) + np.save(filename, self.rmsd) logger.info("Wrote RMSD timeseries to file %r", filename) return filename diff --git a/testsuite/MDAnalysisTests/analysis/test_rms.py b/testsuite/MDAnalysisTests/analysis/test_rms.py index 48aba6b3523..99340e54a34 100644 --- a/testsuite/MDAnalysisTests/analysis/test_rms.py +++ b/testsuite/MDAnalysisTests/analysis/test_rms.py @@ -26,11 +26,11 @@ import os -from MDAnalysisTests.datafiles import GRO, XTC, rmsfArray, PSF, DCD +from MDAnalysisTests.datafiles import GRO, XTC, rmsfArray, rmsdArray, PSF, DCD from MDAnalysisTests import tempdir -class TestRMSD(object): +class Testrmsd(object): def __init__(self): shape = (5, 3) # vectors with length one @@ -128,6 +128,30 @@ def test_with_superposition_equal(self): rmsd_superposition = rms.rmsd(A, B, center=True, superposition=True) assert_almost_equal(rmsd, rmsd_superposition) +class TestRMSD(object): + def setUp(self): + self.universe = MDAnalysis.Universe(GRO, XTC) + self.tempdir = tempdir.TempDir() + self.outfile = os.path.join(self.tempdir.name, 'rmsd.xtc') + + def tearDown(self): + del self.universe + del self.tempdir + + def test_rmsd(self): + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') + RMSD.run() + test_rmsds = np.load(rmsdArray) + + assert_almost_equal(RMSD.rmsd, test_rmsds, 5, + err_msg="error: rmsf profile should match test " + + "values") + + def test_rmsd_single_frame(self): + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') + RMSD.run(start=5, stop=6) + + class TestRMSF(TestCase): def setUp(self): diff --git a/testsuite/MDAnalysisTests/data/adk_oplsaa_CA_rmsd.npy b/testsuite/MDAnalysisTests/data/adk_oplsaa_CA_rmsd.npy new file mode 100644 index 00000000000..8eed3d00377 Binary files /dev/null and b/testsuite/MDAnalysisTests/data/adk_oplsaa_CA_rmsd.npy differ diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 824cc407ed2..95dbb1a1f2e 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -104,7 +104,7 @@ "two_water_gro_widebox", # Issue #548 "DLP_CONFIG", "DLP_CONFIG_order", "DLP_CONFIG_minimal", # dl_poly 4 config file "DLP_HISTORY", "DLP_HISTORY_order", "DLP_HISTORY_minimal", # dl_poly 4 history file - "waterPSF","waterDCD","rmsfArray", + "waterPSF","waterDCD","rmsfArray","rmsdArray" "HoomdXMLdata", "Make_Whole", # for testing the function lib.mdamath.make_whole, has 9 atoms "Plength", @@ -318,6 +318,7 @@ waterDCD = resource_filename(__name__, 'data/watdyn.dcd') rmsfArray = resource_filename(__name__, 'data/adk_oplsaa_CA_rmsf.npy') +rmsdArray = resource_filename(__name__, 'data/adk_oplsaa_CA_rmsd.npy') HoomdXMLdata = resource_filename(__name__, 'data/C12x64.xml.bz2')