def testsuperpose_alias(self): '''testsuperpose_alias''' t0 = self.traj[:] t1 = self.traj[:] pt.transform(t0, ['superpose']) pt.transform(t1, ['rms']) aa_eq(t0.xyz, t1.xyz)
def test_transforming_trajectory(self): traj = pt.iterload(fn('tz2.ortho.nc'), fn('tz2.ortho.parm7')) t0 = traj[:] t0.transform([ 'autoimage', 'center origin', 'rotate x 30', 'scale x 1.2', 'translate x 1.3' ]) t1 = traj[:].autoimage().center('origin').rotate('x 30').scale( 'x 1.2').translate('x 1.3') aa_eq(t0.xyz, t1.xyz) t2 = traj[:] pt.transform(t2, [ 'autoimage', 'center origin', 'rotate x 30', 'scale x 1.2', 'translate x 1.3' ]) aa_eq(t1.xyz, t2.xyz) # another way t3 = traj[:] t3.autoimage().center('origin') pt.rotate(t3, 'x 30') pt.scale(t3, 'x 1.2') pt.translate(t3, 'x 1.3') aa_eq(t3.xyz, t2.xyz)
def test_transform_trajectory_iterator(self): traj0 = pt.load(fn, tn) traj1 = pt.load(fn, tn) traj2 = pt.load(fn, tn) # 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) # use API traj2.translate('x 1.2') traj2.center('origin') traj2.rotate('x 45.') aa_eq(traj0.xyz, traj2.xyz)
def test_transforming_trajectory(self): traj = pt.iterload("./data/tz2.ortho.nc", "./data/tz2.ortho.parm7") t0 = traj[:] t0.transform(['autoimage', 'center origin', 'rotate x 30', 'scale x 1.2', 'translate x 1.3']) t1 = traj[:].autoimage().center('origin').rotate('x 30').scale('x 1.2').translate('x 1.3') aa_eq(t0.xyz, t1.xyz) t2 = traj[:] pt.transform(t2, ['autoimage', 'center origin', 'rotate x 30', 'scale x 1.2', 'translate x 1.3']) aa_eq(t1.xyz, t2.xyz) # another way t3 = traj[:] t3.autoimage().center('origin') pt.rotate(t3, 'x 30') pt.scale(t3, 'x 1.2') pt.translate(t3, 'x 1.3') aa_eq(t3.xyz, t2.xyz)
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') traj2.rotate('x 45.') aa_eq(traj0.xyz, traj2.xyz) print(traj0.xyz[0, 0], traj1.xyz[0, 0], traj2.xyz[0, 0])