Пример #1
0
    def test_modify_frame_use_Pipeline(self):
        traj = pt.iterload("data/tz2.ortho.nc", "data/tz2.ortho.parm7")
        dslist = CpptrajDatasetList()
        dslist.add_new('topology', name='mytop')

        # add a new topology
        dslist[0].data = pt.strip(traj.top, ':WAT')
        commands = ['autoimage', 'strip :WAT', 'createcrd mycrd', ]

        actlist = Pipeline(commands, top=traj.top, dslist=dslist)

        for frame in traj:
            actlist.compute(frame)

        aa_eq(dslist['mycrd'].xyz,
              pt.get_coordinates(traj,
                                 mask='!:WAT',
                                 autoimage=True))
Пример #2
0
    def test_modify_frame_use_Pipeline(self):
        traj = pt.iterload(fn("tz2.ortho.nc"), fn("tz2.ortho.parm7"))
        dslist = CpptrajDatasetList()
        dslist.add('topology', name='mytop')

        # add a new topology
        dslist[0].data = pt.strip(traj.top, ':WAT')
        commands = [
            'autoimage',
            'strip :WAT',
            'createcrd mycrd',
        ]

        actlist = Pipeline(commands, top=traj.top, dslist=dslist)

        for frame in traj:
            actlist.compute(frame)

        aa_eq(dslist['mycrd'].xyz,
              pt.get_coordinates(traj, mask='!:WAT', autoimage=True))
Пример #3
0
def strip_prmtop(prmtop, mask=":WAT,:Na+,:Cl-"):
    """Strip residues from a structure and write a new parameter file. This could probably also be done with ParmEd.

    Parameters
    ----------
    prmtop : os.PathLike
        Existing Amber parameter file.
    mask : str, optional, default=':WAT,:Na+,:Cl-'
        The list of atom masks to strip.

    Returns
    -------
    stripped: :class:`pytraj.topology`
        The stripped topology that can be used to read stripped trajectories with :class:`pytraj`.

    """

    structure = pt.load_topology(os.path.normpath(prmtop))
    stripped = pt.strip(mask, structure)
    # stripped_name = os.path.join(os.path.splitext(prmtop)[0], '-stripped', os.path.splitext(prmtop)[1])
    # stripped.save(filename=stripped_name)
    # logger.debug('Stripping {} from parameter file and writing {}...'.format(mask, stripped_name))
    return stripped
Пример #4
0
def strip_prmtop(prmtop, mask=":WAT,:Na+,:Cl-"):
    """Strip residues from a structure and write a new parameter file. This could probably also be done with ParmEd.

    Parameters:
    ----------
    prmtop : {str}
        Existing parameter file
    mask : {str}, optional
        The list of atom masks to strip (the default is [':WAT,:Na+,:Cl-'])

    Returns:
    -------
    stripped.topology
        The stripped topology that can be used to read stripped trajectories with `pytraj`

    """

    structure = pt.load_topology(os.path.normpath(prmtop))
    stripped = pt.strip(mask, structure)
    # stripped_name = os.path.join(os.path.splitext(prmtop)[0], '-stripped', os.path.splitext(prmtop)[1])
    # stripped.save(filename=stripped_name)
    # log.debug('Stripping {} from parameter file and writing {}...'.format(mask, stripped_name))
    return stripped
Пример #5
0
stop = 2950
every = 50
trajectory = '../../../1-408cent1_skip100.nc'
topology = '../../../PHYb_ff14.prmtop'
stripmask = ':505-1008,Na+'

#solvmask is the mask for the atom around which you can keep the closest waters
solvmask = ':504@CHC'
wat2keep = 390
##########################################################
##########################################################

traj = pt.iterload(trajectory, top=topology)
top = pt.load_topology(topology)

stripped_prm = pt.strip(top, mask=stripmask)
stripped_traj = pt.strip(traj, stripmask)
print stripmask, "stripped"

print "selecting closest", wat2keep, "water molecules ..."
closest_traj = pt.closest(stripped_traj,
                          mask=solvmask,
                          n_solvents=wat2keep,
                          dtype='trajectory')

# NOTE: framelist here starts from zero!
framelist = range(start - 1, stop, every)

for frame in framelist:
    # NOTE: output files have numbering starting from one!
from __future__ import print_function
from parmed.utils.netcdf import netcdf_file
import pytraj as pt
import numpy as np

fh = netcdf_file('data/mdfrc',
                 mmap=False)  # change mdfrc to your force filename
forces = fh.variables['forces']

# do similar thing for velocities

top = pt.load_topology(
    'data/mdfrc.prmtop')  # change prmtop to your parm7 filename
traj = pt.Trajectory(xyz=np.ascontiguousarray(forces[:], dtype='f8'), top=top)
print('original trajectory', traj)

# strip atom atoms
# change ':1-100' to your mask (e.g ':WAT')
new_traj = pt.strip(':1-100', traj)
print('stripped trajectory', new_traj)

# write trajectory
new_traj.save('test.nc', overwrite=True)