def test_2(self): traj = pt.iterload(fn('Tc5b.nat.crd'), fn('Tc5b.top')) t0 = traj[:1] pt.set_dihedral(t0, resid='4', dihedral_type='phi', deg=120) dih = pt.calc_phi(t0, resrange='4').values[0] assert abs(dih - 120) < 1E-3 t0.save('test.pdb', options='model', overwrite=True)
def test_2(self): traj = pt.iterload("./data/Tc5b.nat.crd", "./data/Tc5b.top") t0 = traj[:1] pt.set_dihedral(t0, resid='4', dihedral_type='phi', deg=120) dih = pt.calc_phi(t0, resrange='4').values[0] assert abs(dih - 120) < 1E-3 t0.save('test.pdb', options='model', overwrite=True)
def test_1(self): dslist0 = pt.calc_phi(traj) dslist1 = pt.calc_psi(traj) dslist2 = pt.search_hbonds(traj) self.assertRaises(KeyError, lambda: stack((dslist0, dslist1))) self.assertRaises(TypeError, lambda: stack((dslist0, dslist2))) stack((dslist0 for _ in range(3)))
def test_1(self): dslist0 = pt.calc_phi(traj) dslist1 = pt.calc_psi(traj) dslist2 = pt.search_hbonds(traj) self.assertRaises(KeyError, lambda: stack((dslist0, dslist1))) self.assertRaises(TypeError, lambda: stack((dslist0, dslist2))) stack((dslist0 for _ in range(3)))
def test_1(self): dslist0 = pt.calc_phi(traj) dslist1 = pt.calc_psi(traj) dslist2 = pt.search_hbonds(traj) with pytest.raises(KeyError): stack((dslist0, dslist1)) with pytest.raises(TypeError): stack((dslist0, dslist2)) stack((dslist0 for _ in range(3)))
def test_0(self): traj = pt.iterload("./data/Tc5b.x", "./data/Tc5b.top") # convert to mutable traj t0 = traj[:1] for deg in range(-170, 170, 10): pt.rotate_dihedral(t0, "custom:3:phi:" + str(deg)) _deg = pt.calc_phi(t0, '3', dtype='ndarray')[0] dih = pt.dihedral(t0, ':2@C :3@N :3@CA :3@C')[0] aa_eq(deg, _deg) aa_eq(deg, dih) aa_eq(pt.calc_psi(traj[:1]).values, pt.calc_psi(t0).values)
def test_0(self): traj = pt.iterload(fn('Tc5b.x'), fn('Tc5b.top')) # convert to mutable traj t0 = traj[:1] for deg in range(-170, 170, 10): pt.rotate_dihedral(t0, "custom:3:phi:" + str(deg)) _deg = pt.calc_phi(t0, '3', dtype='ndarray')[0] dih = pt.dihedral(t0, ':2@C :3@N :3@CA :3@C')[0] aa_eq(deg, _deg) aa_eq(deg, dih) aa_eq(pt.calc_psi(traj[:1]).values, pt.calc_psi(t0).values)
def test_1(self): # different from test_0 a bit in `mask` traj = pt.iterload("./data/Tc5b.x", "./data/Tc5b.top") # convert to mutable traj t0 = traj[:1] for deg in range(-170, 170, 10): pt.rotate_dihedral(t0, "3:phi:" + str(deg)) _deg = pt.calc_phi(t0, '3', dtype='ndarray')[0] dih = pt.dihedral(t0, ':2@C :3@N :3@CA :3@C')[0] aa_eq(deg, _deg) aa_eq(deg, dih) aa_eq(pt.calc_psi(traj[:1]).values, pt.calc_psi(t0).values)
def test_autoimage_rotatedihedral(self): traj = pt.iterload(fn('tz2.ortho.nc'), fn('tz2.ortho.parm7')) farray = traj[:] t0trajectory = pt.Trajectory(traj) aa_eq(farray.unitcells, t0trajectory.unitcells) # autoimage farray.autoimage() t0trajectory.autoimage() aa_eq(farray.xyz, t0trajectory.xyz) # rotate_dihedral pt.rotate_dihedral(t0trajectory, '3:phi:120') pt.rotate_dihedral(farray, '3:phi:120') aa_eq(farray.xyz, t0trajectory.xyz) aa_eq( pt.calc_phi(t0trajectory, '3').values, [120 for _ in range(t0trajectory.n_frames)])
def test_autoimage_rotatedihedral(self): traj = pt.iterload("./data/tz2.ortho.nc", "./data/tz2.ortho.parm7") farray = traj[:] t0trajectory = pt.Trajectory(traj) aa_eq(farray.unitcells, t0trajectory.unitcells) # autoimage farray.autoimage() t0trajectory.autoimage() aa_eq(farray.xyz, t0trajectory.xyz) # rotate_dihedral pt.rotate_dihedral(t0trajectory, '3:phi:120') pt.rotate_dihedral(farray, '3:phi:120') aa_eq(farray.xyz, t0trajectory.xyz) aa_eq( pt.calc_phi(t0trajectory, '3').values, [120 for _ in range(t0trajectory.n_frames)])
import pytraj as pt # use iterload for memory saving traj = pt.iterload("../tests/data/Tc5b.x", "../tests/data/Tc5b.top") # calculate phi residue 3 dset = pt.calc_phi(traj, resrange='3-7') # calcuate autocorrelation function for 1st dataset af = pt.acorr(dset[0]) print(af)