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)
Example #4
0
    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)])
Example #5
0
    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)])
Example #6
0
import numpy as np

try:
    import sander
    traj = pt.iterload("./data/Ala3/Ala3.crd", "./data/Ala3/Ala3.top")

    print(traj.n_atoms, traj.top.n_residues)
    print(pt.multidihedral(traj).to_dict())

    t0 = traj[:1]
    deg_ene = []

    flist = []

    for deg in range(-180, 180, 5):
        pt.rotate_dihedral(t0, "custom:3:omega:" + str(deg))

        flist.append(t0[0].copy())

        en = pt.energy_decomposition(t0, igb=8,
                                     prmtop=traj.top.filename)['dihedral'][0]
        deg_ene.append((deg, en))

    arr = np.array(deg_ene).T

    pt.write_traj("test.pdb",
                  flist,
                  top=traj.top,
                  overwrite=True,
                  options='model')
print(traj.n_atoms, traj.top.n_residues)
print(pt.multidihedral(traj).to_dict())

t0 = traj[:1]
deg_ene = []

flist = []

try:
    import sander
    import parmed
    # scan from -180 to 180, every 5 deg
    # calculate dihedral energy for each conformation
    #
    for deg in range(-180, 180, 5):
        pt.rotate_dihedral(t0, "custom:3:omega:" + str(deg))

        flist.append(t0[0].copy())

        en = pt.energy_decomposition(t0,
                                     igb=8,
                                     verbose=False,
                                     parm=traj.top.filename)['dihedral'][0]
        print(deg, en)
        deg_ene.append((deg, en))

    arr = np.array(deg_ene).T

    print(len(flist))

    # write multiple pdb to a single file to visualize
traj = pt.iterload("../tests/data/Tc5b.x", "../tests/data/Tc5b.top")

# for example you're only interested in a single Frame
# let's load it to memory
frame = traj[1]
print(frame)

# now you want to rotate omega dihedral angle for residue 3?

# make a list to store new frames
framelist = []

for deg in range(-180, 180, 5):
    # since Frame does not hold Topology information, you need to
    # pass it
    pt.rotate_dihedral(frame, '3:omega:' + str(deg), top=traj.top)
    # always make a copy since
    # the `rotate_dihedral` inplace-change coords of frame
    framelist.append(frame.copy())

# write multiple pdbs to a single file
# just like multiple pdbs when you load from rcsb
# you can use this pdb file to view in VMD without loading
# prmtop/gro/psf/...

pt.write_traj("./output/test0.pdb",
              framelist,
              top=traj.top,
              options='model',
              overwrite=True)
traj = pt.iterload("../tests/data/Tc5b.x", "../tests/data/Tc5b.top")

# for example you're only interested in a single Frame
# let's load it to memory
frame = traj[1]
print(frame)

# now you want to rotate omega dihedral angle for residue 3?

# make a list to store new frames
framelist = []

for deg in range(-180, 180, 5):
    # since Frame does not hold Topology information, you need to
    # pass it
    pt.rotate_dihedral(frame, '3:omega:' + str(deg), top=traj.top)
    # always make a copy since
    # the `rotate_dihedral` inplace-change coords of frame
    framelist.append(frame.copy())

# write multiple pdbs to a single file
# just like multiple pdbs when you load from rcsb
# you can use this pdb file to view in VMD without loading
# prmtop/gro/psf/...

pt.write_traj("./output/test0.pdb", framelist,
              top=traj.top,
              options='model',
              overwrite=True)

# you can use VMD to open the new file