From dfb3c996bd17efc5af624a77a194d018a64a4343 Mon Sep 17 00:00:00 2001 From: John Detlefs Date: Wed, 6 Jul 2016 11:35:06 -0700 Subject: [PATCH 1/6] Removed call to protected process_selection now that it isn't protected Updated CHANGELOG --- package/CHANGELOG | 1 + package/MDAnalysis/analysis/rms.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index a01407ba373..08850e068fa 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -25,6 +25,7 @@ Fixes next (Issue #869) * Display of Deprecation warnings doesn't affect other modules anymore (Issue #754) * Changed nframes to n_frames in analysis modules for consistency (Issue #890) + * Removed call to protected process_selection function in RMSD Changes * Added protected variable _frame_index to to keep track of frame iteration diff --git a/package/MDAnalysis/analysis/rms.py b/package/MDAnalysis/analysis/rms.py index 7b44115b259..1d2bb7e392c 100644 --- a/package/MDAnalysis/analysis/rms.py +++ b/package/MDAnalysis/analysis/rms.py @@ -338,9 +338,9 @@ def __init__(self, traj, reference=None, select='all', self.reference = self.universe else: self.reference = reference - self.select = _process_selection(select) + self.select = process_selection(select) if groupselections is not None: - self.groupselections = [_process_selection(s) for s in groupselections] + self.groupselections = [process_selection(s) for s in groupselections] else: self.groupselections = [] self.mass_weighted = mass_weighted From a0c1bdb0ef4a74d4e6a81f592de3cf8c40b95f85 Mon Sep 17 00:00:00 2001 From: John Detlefs Date: Fri, 8 Jul 2016 15:06:13 -0700 Subject: [PATCH 2/6] Added tests for RMSD, added a testfile. Changed RMSD class to save rmsd array as numpy file instead of text. --- package/MDAnalysis/analysis/rms.py | 2 +- .../MDAnalysisTests/analysis/test_rms.py | 28 ++++++++++++++++-- .../data/adk_oplsaa_CA_rmsd.npy | Bin 0 -> 320 bytes testsuite/MDAnalysisTests/datafiles.py | 3 +- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 testsuite/MDAnalysisTests/data/adk_oplsaa_CA_rmsd.npy 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..12ee441f1cf 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: rmsd 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 0000000000000000000000000000000000000000..8eed3d0037706424b37da15acc90e694e0b8354a GIT binary patch literal 320 zcmbR27wQ`j$;jZwP_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-209AHnmP)#3NXOMfCd`$dD7(9?6rdkf3OGA3JeU94$oKY*=V*{*#RQX z0HPHb7&0B?G=c&$iWES6AmDHSQwNG1LMA;bo_R(R!e-w04jk*aR2}S literal 0 HcmV?d00001 diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 824cc407ed2..e2b936c40b1 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') From ea41a4996ce5432112c12ea7acc9b8c1d62e0a17 Mon Sep 17 00:00:00 2001 From: John Detlefs Date: Fri, 8 Jul 2016 16:51:22 -0700 Subject: [PATCH 3/6] Tested saving --- testsuite/MDAnalysisTests/analysis/test_rms.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_rms.py b/testsuite/MDAnalysisTests/analysis/test_rms.py index 12ee441f1cf..5d320f1d506 100644 --- a/testsuite/MDAnalysisTests/analysis/test_rms.py +++ b/testsuite/MDAnalysisTests/analysis/test_rms.py @@ -132,7 +132,7 @@ 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') + self.outfile = os.path.join(self.tempdir.name, 'rmsd.npy') def tearDown(self): del self.universe @@ -151,7 +151,15 @@ def test_rmsd_single_frame(self): RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') RMSD.run(start=5, stop=6) - + def test_rmsd_save(self): + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') + RMSD.run() + RMSD.save(self.outfile) + saved_file = np.load(self.outfile) + test_rmsds = np.load(rmsdArray) + assert_almost_equal(saved_file, test_rmsds, 5, + err_msg="error: rmsd profile should match test " + + "values") class TestRMSF(TestCase): def setUp(self): From 023408db07dbe5fcb0bc71d0298fbb0b2dc11d88 Mon Sep 17 00:00:00 2001 From: John Detlefs Date: Fri, 8 Jul 2016 17:40:36 -0700 Subject: [PATCH 4/6] Test group selections Reverted back to save. Updated test coverage for exceptions. Found some errors with logging requiring a message. Reverted inclusion of unnecessary RMSD array. Fixed a small error and combined save and mass_weighted test. No Data Error. Covered RMSD.save(). --- package/CHANGELOG | 1 - package/MDAnalysis/analysis/rms.py | 8 +-- .../MDAnalysisTests/analysis/test_rms.py | 61 ++++++++++++++---- .../data/adk_oplsaa_CA_rmsd.npy | Bin 320 -> 0 bytes testsuite/MDAnalysisTests/datafiles.py | 3 +- 5 files changed, 52 insertions(+), 21 deletions(-) delete mode 100644 testsuite/MDAnalysisTests/data/adk_oplsaa_CA_rmsd.npy diff --git a/package/CHANGELOG b/package/CHANGELOG index 08850e068fa..a01407ba373 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -25,7 +25,6 @@ Fixes next (Issue #869) * Display of Deprecation warnings doesn't affect other modules anymore (Issue #754) * Changed nframes to n_frames in analysis modules for consistency (Issue #890) - * Removed call to protected process_selection function in RMSD Changes * Added protected variable _frame_index to to keep track of frame iteration diff --git a/package/MDAnalysis/analysis/rms.py b/package/MDAnalysis/analysis/rms.py index 7d2e6586984..4e00c2b7eb8 100644 --- a/package/MDAnalysis/analysis/rms.py +++ b/package/MDAnalysis/analysis/rms.py @@ -83,7 +83,7 @@ import matplotlib.pyplot as plt rmsd = R.rmsd.T # transpose makes it easier for plotting - time = rmsd[1] + time = rmsd[1]facebook.com fig = plt.figure(figsize=(4,4)) ax = fig.add_subplot(111) ax.plot(time, rmsd[2], 'k-', label="all") @@ -351,7 +351,7 @@ def __init__(self, traj, reference=None, select='all', self.ref_atoms = self.reference.select_atoms(*self.select['reference']) self.traj_atoms = self.universe.select_atoms(*self.select['mobile']) if len(self.ref_atoms) != len(self.traj_atoms): - logger.exception() + logger.exception('SelectionError: ref_atoms, traj_atoms unequal') raise SelectionError("Reference and trajectory atom selections do " "not contain the same number of atoms: " "N_ref={0:d}, N_traj={1:d}".format( @@ -386,7 +386,7 @@ def __init__(self, traj, reference=None, select='all', for igroup, (sel, atoms) in enumerate(zip(self.groupselections, self.groupselections_atoms)): if len(atoms['mobile']) != len(atoms['reference']): - logger.exception() + logger.exception('SelectionError: Group Selection') raise SelectionError( "Group selection {0}: {1} | {2}: Reference and trajectory " "atom selections do not contain the same number of atoms: " @@ -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.save(filename, self.rmsd) + np.savetxt(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 5d320f1d506..227bd804b7d 100644 --- a/testsuite/MDAnalysisTests/analysis/test_rms.py +++ b/testsuite/MDAnalysisTests/analysis/test_rms.py @@ -26,7 +26,8 @@ import os -from MDAnalysisTests.datafiles import GRO, XTC, rmsfArray, rmsdArray, PSF, DCD +from MDAnalysis.exceptions import SelectionError, NoDataError +from MDAnalysisTests.datafiles import GRO, XTC, rmsfArray, PSF, DCD from MDAnalysisTests import tempdir @@ -130,7 +131,7 @@ def test_with_superposition_equal(self): class TestRMSD(object): def setUp(self): - self.universe = MDAnalysis.Universe(GRO, XTC) + self.universe = MDAnalysis.Universe(PSF, DCD) self.tempdir = tempdir.TempDir() self.outfile = os.path.join(self.tempdir.name, 'rmsd.npy') @@ -140,26 +141,58 @@ def tearDown(self): 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, + RMSD.run(step=49) + correct_values = [[ 0, 0, 0], + [ 49, 48.9999, 4.68953]] + assert_almost_equal(RMSD.rmsd, correct_values, 4, err_msg="error: rmsd 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) - def test_rmsd_save(self): + + def test_mass_weighted_and_save(self): RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') - RMSD.run() - RMSD.save(self.outfile) - saved_file = np.load(self.outfile) - test_rmsds = np.load(rmsdArray) - assert_almost_equal(saved_file, test_rmsds, 5, - err_msg="error: rmsd profile should match test " + - "values") + RMSD.run(step=49, mass_weighted= True) + RMSD.save() + + def test_rmsd_group_selections(self): + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, + groupselections= + ['backbone','name CA']) + RMSD.run(step=49) + + + @raises(SelectionError) + def test_ref_length_unequal_len(self): + reference = MDAnalysis.Universe(PSF, DCD) + reference.atoms = reference.atoms[:-1] + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, + reference=reference) + + @raises(SelectionError) + def test_mass_mismatches(self): + reference = MDAnalysis.Universe(PSF, DCD) + reference.atoms.masses = 10 + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, + reference=reference) + + + @raises(SelectionError) + def test_group_selections_unequal_len(self): + reference = MDAnalysis.Universe(PSF, DCD) + reference.atoms[0].resname='NOTMET' + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, + reference=reference, + groupselections= + ['resname MET','type NH3']) + @raises(NoDataError) + def test_save_before_run(self): + RMSD = MDAnalysis.analysis.rms.RMSD(self.universe) + RMSD.save('blah') 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 deleted file mode 100644 index 8eed3d0037706424b37da15acc90e694e0b8354a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 320 zcmbR27wQ`j$;jZwP_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-209AHnmP)#3NXOMfCd`$dD7(9?6rdkf3OGA3JeU94$oKY*=V*{*#RQX z0HPHb7&0B?G=c&$iWES6AmDHSQwNG1LMA;bo_R(R!e-w04jk*aR2}S diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index e2b936c40b1..824cc407ed2 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","rmsdArray", + "waterPSF","waterDCD","rmsfArray", "HoomdXMLdata", "Make_Whole", # for testing the function lib.mdamath.make_whole, has 9 atoms "Plength", @@ -318,7 +318,6 @@ 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') From 40eb01c2815bd73a5273580a69da6645a2bf741c Mon Sep 17 00:00:00 2001 From: jdetle Date: Sat, 9 Jul 2016 20:41:53 -0700 Subject: [PATCH 5/6] Fixed error messages --- package/MDAnalysis/analysis/rms.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/package/MDAnalysis/analysis/rms.py b/package/MDAnalysis/analysis/rms.py index 4e00c2b7eb8..639220196de 100644 --- a/package/MDAnalysis/analysis/rms.py +++ b/package/MDAnalysis/analysis/rms.py @@ -83,7 +83,7 @@ import matplotlib.pyplot as plt rmsd = R.rmsd.T # transpose makes it easier for plotting - time = rmsd[1]facebook.com + time = rmsd[1] fig = plt.figure(figsize=(4,4)) ax = fig.add_subplot(111) ax.plot(time, rmsd[2], 'k-', label="all") @@ -351,12 +351,13 @@ def __init__(self, traj, reference=None, select='all', self.ref_atoms = self.reference.select_atoms(*self.select['reference']) self.traj_atoms = self.universe.select_atoms(*self.select['mobile']) if len(self.ref_atoms) != len(self.traj_atoms): - logger.exception('SelectionError: ref_atoms, traj_atoms unequal') - raise SelectionError("Reference and trajectory atom selections do " + errmsg = "Reference and trajectory atom selections do " "not contain the same number of atoms: " "N_ref={0:d}, N_traj={1:d}".format( self.ref_atoms.n_atoms, - self.traj_atoms.n_atoms)) + self.traj_atoms.n_atoms) + logger.exception(errmsg) + raise SelectionError(errormsg) logger.info("RMS calculation for {0:d} atoms.".format(len(self.ref_atoms))) mass_mismatches = (np.absolute(self.ref_atoms.masses - self.traj_atoms.masses) > self.tol_mass) if np.any(mass_mismatches): @@ -366,7 +367,8 @@ def __init__(self, traj, reference=None, select='all', if ar.name != at.name: logger.error("{0!s:>4} {1:3d} {2!s:>3} {3!s:>3} {4:6.3f} | {5!s:>4} {6:3d} {7!s:>3} {8!s:>3} {9:6.3f}".format(ar.segid, ar.resid, ar.resname, ar.name, ar.mass, at.segid, at.resid, at.resname, at.name, at.mass)) - errmsg = "Inconsistent selections, masses differ by more than {0:f}; mis-matching atoms are shown above.".format( \ + errmsg = "Inconsistent selections, masses differ by more than" + + "{0:f}; mis-matching atoms are shown above.".format( self.tol_mass) logger.error(errmsg) raise SelectionError(errmsg) From 91ba82a7877a812c8617271bb2c259a9c5cab8f7 Mon Sep 17 00:00:00 2001 From: jdetle Date: Sat, 9 Jul 2016 21:23:50 -0700 Subject: [PATCH 6/6] Asserted everywhere, fixed error messages. --- package/MDAnalysis/analysis/rms.py | 15 ++++---- .../MDAnalysisTests/analysis/test_rms.py | 36 +++++++++++++------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/package/MDAnalysis/analysis/rms.py b/package/MDAnalysis/analysis/rms.py index 639220196de..d26130ccd7e 100644 --- a/package/MDAnalysis/analysis/rms.py +++ b/package/MDAnalysis/analysis/rms.py @@ -351,13 +351,12 @@ def __init__(self, traj, reference=None, select='all', self.ref_atoms = self.reference.select_atoms(*self.select['reference']) self.traj_atoms = self.universe.select_atoms(*self.select['mobile']) if len(self.ref_atoms) != len(self.traj_atoms): - errmsg = "Reference and trajectory atom selections do " - "not contain the same number of atoms: " - "N_ref={0:d}, N_traj={1:d}".format( - self.ref_atoms.n_atoms, - self.traj_atoms.n_atoms) + errmsg = ("Reference and trajectory atom selections do "+ + "not contain the same number of atoms: "+ + "N_ref={0:d}, N_traj={1:d}".format(self.ref_atoms.n_atoms, + self.traj_atoms.n_atoms)) logger.exception(errmsg) - raise SelectionError(errormsg) + raise SelectionError(errmsg) logger.info("RMS calculation for {0:d} atoms.".format(len(self.ref_atoms))) mass_mismatches = (np.absolute(self.ref_atoms.masses - self.traj_atoms.masses) > self.tol_mass) if np.any(mass_mismatches): @@ -367,9 +366,9 @@ def __init__(self, traj, reference=None, select='all', if ar.name != at.name: logger.error("{0!s:>4} {1:3d} {2!s:>3} {3!s:>3} {4:6.3f} | {5!s:>4} {6:3d} {7!s:>3} {8!s:>3} {9:6.3f}".format(ar.segid, ar.resid, ar.resname, ar.name, ar.mass, at.segid, at.resid, at.resname, at.name, at.mass)) - errmsg = "Inconsistent selections, masses differ by more than" + errmsg = ("Inconsistent selections, masses differ by more than" + "{0:f}; mis-matching atoms are shown above.".format( - self.tol_mass) + self.tol_mass)) logger.error(errmsg) raise SelectionError(errmsg) del mass_mismatches diff --git a/testsuite/MDAnalysisTests/analysis/test_rms.py b/testsuite/MDAnalysisTests/analysis/test_rms.py index 227bd804b7d..8034b28870a 100644 --- a/testsuite/MDAnalysisTests/analysis/test_rms.py +++ b/testsuite/MDAnalysisTests/analysis/test_rms.py @@ -21,7 +21,9 @@ import MDAnalysis as mda from MDAnalysis.analysis import rms, align -from numpy.testing import TestCase, assert_almost_equal, raises, assert_ +from numpy.testing import (TestCase, assert_almost_equal, raises, assert_, + assert_array_almost_equal) + import numpy as np import os @@ -133,7 +135,11 @@ class TestRMSD(object): def setUp(self): self.universe = MDAnalysis.Universe(PSF, DCD) self.tempdir = tempdir.TempDir() - self.outfile = os.path.join(self.tempdir.name, 'rmsd.npy') + self.outfile = os.path.join(self.tempdir.name, 'rmsd.txt') + self.correct_values = [[0, 0, 0], [49, 48.9999, 4.68953]] + self.correct_values_group = [[0 , 0, 0, 0, 0], + [49, 48.9999, 4.7857, 4.7002, + 4.68981]] def tearDown(self): del self.universe @@ -142,29 +148,37 @@ def tearDown(self): def test_rmsd(self): RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') RMSD.run(step=49) - correct_values = [[ 0, 0, 0], - [ 49, 48.9999, 4.68953]] - assert_almost_equal(RMSD.rmsd, correct_values, 4, - err_msg="error: rmsd profile should match test " + - "values") - + assert_array_almost_equal(RMSD.rmsd, self.correct_values, 4, + err_msg="error: rmsd 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) - + single_frame = [[ 5, 5, 0.91544906]] + assert_array_almost_equal(RMSD.rmsd, single_frame, 4, + err_msg="error: rmsd profile should match" + + "test values") def test_mass_weighted_and_save(self): RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, select='name CA') RMSD.run(step=49, mass_weighted= True) - RMSD.save() - + RMSD.save(self.outfile) + saved = np.loadtxt(self.outfile) + assert_array_almost_equal(RMSD.rmsd, saved, 4, + err_msg="error: rmsd profile should match " + + "test values") + def test_rmsd_group_selections(self): RMSD = MDAnalysis.analysis.rms.RMSD(self.universe, groupselections= ['backbone','name CA']) RMSD.run(step=49) + assert_array_almost_equal(RMSD.rmsd, self.correct_values_group, 4, + err_msg="error: rmsd profile should match" + + "test values") + @raises(SelectionError) def test_ref_length_unequal_len(self):