def test_load_samples(self): traj = pt.load_sample_data()[:] assert isinstance(traj, pt.Trajectory) == True assert traj.top.n_atoms == 34 assert traj.shape == (1, 34, 3) traj2 = pt.load_sample_data() assert isinstance(traj2, pt.TrajectoryIterator) == True assert traj2.top.n_atoms == 34 assert traj2.shape == (1, 34, 3) aa_eq(traj.xyz, traj2.xyz)
def test_join(self): # need to create traj0, traj1 to keep lifetime of t0, t1 traj0 = pt.load_sample_data() t0 = traj0.top traj1 = pt.load_sample_data('tz2') t1 = traj1.top # + t2 = t0 + t1 # mimic ParmEd assert t2.n_atoms == t0.n_atoms + t1.n_atoms t0 += t1 assert t0.n_atoms == t2.n_atoms
def get_remd_fn(txt): """ >>> fnlist, tn = get_remd_fn('remd_ala2') """ from pytraj import load_sample_data traj = load_sample_data(txt) return traj.filelist, traj.top.filename
def test_action_grid(self): from pytraj.all_actions import grid traj = pt.load_sample_data("tz2")[:] traj.autoimage() traj.rmsfit(mask=':1-13') d = grid(traj, " 20 0.5 20 0.5 20 0.5 :WAT@O") d = grid(traj(), " 20 0.5 20 0.5 20 0.5 :WAT@O", top=traj.top)
def test_single_frame(): traj = pt.load_sample_data('tz2') frame = pt.io.load_frame(traj.filename, traj.top.filename, 3) aa_eq(traj[3].xyz, frame.xyz) with pytest.raises(RuntimeError): pt.io.load_frame('afddsfdsfa', traj.top.filename, 3) with pytest.raises(RuntimeError): pt.io.load_frame(filename='afddsfdsfa', top=traj.top.filename, index=3)
def test_loading(self): traj = pt.load_sample_data('tz2') traj[:] traj[:3] # load from a list of files fname = traj.filename t0 = pt.iterload([fname, fname], traj.top, frame_slice=[(0, 8, 2), ] * 2)
def test_single_frame(self): traj = pt.load_sample_data('tz2') frame = pt.io.load_frame(traj.filename, traj.top.filename, 3) aa_eq(traj[3].xyz, frame.xyz) self.assertRaises( RuntimeError, lambda: pt.io.load_frame('afddsfdsfa', traj.top.filename, 3)) self.assertRaises( RuntimeError, lambda: pt.io.load_frame( filename='afddsfdsfa', top=traj.top.filename, index=3))
def test_loading(self): traj = pt.load_sample_data('tz2') traj[:] traj[:3] # load from a list of files fname = traj.filename t0 = pt.iterload([fname, fname], traj.top, frame_slice=[ (0, 8, 2), ] * 2)
def get_fn(txt): '''get absolute path for trajectory and topology samples. Legit text = 'ala3', 'tz2', 'rna'. Mostly for testing purpose. Examples -------- >>> # get trajectory file name >>> fname = get_fn('tz2')[0] >>> fname.split('/')[-1] 'tz2.ortho.nc' ''' from pytraj import load_sample_data traj = load_sample_data(txt) return traj.filename, traj.top.filename
def set_xyz_not_same_n_atoms(): traj1 = pt.load_sample_data('ala3') t0.xyz = traj1.xyz
# that stops travis import pytraj as pt from utils import fn from memory_profiler import profile traj = pt.load_sample_data('tz2') # make fake large trajectory from 10 frames for _ in range(9): traj.load(traj.filelist) @profile def test_iterchunk(chunksize=100): for chunk in traj.iterchunk(chunksize=chunksize): pass test_iterchunk(chunksize=100)
def append_2d(): traj1 = pt.load_sample_data('ala3') t0.append_xyz(pt.tools.as_2darray(traj))
def setUp(self): self.traj = pt.load_sample_data('tz2')
def test_velocity_and_force(self): traj = pt.load_sample_data('ala3') assert not traj[0].has_force(), 'does not have force' assert not traj[0].has_velocity(), 'does not have force' assert traj[0].force is None, 'force must be None' assert traj[0].velocity is None, 'velocity is None'
# that stops travis import os import pytraj as pt from numpy import max from memory_profiler import profile, memory_usage from glob import glob traj0 = pt.load_sample_data('tz2') # make fake large trajectory from 10 frames for _ in range(9): traj0.load(traj0.filelist) tlist = [traj0, ] if os.path.exists("./data/nogit/remd/myparm.parm7"): tlist.append(pt.iterload( glob("./data/nogit/remd/remd.x.*")[:10], "./data/nogit/remd/myparm.parm7")) for traj in tlist[:1]: print(traj) print(traj._estimated_GB) @profile def test_pairwise_rmsd(): pt.pairwise_rmsd(traj(stop=1000), mask='@CA') @profile def test_write(): pt.write_traj('test.nc', traj,
def append_2d(): pt.load_sample_data('ala3')
def test_4_trajiter(self): traj = pt.load_sample_data("tz2") for idx, (f0, f1) in enumerate(zip(traj, traj)): f0.rmsd(f1)
def append_2d(): pt.load_sample_data('ala3') t0.append_xyz(pt.tools.as_2darray(traj))
def append_2d(): traj1 = pt.load_sample_data('ala3')