예제 #1
0
    def test_load_samples(self):
        traj = pt.load_sample_data()[:]
        assert isinstance(traj, pt.Trajectory) == True
        assert traj.top.n_atoms == 34
        assert traj.shape == (1, 34, 3)

        traj2 = pt.load_sample_data()
        assert isinstance(traj2, pt.TrajectoryIterator) == True
        assert traj2.top.n_atoms == 34
        assert traj2.shape == (1, 34, 3)
        aa_eq(traj.xyz, traj2.xyz)
예제 #2
0
    def test_load_samples(self):
        traj = pt.load_sample_data()[:]
        assert isinstance(traj, pt.Trajectory) == True
        assert traj.top.n_atoms == 34
        assert traj.shape == (1, 34, 3)

        traj2 = pt.load_sample_data()
        assert isinstance(traj2, pt.TrajectoryIterator) == True
        assert traj2.top.n_atoms == 34
        assert traj2.shape == (1, 34, 3)
        aa_eq(traj.xyz, traj2.xyz)
예제 #3
0
    def test_join(self):
        # need to create traj0, traj1 to keep lifetime of t0, t1
        traj0 = pt.load_sample_data()
        t0 = traj0.top
        traj1 = pt.load_sample_data('tz2')
        t1 = traj1.top

        # +
        t2 = t0 + t1  # mimic ParmEd
        assert t2.n_atoms == t0.n_atoms + t1.n_atoms

        t0 += t1
        assert t0.n_atoms == t2.n_atoms
예제 #4
0
    def test_join(self):
        # need to create traj0, traj1 to keep lifetime of t0, t1
        traj0 = pt.load_sample_data()
        t0 = traj0.top
        traj1 = pt.load_sample_data('tz2')
        t1 = traj1.top

        # +
        t2 = t0 + t1  # mimic ParmEd
        assert t2.n_atoms == t0.n_atoms + t1.n_atoms

        t0 += t1
        assert t0.n_atoms == t2.n_atoms
예제 #5
0
def get_remd_fn(txt):
    """

    >>> fnlist, tn = get_remd_fn('remd_ala2')
    """
    from pytraj import load_sample_data
    traj = load_sample_data(txt)
    return traj.filelist, traj.top.filename
예제 #6
0
    def test_action_grid(self):
        from pytraj.all_actions import grid
        traj = pt.load_sample_data("tz2")[:]
        traj.autoimage()
        traj.rmsfit(mask=':1-13')
        d = grid(traj, " 20 0.5 20 0.5 20 0.5 :WAT@O")

        d = grid(traj(), " 20 0.5 20 0.5 20 0.5 :WAT@O", top=traj.top)
예제 #7
0
def get_remd_fn(txt):
    """

    >>> fnlist, tn = get_remd_fn('remd_ala2')
    """
    from pytraj import load_sample_data
    traj = load_sample_data(txt)
    return traj.filelist, traj.top.filename
예제 #8
0
파일: test_io.py 프로젝트: recherHE/pytraj
def test_single_frame():
    traj = pt.load_sample_data('tz2')
    frame = pt.io.load_frame(traj.filename, traj.top.filename, 3)
    aa_eq(traj[3].xyz, frame.xyz)

    with pytest.raises(RuntimeError):
        pt.io.load_frame('afddsfdsfa', traj.top.filename, 3)

    with pytest.raises(RuntimeError):
        pt.io.load_frame(filename='afddsfdsfa', top=traj.top.filename, index=3)
예제 #9
0
    def test_loading(self):
        traj = pt.load_sample_data('tz2')
        traj[:]
        traj[:3]

        # load from a list of files
        fname = traj.filename
        t0 = pt.iterload([fname, fname],
                         traj.top,
                         frame_slice=[(0, 8, 2), ] * 2)
예제 #10
0
    def test_single_frame(self):
        traj = pt.load_sample_data('tz2')
        frame = pt.io.load_frame(traj.filename, traj.top.filename, 3)
        aa_eq(traj[3].xyz, frame.xyz)

        self.assertRaises(
            RuntimeError,
            lambda: pt.io.load_frame('afddsfdsfa', traj.top.filename, 3))

        self.assertRaises(
            RuntimeError, lambda: pt.io.load_frame(
                filename='afddsfdsfa', top=traj.top.filename, index=3))
예제 #11
0
    def test_loading(self):
        traj = pt.load_sample_data('tz2')
        traj[:]
        traj[:3]

        # load from a list of files
        fname = traj.filename
        t0 = pt.iterload([fname, fname],
                         traj.top,
                         frame_slice=[
                             (0, 8, 2),
                         ] * 2)
예제 #12
0
def get_fn(txt):
    '''get absolute path for trajectory and topology samples. Legit text = 'ala3', 'tz2',
    'rna'. Mostly for testing purpose.

    Examples
    --------
    >>> # get trajectory file name
    >>> fname = get_fn('tz2')[0]
    >>> fname.split('/')[-1]
    'tz2.ortho.nc'
    '''
    from pytraj import load_sample_data
    traj = load_sample_data(txt)
    return traj.filename, traj.top.filename
예제 #13
0
def get_fn(txt):
    '''get absolute path for trajectory and topology samples. Legit text = 'ala3', 'tz2',
    'rna'. Mostly for testing purpose.

    Examples
    --------
    >>> # get trajectory file name
    >>> fname = get_fn('tz2')[0]
    >>> fname.split('/')[-1]
    'tz2.ortho.nc'
    '''
    from pytraj import load_sample_data
    traj = load_sample_data(txt)
    return traj.filename, traj.top.filename
예제 #14
0
 def set_xyz_not_same_n_atoms():
     traj1 = pt.load_sample_data('ala3')
     t0.xyz = traj1.xyz
예제 #15
0
# that stops travis
import pytraj as pt
from utils import fn
from memory_profiler import profile

traj = pt.load_sample_data('tz2')
# make fake large trajectory from 10 frames
for _ in range(9):
    traj.load(traj.filelist)


@profile
def test_iterchunk(chunksize=100):
    for chunk in traj.iterchunk(chunksize=chunksize):
        pass


test_iterchunk(chunksize=100)
예제 #16
0
 def append_2d():
     traj1 = pt.load_sample_data('ala3')
     t0.append_xyz(pt.tools.as_2darray(traj))
예제 #17
0
 def setUp(self):
     self.traj = pt.load_sample_data('tz2')
예제 #18
0
 def test_velocity_and_force(self):
     traj = pt.load_sample_data('ala3')
     assert not traj[0].has_force(), 'does not have force'
     assert not traj[0].has_velocity(), 'does not have force'
     assert traj[0].force is None, 'force must be None'
     assert traj[0].velocity is None, 'velocity is None'
예제 #19
0
 def setUp(self):
     self.traj = pt.load_sample_data('tz2')
예제 #20
0
# that stops travis
import os
import pytraj as pt
from numpy import max
from memory_profiler import profile, memory_usage

from glob import glob

traj0 = pt.load_sample_data('tz2')
# make fake large trajectory from 10 frames
for _ in range(9):
    traj0.load(traj0.filelist)

tlist = [traj0, ]
if os.path.exists("./data/nogit/remd/myparm.parm7"):
    tlist.append(pt.iterload(
        glob("./data/nogit/remd/remd.x.*")[:10],
        "./data/nogit/remd/myparm.parm7"))

for traj in tlist[:1]:
    print(traj)
    print(traj._estimated_GB)

    @profile
    def test_pairwise_rmsd():
        pt.pairwise_rmsd(traj(stop=1000), mask='@CA')

    @profile
    def test_write():
        pt.write_traj('test.nc',
                      traj,
예제 #21
0
파일: test_frame.py 프로젝트: hainm/pytraj
 def test_velocity_and_force(self):
     traj = pt.load_sample_data('ala3')
     assert not traj[0].has_force(), 'does not have force'
     assert not traj[0].has_velocity(), 'does not have force'
     assert traj[0].force is None, 'force must be None'
     assert traj[0].velocity is None, 'velocity is None'
예제 #22
0
 def set_xyz_not_same_n_atoms():
     traj1 = pt.load_sample_data('ala3')
     t0.xyz = traj1.xyz
예제 #23
0
 def append_2d():
     pt.load_sample_data('ala3')
예제 #24
0
    def test_4_trajiter(self):
        traj = pt.load_sample_data("tz2")

        for idx, (f0, f1) in enumerate(zip(traj, traj)):
            f0.rmsd(f1)
예제 #25
0
 def append_2d():
     pt.load_sample_data('ala3')
     t0.append_xyz(pt.tools.as_2darray(traj))
예제 #26
0
 def append_2d():
     traj1 = pt.load_sample_data('ala3')