def setUp(self): self.u = MDAnalysis.Universe(PDB, XTC) self.dist = diffusionmap.DistanceMatrix(self.u, select='backbone') self.dmap = diffusionmap.DiffusionMap(self.dist) self.dmap.run() self.eigvals = self.dmap.eigenvalues self.eigvects = self.dmap._eigenvectors
def test_transform(u, dmap): eigvects = dmap._eigenvectors n_eigenvectors = 4 dmap = diffusionmap.DiffusionMap(u) dmap.run() diffusion_space = dmap.transform(n_eigenvectors, 1) assert diffusion_space.shape == (eigvects.shape[0], n_eigenvectors)
def test_transform(self): self.n_eigenvectors = 4 self.dmap = diffusionmap.DiffusionMap(self.u) self.dmap.run() diffusion_space = self.dmap.transform(self.n_eigenvectors, 1) assert_equal(diffusion_space.shape, (self.eigvects.shape[0], self.n_eigenvectors))
def test_dist_weights(u): backbone = u.select_atoms('backbone') weights_atoms = np.ones(len(backbone.atoms)) dist = diffusionmap.DistanceMatrix(u, select='backbone', weights=weights_atoms) dist.run(step=3) dmap = diffusionmap.DiffusionMap(dist) dmap.run() assert_array_almost_equal(dmap.eigenvalues, [1, 1, 1, 1], 4) assert_array_almost_equal(dmap._eigenvectors, ([[0, 0, 1, 0], [0, 0, 0, 1], [-.707, -.707, 0, 0], [.707, -.707, 0, 0]]), 2)
def test_different_steps(self): self.dmap = diffusionmap.DiffusionMap(self.u, select='backbone', step=3) self.dmap.run() assert_equal(self.dmap._eigenvectors.shape, (4,4))
def test_different_steps(u): dmap = diffusionmap.DiffusionMap(u, select='backbone') dmap.run(step=3) assert dmap._eigenvectors.shape == (4, 4)
def dmap(dist): d_map = diffusionmap.DiffusionMap(dist) d_map.run() return d_map