예제 #1
0
    def test_0(self):
        atm = AtomMask("@CA")
        assert atm.n_atoms == 0
        top = pt.load_topology("./data/Tc5b.top")
        top.set_integer_mask(atm)
        assert atm.n_atoms == 20
        top2 = top._modify_state_by_mask(atm)
        assert top2.n_atoms == 20
        for atom in top2:
            assert atom.name == 'CA'

        atm.invert_mask()
        top3 = top._modify_state_by_mask(atm)
        assert top3.n_atoms == top.n_atoms - 20
예제 #2
0
    def test_0(self):
        atm = AtomMask("@CA")
        assert atm.n_atoms == 0
        top = pt.load_topology(fn('Tc5b.top'))
        top._set_integer_mask(atm)
        assert atm.n_atoms == 20
        top2 = top._modify_state_by_mask(atm)
        assert top2.n_atoms == 20
        for atom in top2:
            assert atom.name == 'CA'

        atm.invert_mask()
        top3 = top._modify_state_by_mask(atm)
        assert top3.n_atoms == top.n_atoms - 20
예제 #3
0
    def test_6_speed(self):
        import numpy as np
        from pytraj import AtomMask
        # test constructor from list/array/python array
        top = pt.load_topology(fn('DOPC.parm7'))
        indices = top.select(":WAT")

        atm1 = AtomMask(indices)
        atm2 = AtomMask(list(indices))
        atm3 = AtomMask(np.asarray(indices))
        # use max_atoms
        atm4 = AtomMask(np.asarray(indices), 1000)

        import numpy as np
        assert np.all(atm1.indices == atm2.indices)
        assert np.all(atm3.indices == atm4.indices)
예제 #4
0
    def test_4(self):
        from array import array
        atm = AtomMask()
        indices = array('i', range(100))
        atm.add_selected_indices(indices)
        assert_almost_equal(indices, atm.selected_indices())
        assert_almost_equal(indices, atm.indices)

        # test list
        atm2 = AtomMask(list(indices))
        assert_almost_equal(indices, atm2.indices)

        # test range
        r100 = range(100)
        atm3 = AtomMask(range(100))
        assert_almost_equal(indices, atm3.indices)
예제 #5
0
    def test_4(self):
        from array import array
        atm = AtomMask()
        indices = array('i', range(100))
        atm.add_selected_indices(indices)
        assert_almost_equal(indices, atm.selected_indices())
        assert_almost_equal(indices, atm.indices)

        # test list
        atm2 = AtomMask(list(indices))
        assert_almost_equal(indices, atm2.indices)

        # test range
        range(100)
        atm3 = AtomMask(range(100))
        assert_almost_equal(indices, atm3.indices)
예제 #6
0
    def test_rmsd_with_mask(self):
        TRAJ = pt.iterload(filename=tc5b_trajin, top=tc5b_top)
        cpptraj_rmsd = np.loadtxt(fn("rmsd_to_firstFrame_CA_allres.Tc5b.dat"),
                                  skiprows=1).transpose()[1]
        f0 = TRAJ[0]
        arr0 = np.zeros(TRAJ.n_frames)
        arr1 = np.zeros(TRAJ.n_frames)
        mask = "@CA"
        atm = AtomMask(mask)
        TRAJ.top._set_integer_mask(atm)

        for i, frame in enumerate(TRAJ):
            arr0[i] = frame.rmsd(f0, mask=mask, top=TRAJ.top)
            arr1[i] = frame.rmsd(f0, atommask=atm)

        arr2 = pt.rmsd(TRAJ, mask=mask, ref=f0)
        arr3 = pt.rmsd(TRAJ, mask=mask, ref=0)
        aa_eq(arr0, cpptraj_rmsd, decimal=3)
        aa_eq(arr1, cpptraj_rmsd, decimal=3)
        aa_eq(arr2, cpptraj_rmsd, decimal=3)
        aa_eq(arr3, cpptraj_rmsd, decimal=3)
예제 #7
0
 def test_3_indexing(self):
     top = pt.load_topology(fn('Tc5b.top'))
     atm = AtomMask("@CA")
     top._set_integer_mask(atm)
예제 #8
0
 def test_1(self):
     atm = AtomMask(10)
     assert atm.n_atoms == 1
예제 #9
0
 def test_3_indexing(self):
     top = pt.load_topology("./data/Tc5b.top")
     atm = AtomMask("@CA")
     top.set_integer_mask(atm)