Пример #1
0
    def test_load_and_save_0(self):
        print "test_load_and_save"
        # need to load to FrameArray to save
        traj = mdio.load(filename="./data/md1_prod.Tc5b.x",
                         top="./data/Tc5b.top")[:]
        trajiter = mdio.iterload(filename="./data/md1_prod.Tc5b.x",
                                 top="./data/Tc5b.top",
                                 chunk=100)
        print trajiter
        print traj.size

        indices = range(20, 30, 5) + [103, 78, 90, 82]
        print type(indices)
        print indices
        mdio.writetraj(filename="./output/test_io_saved_.x",
                       traj=traj[:],
                       top="./data/Tc5b.top",
                       indices=indices,
                       overwrite=True)

        # check frames
        traj2 = mdio.load(filename="./output/test_io_saved_.x",
                          top="./data/Tc5b.top")
        print "test_load_and_save_0"
        print traj2.size
        print traj2.is_empty()
        print len(indices)
        assert traj2.size == len(indices)
Пример #2
0
    def test_iterload_1(self):
        """get FrameArray"""
        print __doc__
        for i in range(1):
            print ""
            print "loop number = %s-th" % i
            genobj = iterload(filename="./data/md1_prod.Tc5b.x", top=Topology("./data/Tc5b.top"), chunk=50)
            
            farray = genobj.next()
            farray.warning = True
            # create a view of farray[0]
            frame0_0 = farray[0].copy()
            print farray
            assert farray.size == 50
            print farray[0].n_atoms
            assert farray[0].n_atoms == 304

            print "next iteration"
            farray = genobj.next()
            frame0_1 = farray[0].copy()
            print farray
            assert farray.size == 50
            print farray[0].n_atoms
            assert farray[0].n_atoms == 304

            print "make sure that we DID the iteration"
            assert frame0_0.coords != frame0_1.coords
            #print frame0_0[:10]
            print frame0_1.coords[:10]
            print frame0_0.coords[:10]
Пример #3
0
 def test_iterload_0(self):
     """get single frame"""
     genobj = iterload(filename="./data/md1_prod.Tc5b.x", top=Topology("./data/Tc5b.top"))
     
     frame0 = genobj.next()
     print frame0
     print genobj.next()
     print genobj.next()[0]
     print genobj.next().n_atoms
Пример #4
0
 def test_0(self):
     # create FrameArray from Trajing_Single
     # TODO : add more assert
     traj = mdio.iterload("./data/md1_prod.Tc5b.x",
                          "./data/Tc5b.top",
                          chunk=100).next()
     print traj
     arr0 = traj[:, :, :]
     print arr0.shape
     print type(arr0)
Пример #5
0
    def test_load_and_save_1(self):
        traj = mdio.load(filename="./data/md1_prod.Tc5b.x",
                         top="./data/Tc5b.top")
        trajiter = mdio.iterload(filename="./data/md1_prod.Tc5b.x",
                                 top="./data/Tc5b.top",
                                 chunk=100)
        print trajiter

        indices = range(20, 30, 5) + [103, 78, 90, 82]
        mdio.writetraj(filename="./output/test_io_saved.pdb",
                       traj=traj,
                       top="./data/Tc5b.top",
                       fmt='pdbfile',
                       indices=indices,
                       overwrite=True)

        # check frames
        traj = mdio.load(filename="./output/test_io_saved.pdb",
                         top="./data/Tc5b.top")
        assert traj.size == len(indices)
        assert traj.top.n_atoms == 304