def test_compute_at_cpptraj_level(self): from pytraj.testing import get_fn fn, tn = get_fn('tz2') # ortho traj_on_disk0 = pt.iterload([ fn, ] * 2, tn) traj_on_disk1 = pt.iterload([ fn, ] * 2, tn) traj_on_mem = pt.load([ fn, ] * 2, tn) traj_on_mem2 = pt.load([ fn, ] * 2, tn) traj_on_disk0.autoimage().superpose() traj_on_disk1.autoimage().superpose() traj_on_mem.autoimage().superpose() aa_eq(traj_on_disk0.xyz, traj_on_disk1.xyz) aa_eq(traj_on_disk0.xyz, traj_on_mem.xyz) data0 = pt.rmsd(traj_on_disk0, mask='@CA', ref=0, nofit=True) data1 = pt.compute(['rms @CA first nofit'], traj_on_disk1)['RMSD_00000'] data2 = pt.rmsd(traj_on_mem, mask='@CA', ref=0, nofit=True) aa_eq(data0, data2) aa_eq(data0, data1)
def test_pytraj_do(): traj = pt.iterload(fn("tz2.nc"), fn("tz2.parm7")) ref0 = pt.autoimage(traj[0], top=traj.top) ref1 = pt.autoimage(traj[1], top=traj.top) data = pt.tools.dict_to_ndarray(pt.compute( ['autoimage', 'radgyr nomax @CA', 'rms refindex 0', 'rms refindex 1'], traj, ref=[ref0, ref1])) t0 = pt.autoimage(traj[:]) aa_eq(pt.radgyr(t0, '@CA'), data[0]) aa_eq(pt.rmsd(t0, ref=ref0), data[1]) aa_eq(pt.rmsd(t0, ref=ref1), data[2]) aa_eq(pt.compute(pt.radgyr, t0, '@CA'), data[0])
def test_pytraj_do(self): traj = pt.iterload("./data/tz2.nc", "./data/tz2.parm7") ref0 = pt.autoimage(traj[0], top=traj.top) ref1 = pt.autoimage(traj[1], top=traj.top) data = pt.tools.dict_to_ndarray(pt.compute( ['autoimage', 'radgyr nomax @CA', 'rms refindex 0', 'rms refindex 1'], traj, ref=[ref0, ref1])) t0 = pt.autoimage(traj[:]) aa_eq(pt.radgyr(t0, '@CA'), data[0]) aa_eq(pt.rmsd(t0, ref=ref0), data[1]) aa_eq(pt.rmsd(t0, ref=ref1), data[2]) # pytraj's method aa_eq(pt.compute(pt.radgyr, t0, '@CA'), data[0])
def test_nativecontacts(tmpdir): with tmpdir.as_cwd(): traj_fname = fn('DPDP.nc') top_fname = fn('DPDP.parm7') traj = pt.iterload(traj_fname, top_fname) c_raw = pt.compute( """ nativecontacts name NC3 :1-21&!@H= byresidue out nc.all.res.dat distance 3.0 """, traj) data = pt.nativecontacts(traj, mask=':1-21&!@H=', byres=True, distance=3.0, options='name NC3', dtype='dict') print(c_raw, data) aa_eq(c_raw['NC3[native]'], data['NC3[native]'])
import pytraj as pt refname = '../tests/data/Tc5b.nat.inpcrd' fn = '../tests/data/Tc5b.x' prmtop = '../tests/data/Tc5b.prmtop' traj = pt.iterload(fn, top=prmtop) ref = pt.iterload(refname, top=prmtop) cm = """ rms reference @CA distance :3 :7 angle :3 :8 :12 multidihedral phi psi molsurf @CA """ # need to specify ref=ref # TODO: reflist data = pt.compute(cm, traj, ref=ref) print(data)
def test_raising_error(self): traj = pt.datafiles.load_tz2() with pytest.raises(ValueError, match="ERROR: radgyr myrms @CA nomax"): pt.compute(['rms myrms @CA','radgyr myrms @CA nomax'], traj)