Ejemplo n.º 1
0
    def test_general(self):
        traj = pt.iterload(fn('Tc5b.x'), fn('Tc5b.top'))
        fa = traj[:]
        mask = ':1@CA :14@CB'
        d0 = pt.distance(traj, mask)
        d1 = pt.distance(traj, mask)
        d2 = pt.distance(fa, mask)

        aa_eq(d0, d1)
        aa_eq(d0, d2)

        Nsize = 12
        arr = np.random.randint(0, 300, size=Nsize * 2).reshape(Nsize, 2)
        d3 = pt.distance(fa, arr)
        d4 = pt.distance(traj, arr)
        d5 = pt.distance(traj, arr)
        d6 = pt.distance(fa, arr)
        d7 = pt.distance([fa, traj], arr, n_frames=2 * fa.n_frames)
        d8 = pt.distance([fa, traj],
                         arr,
                         n_frames=2 * fa.n_frames,
                         dtype='dataset')
        aa_eq(d3, d4)
        aa_eq(d3, d5)
        aa_eq(d3, d6)
        aa_eq(d3.T, d7.T[:fa.n_frames])
        aa_eq(d3.T, d7.T[fa.n_frames:])
        aa_eq(d7, d8.values)

        # raise
        with pytest.raises(ValueError):
            pt.dihedrals(traj, [[0, 3, 2]])
Ejemplo n.º 2
0
    def test_dihedral(self):
        import numpy as np
        traj = pt.iterload(fn('Tc5b.x'), fn('Tc5b.top'))
        fa = traj[:]
        mask = ':2@CA :14@CA :15@CA :16@CA'
        txt = '''
        parm {}
        trajin {}
        dihedral {}
        '''.format(tc5b_top, tc5b_trajin, mask)
        d0 = pt.dihedral(traj, mask, dtype='dataset').to_ndarray()
        d1 = pt.dihedral(traj, mask)
        d2 = pt.calc_dihedral(fa, mask)
        state = pt.load_cpptraj_state(txt)
        state.run()
        dcpp = state.data[1:].values

        aa_eq(d0, d1)
        aa_eq(d0, d2)
        aa_eq(d0, dcpp)

        Nsize = 10
        np.random.seed(1)
        arr = np.random.randint(0, 300, size=Nsize * 4).reshape(Nsize, 4)
        d3 = pt.calc_dihedral(fa, arr)
        d4 = pt.dihedral(traj, arr)
        d5 = pt.dihedral(traj, arr)
        d6 = pt.dihedral(fa, arr)
        d7 = pt.dihedral([fa, traj], arr, n_frames=2 * fa.n_frames)
        aa_eq(d3, d4)
        aa_eq(d3, d5)
        aa_eq(d3, d6)
        aa_eq(d3.T, d7.T[:fa.n_frames])
        aa_eq(d3.T, d7.T[fa.n_frames:])

        d8 = pt.dihedral(traj, mask, dtype='dataset')
        d9 = pt.tools.dict_to_ndarray(pt.dihedral(traj, mask, dtype='dict'))
        aa_eq(d0, d8.values)
        aa_eq([d0], d9)

        # raise
        with pytest.raises(ValueError):
            pt.dihedrals(traj, [[0, 3, 2]])
Ejemplo n.º 3
0
    def test_dihedral(self):
        import numpy as np
        traj = mdio.iterload("./data/Tc5b.x", "./data/Tc5b.top")
        fa = traj[:]
        mask = ':2@CA :14@CA :15@CA :16@CA'
        txt = '''
        parm ./data/Tc5b.top
        trajin ./data/Tc5b.x
        dihedral %s
        ''' % mask
        d0 = pt.dihedral(traj, mask, dtype='dataset').to_ndarray()
        d1 = pt.dihedral(traj, mask)
        d2 = pt.calc_dihedral(fa, mask)
        state = pt.load_cpptraj_state(txt)
        state.run()
        dcpp = state.data[1:].values

        aa_eq(d0, d1)
        aa_eq(d0, d2)
        aa_eq(d0, dcpp)

        Nsize = 10
        np.random.seed(1)
        arr = np.random.randint(0, 300, size=Nsize * 4).reshape(Nsize, 4)
        d3 = pt.calc_dihedral(fa, arr)
        d4 = pt.dihedral(traj, arr)
        d5 = pt.dihedral(traj, arr)
        d6 = pt.dihedral(fa, arr)
        d7 = pt.dihedral([fa, traj], arr, n_frames=2 * fa.n_frames)
        aa_eq(d3, d4)
        aa_eq(d3, d5)
        aa_eq(d3, d6)
        aa_eq(d3.T, d7.T[:fa.n_frames])
        aa_eq(d3.T, d7.T[fa.n_frames:])

        d8 = pt.dihedral(traj, mask, dtype='dataset')
        d9 = pt.tools.dict_to_ndarray(pt.dihedral(traj, mask, dtype='dict'))
        aa_eq(d0, d8.values)
        aa_eq(d0, d9)

        # raise
        self.assertRaises(ValueError, lambda: pt.dihedrals(traj, [[0, 3, 2]]))