def test_analyze_modes(): for mask in ['@CA', '@N,CA', '@CA,H']: command = ''' matrix mwcovar name tz2 {} diagmatrix tz2 name my_modes vecs 20 modes fluct name my_modes '''.format(mask) traj = pt.iterload(fn('tz2.nc'), fn('tz2.parm7')) # cpptraj state = pt.load_cpptraj_state(command, traj) # pt._verbose() state.run() pt._verbose(False) state.run() cpp_dict = state.data[1:].to_dict() c_dslist = state.data[1:] cpp_modes = c_dslist[1] # pytraj mat = pt.matrix.mwcovar(traj, mask) indices = traj.top.select(mask) dslist = pt.matrix.diagonalize(mat, n_vecs=20, scalar_type='mwcovar', mass=traj.top.mass[indices], dtype='dataset') evecs, evals = dslist[0].eigenvectors, dslist[0].eigenvalues aa_eq(cpp_dict['tz2'], mat) aa_eq(evals, cpp_modes.eigenvalues) aa_eq(evecs, cpp_modes.eigenvectors) with pytest.raises(AssertionError): # wrong mass dslist = pt.matrix.diagonalize( mat, n_vecs=20, scalar_type='mwcovar', mass=traj.top.mass[indices].tolist() + [1], dtype='dataset') with pytest.raises(AssertionError): # mass is None dslist = pt.matrix.diagonalize(mat, n_vecs=20, scalar_type='mwcovar', mass=None, dtype='dataset') # pt._verbose() fluct = pt.analyze_modes('fluct', evecs, evals, scalar_type='mwcovar', dtype='dataset') # pt._verbose(False) p_rms = fluct['FLUCT_00001[rms]'].values c_rms = c_dslist['FLUCT_00003[rms]'].values aa_eq(p_rms, c_rms)
def test_options(self): '''specify cpptraj options ''' # restart, keep extension try: os.remove('output/test.rst7') except OSError: pass pt._verbose() self.traj_tz2_ortho[:1].save('output/test.rst7', options='keepext') pt._verbose(False) assert os.path.exists('output/test.1.rst7')
def test_extra_coverage(self): '''all kind of tests that do not belong to anywhere else ''' traj = pt.iterload(fn('tz2.nc'), fn('tz2.parm7')) # show_versions pt.show_versions() pt._verbose() pt._verbose(False) # info pt.info() pt.info('parallel') misc.parallel_info('pmap') misc.parallel_info('openmp') misc.parallel_info(None) eq([2, 3], [2, 3]) dslist = pt.multidihedral(traj) str(dslist[0])
def test_spam(): peaks_xyz = os.path.join(cpptraj_test_dir, 'Test_SPAM', 'peaks.xyz') command = """ parm {} trajin {} autoimage spam {} name SPAM cut 12.0 info spam.info out spam.dat reorder \ summary summary.dat trajout test.mdcrd onlyframes 1-2 """.format(tz2_truncoct_top, tz2_truncoct_trajin, peaks_xyz) state = pt.load_cpptraj_state(command) with tempfolder(): state.run() traj = pt.iterload(tz2_truncoct_trajin, tz2_truncoct_top) # cm = 'SPAM cut 12.0 info spam.info out spam.dat reorder summary summary.dat' cm = 'SPAM cut 12.0 reorder' pt._verbose() with tempfolder(): spam_out = pt.spam(traj, peak_file=peaks_xyz, command=cm) print(spam_out)
def test_extra_coverage(self): '''all kind of tests that do not belong to anywhere else ''' traj = pt.iterload("./data/tz2.nc", "./data/tz2.parm7") # show_versions pt.show_versions() pt._verbose() pt._verbose(False) print(version) # info pt.info() pt.info('parallel') pt.misc.parallel_info('pmap') pt.misc.parallel_info('openmp') pt.misc.parallel_info(None) eq([2, 3], [2, 3]) # raise if comparing NaN self.assertRaises(ValueError, lambda: aa_eq(np.nan, np.nan)) dslist = pt.multidihedral(traj) string_ = str(dslist[0])