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_reset_dataset_that_hold_rmsd(self): from pytraj.testing import get_fn fn, tn = get_fn('tz2_dry') traj_on_disk = pt.iterload([ fn, ] * 10, tn) # 1010 frames assert traj_on_disk.n_frames == 1010 ref = traj_on_disk[:1] traj_on_disk.superpose(mask='@CA', ref=ref) traj_on_disk._max_count_to_reset = 100 for _ in range(10): for frame in traj_on_disk: pass
#!/usr/bin/env python import numpy as np import pytraj as pt from memory_profiler import profile from pytraj.testing import get_fn fn, tn = get_fn('tz2') traj = pt.iterload([ fn, ] * 100, tn) print(traj) ref = traj[:1] @profile def do_it(traj=traj, n_times=1): # memory leaking traj.superpose(ref=ref, mask='@CA') # memory not leaking # traj.autoimage().center() for _ in range(n_times): for frame in traj: pass print(traj._cdslist)
import pytraj as pt from pytraj.testing import get_fn, aa_eq fn, tn = get_fn('tz2_dry') traj0 = pt.load(fn, tn) traj1 = pt.load(fn, tn) traj2 = pt.load(fn, tn) print(traj0.xyz[0, 0], traj1.xyz[0, 0], traj2.xyz[0, 0]) # Use ActionList for traj0 actlist = pt.ActionList(top=traj0.top) actlist.add("translate", "x 1.2") actlist.add("center", "origin") actlist.add("rotate", "x 45.") for frame in traj0: actlist.compute(frame) # use transformation itertraj = pt.transform( traj1, by=['translate x 1.2', 'center origin', 'rotate x 45.']) for frame in itertraj: pass aa_eq(traj0.xyz, traj1.xyz) print(traj0.xyz[0, 0], traj1.xyz[0, 0], traj2.xyz[0, 0]) # use API traj2.translate('x 1.2') traj2.center('origin')