Example #1
0
 def assert_build(ss_type, seq=seq):
     cm = '{}:1-10'.format(ss_type)
     traj = builder.build_protein(seq, [cm])
     # traj.save('test.pdb', overwrite=True)
     pdb_fn = get_fn('builder/ala10_{}.pdb'.format(ss_type))
     saved_traj = pt.load(pdb_fn)
     aa_eq(traj.xyz, saved_traj.xyz, decimal=3)
def test_add_struture_then_trajectory():
    view = nv.show_structure_file('data/tz2.pdb')
    traj = pt.datafiles.load_trpcage()
    view.add_trajectory(traj)
    view.frame = 3
    coords = view.coordinates_dict[1].copy()
    aa_eq(coords, traj[3].xyz)
def test_sander_struct():
    fn = get_fn('4lzt_pawel/4lztabH.pdb')
    tn = get_fn('4lzt_pawel/4lztab.parm7')
    rst7 = get_fn('4lzt_pawel/4lztabH.rst7')
    s_struct = SanderStruct(tn, rst7)
    parm = pmd.load_file(tn, rst7)
    aa_eq(parm.coordinates, s_struct.parm.coordinates)
def test_normal_pdb():
    fn = get_fn('4lzt/4lzt.not_les.pdb')
    tn = get_fn('4lzt/4lzt.parm7')
    rst7 = get_fn('4lzt/4lzt.rst7')

    pdb_input = pdb.input(fn)
    symm = pdb_input.crystal_symmetry()
    pdb_hc = pdb_input.construct_hierarchy()

    phenix_coords_uc = expand_coord_to_unit_cell(pdb_hc.atoms().extract_xyz(),
                                                 symm)

    indices_dict = get_indices_convert_dict(fn)
    p2a_indices = indices_dict['p2a']
    a2p_indices = indices_dict['a2p']
    parm = pmd.load_file(tn, rst7)

    a0 = reorder_coords_phenix_to_amber(phenix_coords_uc, p2a_indices)

    # make sure phenix and amber read the same coordinates
    aa_eq(pdb_input.atoms().extract_xyz(), parm.coordinates, decimal=2)
    aa_eq(a0, parm.coordinates, decimal=2)

    # make sure the a2p_indices and p2a_indices are identical for non-LES
    indices_dict = get_indices_convert_dict_from_array(
        pdb_input.atoms().extract_xyz(), parm.coordinates)
    p2a_indices = indices_dict['p2a']
    a2p_indices = indices_dict['a2p']
    eq(a2p_indices, p2a_indices)
Example #5
0
def test_nab_arna():
    with tempfolder():
        filename = 'nuc.pdb'
        traj = builder.build_arna('AAAAAAAAAA')
        nu = pt.nastruct(traj)
        aa_eq(np.mean(nu.major[1]), [15.183,], decimal=3)
        aa_eq(np.mean(nu.minor[1]), [18.804,], decimal=3)
def test_netcdf_trajectory():
    command_refine = [
        'phenix.refine',
        get_fn('vAla3/vAla3.pdb'),
        get_fn('vAla3/vAla3.cif'),
        get_fn('vAla3/vAla3.mtz'),
        'topology_file_name={}'.format(get_fn('vAla3/vAla3.prmtop')),
        'coordinate_file_name={}'.format(get_fn('vAla3/vAla3.rst7')),
        'use_amber=True', 'wxc_scale=0.025', '--overwrite',
        'refinement.main.number_of_macro_cycles=1',
        'amber.netcdf_trajectory_file_name=hello.nc'
    ]

    n_frames = 59
    parm = pmd.load_file(get_fn('vAla3/vAla3.prmtop'))
    expected_boxes = np.array(n_frames * [
        [30., 30., 30., 90., 90., 90.],
    ],
                              dtype='f8')

    with tempfolder():
        output = subprocess.check_output(command_refine)
        traj = NetCDFTraj.open_old('hello.nc')
        print(traj.coordinates.shape)
        aa_eq(traj.box, expected_boxes)
        assert traj.coordinates.shape == (n_frames, len(parm.atoms), 3)
Example #7
0
def test_hausdorff(tmpdir):
    # with tmpdir.as_cwd():
    matrix = np.array([[1.0000, 2.2361, 3.0000, 4.1231],
                       [2.2361, 1.0000, 2.2361, 5.0000],
                       [3.0000, 2.2361, 1.0000, 4.1231],
                       [2.2361, 3.0000, 2.2361, 3.0000]])
    aa_eq(pt.hausdorff(matrix), [[3.], [3.], [2.23609996]])
Example #8
0
def test_coordinates_meta():
    from mdtraj.testing import get_fn
    fn, tn = [get_fn('frame0.pdb'),] * 2
    trajs = [pt.load(fn, tn), md.load(fn, top=tn), pmd.load_file(tn, fn)]

    N_FRAMES = trajs[0].n_frames

    from MDAnalysis import Universe
    u = Universe(tn, fn)
    trajs.append(Universe(tn, fn))

    views = [nv.show_pytraj(trajs[0]), nv.show_mdtraj(trajs[1]), nv.show_parmed(trajs[2])]
    views.append(nv.show_mdanalysis(trajs[3]))

    for index, (view, traj) in enumerate(zip(views, trajs)):
        view.frame = 3
        
        nt.assert_equal(view.trajlist[0].n_frames, N_FRAMES)
        nt.assert_equal(len(view.trajlist[0].get_coordinates_dict().keys()), N_FRAMES)

        if index in [0, 1]:
            # pytraj, mdtraj
            if index == 0:
                aa_eq(view.coordinates[0], traj.xyz[3], decimal=4)
            else:
                aa_eq(view.coordinates[0],10*traj.xyz[3], decimal=4)
            view.coordinates = traj.xyz[2]
def test_non_LES_refinement_vAla3(use_amber):
    command_refine = [
        'phenix.refine',
        get_fn('vAla3/vAla3.pdb'),
        get_fn('vAla3/vAla3.cif'),
        get_fn('vAla3/vAla3.mtz'),
        'topology_file_name={}'.format(get_fn('vAla3/vAla3.prmtop')),
        'coordinate_file_name={}'.format(get_fn('vAla3/vAla3.rst7')),
        'use_amber={}'.format(use_amber), 'wxc_scale=0.025', '--overwrite',
        'refinement.main.number_of_macro_cycles=1'
    ]

    expected_r = {
        # 'Start R-work': 0.0154, 'Start R-free': 0.0154,
        'Final R-work': 0.0066,
        'Final R-free': 0.0065
    }

    with tempfolder():
        output = subprocess.check_output(command_refine)
        for line in output.split('\n'):
            if 'Final R-work' in line:
                break
        final_r_work = float(line.split()[3].strip(','))
        final_r_free = float(line.split()[6])
        aa_eq([
            final_r_work,
        ], [
            expected_r['Final R-work'],
        ], decimal=3)
        aa_eq([
            final_r_free,
        ], [
            expected_r['Final R-free'],
        ], decimal=3)
def test_encode_and_decode():
    xyz = np.arange(100).astype('f4')
    shape = xyz.shape

    b64_str = nv.encode_base64(xyz)
    new_xyz = nv.decode_base64(b64_str, dtype='f4', shape=shape)
    aa_eq(xyz, new_xyz)
Example #11
0
def test_encode_and_decode():
    xyz = np.arange(100).astype('f4')
    shape = xyz.shape

    b64_str = nv.encode_numpy(xyz)
    new_xyz = nv.decode_base64(b64_str, dtype='f4', shape=shape)
    aa_eq(xyz, new_xyz) 
Example #12
0
def test_add_struture_then_trajectory():
    view = nv.show_structure_file(get_fn('tz2.pdb'))
    view.loaded = True
    traj = pt.datafiles.load_trpcage()
    view.add_trajectory(traj)
    view.frame = 3
    coords = view.coordinates_dict[1].copy()
    aa_eq(coords, traj[3].xyz)
    view.loaded = False
    view.add_trajectory(traj)
def test_coordinates_dict():
    traj = pt.load(nv.datafiles.TRR, nv.datafiles.PDB)
    view = nv.show_pytraj(traj)
    view.frame = 1
    coords = view.coordinates_dict[0]
    aa_eq(coords, traj[1].xyz)

    # dummy
    view._send_binary = False
    view.coordinates_dict = {0: coords}
Example #14
0
def test_add_struture_then_trajectory():
    view = nv.show_structure_file(get_fn('tz2.pdb'))
    view.loaded = True
    traj = pt.datafiles.load_trpcage()
    view.add_trajectory(traj)
    view.frame = 3
    coords = view._coordinates_dict[1].copy()
    aa_eq(coords, traj[3].xyz)
    view.loaded = False
    view.add_trajectory(traj)
Example #15
0
def test_show_htmd():
    from htmd import Molecule
    fn = nv.datafiles.PDB
    traj = Molecule(fn)
    view = nv.show_htmd(traj)
    # trigger updating cooridnates
    view.frame = 100
    index = 0
    view.frame = index
    xyz_htmd = np.squeeze(traj.coords[:, :, index])
    aa_eq(view._coordinates_dict[0], xyz_htmd)
Example #16
0
def test_show_htmd():
    from htmd import Molecule
    fn = nv.datafiles.PDB
    traj = Molecule(fn)
    view = nv.show_htmd(traj)
    # trigger updating cooridnates
    view.frame = 100
    index = 0
    view.frame = index
    xyz_htmd = np.squeeze(traj.coords[:, :, index])
    aa_eq(view.coordinates_dict[0], xyz_htmd)
def test_coordinates_dict():
    traj = pt.load(nv.datafiles.TRR, nv.datafiles.PDB)
    view = nv.show_pytraj(traj)
    view.frame = 1
    coords = view.coordinates_dict[0]
    aa_eq(coords, traj[1].xyz)

    # dummy
    view._send_binary = False
    view.coordinates_dict = {0: coords}
    # increase coverage for IndexError: make index=1000 (which is larger than n_frames)
    view._set_coordinates(1000)
Example #18
0
def test_coordinates_dict():
    traj = pt.load(nv.datafiles.TRR, nv.datafiles.PDB)
    view = nv.show_pytraj(traj)
    view.frame = 1
    coords = view.coordinates_dict[0]
    aa_eq(coords, traj[1].xyz)

    # dummy
    view._send_binary = False
    view.coordinates_dict = {0: coords}
    # increase coverage for IndexError: make index=1000 (which is larger than n_frames)
    view._set_coordinates(1000)
def test_converter_by_array():
    fn = get_fn('4lzt_pawel/4lztabH.pdb')
    tn = get_fn('4lzt_pawel/4lztab.parm7')
    rst7 = get_fn('4lzt_pawel/4lztabH.rst7')

    pdb_input = pdb.input(fn)
    parm = pmd.load_file(tn, rst7)

    symm = pdb_input.crystal_symmetry()

    # reorder
    pdb_hc = pdb_input.construct_hierarchy()

    phenix_coords_uc = expand_coord_to_unit_cell(pdb_hc.atoms().extract_xyz(),
                                                 symm)

    indices_dict = get_indices_convert_dict_from_array(phenix_coords_uc,
                                                       parm.coordinates)
    p2a_indices = indices_dict['p2a']
    a2p_indices = indices_dict['a2p']

    a0 = reorder_coords_phenix_to_amber(phenix_coords_uc, p2a_indices)

    # make sure the original pdb and rst7 have the same coordinates
    aa_eq(pdb_input.atoms().extract_xyz(), parm.coordinates, decimal=2)

    # make sure reordered coordinates is equal to original coordinates
    aa_eq(a0, parm.coordinates, decimal=2)

    # raise KeyError if provide wrong coordinates
    def make_sure_key_error_being_raised():
        phenix_coords = flex.vec3_double([
            [0., 2., 3.2],  # should be [0., 2., 3.]
            [4., 5., 6.],
            [10., 12., 13.],
            [7., 8., 9.]
        ])
        amber_coords = np.array([[10., 12., 13.], [7., 8., 9], [4., 5., 6.],
                                 [0., 2., 3.]])
        get_indices_convert_dict_from_array(phenix_coords, amber_coords)

    with pytest.raises(KeyError):
        make_sure_key_error_being_raised()
Example #20
0
def test_eneregy_and_force():
    path = os.path.dirname(__file__) 
    
    prmtop = path + '/vAla3.prmtop'
    rst7 = path + '/vAla3.rst7'
    
    with mdgx.setup(prmtop, rst7) as context:
        mdgx_energies, mdgx_forces = context.energy_forces()
        
    pme_input = sander.pme_input()
    parm = pmd.load_file(prmtop, rst7)

    with sander.setup(prmtop, rst7, box=parm.box, mm_options=pme_input):
        
        ene, sander_forces = sander.energy_forces()
        sander_enegies = dict((att, getattr(ene, att)) for att in dir(ene) if not
            att.startswith('_'))
        
    print("")
    print("potential energy")
    print("sander_enegies")
    print(sander_enegies['tot'])
    print("mdgx_energies")
    print(mdgx_energies['eptot'])
    
    print("")
    print('forces')
    print('sander_forces, first 5 atoms')
    print(sander_forces[:15])
    print("")
    print('mdgx_forces, first 5 atoms')
    print(mdgx_forces.tolist()[:15])

    aa_eq([sander_enegies['tot'],],
          [mdgx_energies['eptot'],],
          decimal=4)
Example #21
0
def test_build_nuleic_acid():
    builder = AmberBuilder()
    builder.build_bdna('GGGGGG')
    aa_eq(_compute_major_groove(builder), [17.24558067])
    aa_eq(_compute_major_groove(builder.build_adna('GGGGGG')), [15.72079277])

    # build_xxx will repalce old structure
    aa_eq(_compute_major_groove(builder.build_arna('GGGGGG')), [15.18226528])
    with tempfolder():
        pdb_out = 'out.pdb'
        builder.write_pdb(pdb_out)
        with open(pdb_out) as fh:
            assert "O2'" in fh.read()
def test_converter():
    fn = get_fn('4lzt_pawel/4lztabH.pdb')
    tn = get_fn('4lzt_pawel/4lztab.parm7')
    rst7 = get_fn('4lzt_pawel/4lztabH.rst7')

    pdb_input = pdb.input(fn)
    parm = pmd.load_file(tn, rst7)

    symm = pdb_input.crystal_symmetry()
    pdb_hc = pdb_input.construct_hierarchy()

    phenix_coords_uc = expand_coord_to_unit_cell(pdb_hc.atoms().extract_xyz(),
                                                 symm)

    indices_dict = get_indices_convert_dict(fn)
    p2a_indices = indices_dict['p2a']
    a2p_indices = indices_dict['a2p']
    # make sure two indices are not equal
    with pytest.raises(AssertionError):
        aa_eq(p2a_indices, a2p_indices)

    a0 = reorder_coords_phenix_to_amber(phenix_coords_uc, p2a_indices)
    aa_eq(pdb_input.atoms().extract_xyz(), parm.coordinates)
    aa_eq(a0, parm.coordinates)
def test_trajectory_show_hide_sending_cooridnates():
    view = NGLWidget()

    traj0 = pt.datafiles.load_tz2()
    traj1 = pt.datafiles.load_trpcage()

    view.add_trajectory(nv.PyTrajTrajectory(traj0))
    view.add_trajectory(nv.PyTrajTrajectory(traj1))

    for traj in view._trajlist:
        nt.assert_true(traj.shown)

    view.frame = 1

    def copy_coordinate_dict(view):
        # make copy to avoid memory free
        return dict((k, v.copy()) for k, v in view.coordinates_dict.items())

    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz)
    aa_eq(coordinates_dict[1], traj1[1].xyz)

    # hide 0
    view.hide([
        0,
    ])
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_true(view._trajlist[1].shown)

    # update frame so view can update its coordinates
    view.frame = 2
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    aa_eq(coordinates_dict[1], traj1[2].xyz)

    # hide 0, 1
    view.hide([0, 1])
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_false(view._trajlist[1].shown)
    view.frame = 3
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    nt.assert_equal(coordinates_dict[1].shape[0], 0)

    # slicing, show only component 1
    view[1].show()
    view.frame = 0
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_true(view._trajlist[1].shown)
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    aa_eq(coordinates_dict[1], traj1[0].xyz)

    # show all
    view[1].show()
    view[0].show()
    view.frame = 1
    nt.assert_true(view._trajlist[0].shown)
    nt.assert_true(view._trajlist[1].shown)
    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz)
    aa_eq(coordinates_dict[1], traj1[1].xyz)

    # hide all
    view[1].hide()
    view[0].hide()
    view.frame = 2
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_false(view._trajlist[1].shown)
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    nt.assert_equal(coordinates_dict[1].shape[0], 0)
Example #24
0
def test_coordinates_dict():
    traj = pt.load(nv.datafiles.TRR, nv.datafiles.PDB)
    view = nv.show_pytraj(traj)
    view.frame = 1
    coords = view.coordinates_dict[0]
    aa_eq(coords, traj[1].xyz)
def test_coordinates_dict():
    traj = pt.load(nv.datafiles.TRR, nv.datafiles.PDB)
    view = nv.show_pytraj(traj)
    view.frame = 1
    coords = view.coordinates_dict[0]
    aa_eq(coords, traj[1].xyz)
 def test_something(self):
     a = [1., 2., 4.]
     b = [1.000000000001, 2., 4.]
     aa_eq(a, b)
Example #27
0
def test_nab_bdna():
    with tempfolder():
        traj = builder.build_bdna('AAAAAAAAAA')
        nu = pt.nastruct(traj)
        aa_eq(np.mean(nu.major[1]), [17.246,], decimal=3)
        aa_eq(np.mean(nu.minor[1]), [11.459,], decimal=3)
Example #28
0
def test_trajectory_show_hide_sending_cooridnates():
    view = NGLWidget()

    traj0 = pt.datafiles.load_tz2()
    traj1 = pt.datafiles.load_trpcage()

    view.add_trajectory(nv.PyTrajTrajectory(traj0))
    view.add_trajectory(nv.PyTrajTrajectory(traj1))

    for traj in view._trajlist:
        assert traj.shown

    view.frame = 1

    def copy_coordinate_dict(view):
        # make copy to avoid memory free
        return {k: v.copy() for k, v in view._coordinates_dict.items()}

    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz)
    aa_eq(coordinates_dict[1], traj1[1].xyz)

    # hide 0
    view.hide([
        0,
    ])
    assert not view._trajlist[0].shown
    assert view._trajlist[1].shown

    # update frame so view can update its coordinates
    view.frame = 2
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    aa_eq(coordinates_dict[1], traj1[2].xyz)

    # hide 0, 1
    view.hide([0, 1])
    assert not view._trajlist[0].shown
    assert not view._trajlist[1].shown
    view.frame = 3
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    assert coordinates_dict[1].shape[0] == 0

    # slicing, show only component 1
    view[1].show()
    view.frame = 0
    assert not view._trajlist[0].shown
    assert view._trajlist[1].shown
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    aa_eq(coordinates_dict[1], traj1[0].xyz)

    # show all
    view[1].show()
    view[0].show()
    view.show(indices='all')
    view.show(indices=[
        0,
    ])
    view.show(indices=[0, 1])
    view.frame = 1
    assert view._trajlist[1].shown
    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz)
    aa_eq(coordinates_dict[1], traj1[1].xyz)

    # hide all
    view[1].hide()
    view[0].hide()
    view.frame = 2
    assert not view._trajlist[0].shown
    assert not view._trajlist[1].shown
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    assert coordinates_dict[1].shape[0] == 0
Example #29
0
        (atom.id_str(), idx) for (idx, atom) in enumerate(pdb_inp.atoms()))

    return {
        'p2a': np.array([newids[atom.id_str()] for atom in pdb_inp.atoms()]),
        'a2p':
        np.array([oldids[atom.id_str()] for atom in pdb_hierarchy.atoms()])
    }


if __name__ == '__main__':
    import parmed as pmd
    from numpy.testing import assert_almost_equal as aa_eq

    root = './test_4lzt_les/'
    fn, tn, rst7 = [
        root + filename
        for filename in ["4lztabH.pdb", "4lztab.parm7", "4lztabH.rst7"]
    ]

    pdb_input = pdb.input(fn)
    hi = pdb_input.construct_hierarchy()
    parm = pmd.load_file(tn, rst7)

    p2a_indices = get_indices_convert_dict(fn)['p2a']
    a2p_indices = get_indices_convert_dict(fn)['a2p']

    a0 = reorder_coords_phenix_to_amber(hi.atoms().extract_xyz(), p2a_indices)
    print(a0.shape)
    aa_eq(a0, parm.coordinates.flatten())
    print("OK")
Example #30
0
def test_trajectory_show_hide_sending_cooridnates():
    view = NGLWidget()

    traj0 = pt.datafiles.load_tz2()
    traj1 = pt.datafiles.load_trpcage()

    view.add_trajectory(nv.PyTrajTrajectory(traj0))
    view.add_trajectory(nv.PyTrajTrajectory(traj1))

    for traj in view._trajlist:
        assert traj.shown

    view.frame = 1

    def copy_coordinate_dict(view):
        # make copy to avoid memory free
        return dict((k, v.copy()) for k, v in view.coordinates_dict.items())

    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz) 
    aa_eq(coordinates_dict[1], traj1[1].xyz) 

    # hide 0
    view.hide([0,])
    assert not view._trajlist[0].shown
    assert view._trajlist[1].shown

    # update frame so view can update its coordinates
    view.frame = 2
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    aa_eq(coordinates_dict[1], traj1[2].xyz)

    # hide 0, 1
    view.hide([0, 1])
    assert not view._trajlist[0].shown
    assert not view._trajlist[1].shown
    view.frame = 3
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    assert coordinates_dict[1].shape[0] == 0

    # slicing, show only component 1
    view[1].show()
    view.frame = 0
    assert not view._trajlist[0].shown
    assert view._trajlist[1].shown
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    aa_eq(coordinates_dict[1], traj1[0].xyz)

    # show all
    view[1].show()
    view[0].show()
    view.show(indices='all')
    view.show(indices=[0,])
    view.show(indices=[0, 1])
    view.frame = 1
    assert view._trajlist[1].shown
    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz)
    aa_eq(coordinates_dict[1], traj1[1].xyz)

    # hide all
    view[1].hide()
    view[0].hide()
    view.frame = 2
    assert not view._trajlist[0].shown
    assert not view._trajlist[1].shown
    coordinates_dict = copy_coordinate_dict(view)
    assert coordinates_dict[0].shape[0] == 0
    assert coordinates_dict[1].shape[0] == 0
Example #31
0
def test_trajectory_show_hide_sending_cooridnates():
    view = NGLWidget()

    traj0 = pt.datafiles.load_tz2()
    traj1 = pt.datafiles.load_trpcage()

    view.add_trajectory(nv.PyTrajTrajectory(traj0))
    view.add_trajectory(nv.PyTrajTrajectory(traj1))

    for traj in view._trajlist:
        nt.assert_true(traj.shown)

    view.frame = 1

    def copy_coordinate_dict(view):
        # make copy to avoid memory free
        return dict((k, v.copy()) for k, v in view.coordinates_dict.items())

    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz) 
    aa_eq(coordinates_dict[1], traj1[1].xyz) 

    # hide 0
    view.hide([0,])
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_true(view._trajlist[1].shown)

    # update frame so view can update its coordinates
    view.frame = 2
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    aa_eq(coordinates_dict[1], traj1[2].xyz)

    # hide 0, 1
    view.hide([0, 1])
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_false(view._trajlist[1].shown)
    view.frame = 3
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    nt.assert_equal(coordinates_dict[1].shape[0], 0)

    # slicing, show only component 1
    view[1].show()
    view.frame = 0
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_true(view._trajlist[1].shown)
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    aa_eq(coordinates_dict[1], traj1[0].xyz)

    # show all
    view[1].show()
    view[0].show()
    view.frame = 1
    nt.assert_true(view._trajlist[0].shown)
    nt.assert_true(view._trajlist[1].shown)
    coordinates_dict = copy_coordinate_dict(view)
    aa_eq(coordinates_dict[0], traj0[1].xyz)
    aa_eq(coordinates_dict[1], traj1[1].xyz)

    # hide all
    view[1].hide()
    view[0].hide()
    view.frame = 2
    nt.assert_false(view._trajlist[0].shown)
    nt.assert_false(view._trajlist[1].shown)
    coordinates_dict = copy_coordinate_dict(view)
    nt.assert_equal(coordinates_dict[0].shape[0], 0)
    nt.assert_equal(coordinates_dict[1].shape[0], 0)