Skip to content

Commit

Permalink
Added tests for RMSD, added a testfile.
Browse files Browse the repository at this point in the history
Changed RMSD class to save rmsd array as numpy file instead of text.
  • Loading branch information
jdetle committed Jul 8, 2016
1 parent c868ed2 commit f051b47
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 26 additions & 2 deletions testsuite/MDAnalysisTests/analysis/test_rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit f051b47

Please sign in to comment.