Ejemplo n.º 1
0
    def read_single_dcd_step(self, filename, frame):
        '''
        This method reads a single dcd step in the Charmm/Xplor data format.
	
        The method simply reads all frames up until frame and then assigns
        coordinates to the last frame (no seek option is utilizied)

        '''

        infile = dcdio.open_dcd_read(filename)
        num_fixed = 0
        result = 1

        print 'calling read dcd header'
        readheaderresult, nnatoms, nset, istart, nsavc, delta, namnf, reverseEndian, charmm = dcdio.read_dcdheader(
            infile)
        if (readheaderresult != 0):
            print 'failed to read header'
            print 'readheaderresult = ', readheaderresult

        print 'done with read dcd header'

        coor = numpy.zeros((1, nnatoms, 3), numpy.float)

        tx = numpy.zeros(nnatoms, dtype=numpy.float32)
        ty = numpy.zeros(nnatoms, dtype=numpy.float32)
        tz = numpy.zeros(nnatoms, dtype=numpy.float32)

        first = 1  # since num_fixed = 0 ; the "first" variable is inconsequential

        print 'calling read_dcdstep'
        for i in xrange(frame):
            result = dcdio.read_dcdstep(infile, tx, ty, tz, num_fixed, first,
                                        reverseEndian, charmm)

        print 'back from read_dcdstep'
        print 'result = ', result

        coor[0, :, 0] = tx.astype(numpy.float)
        coor[0, :, 1] = ty.astype(numpy.float)
        coor[0, :, 2] = tz.astype(numpy.float)

        result = dcdio.close_dcd_read(infile)
        self._coor = numpy.array(coor)

        if (result != 0):
            print 'failed to read coordinates'
            print 'result = ', result

        return
Ejemplo n.º 2
0
    def read_dcd(self, filename):
        '''
        This method reads data in the Charmm/Xplor data format.
        '''

        infile = dcdio.open_dcd_read(filename)

        nnatoms = 0
        nset = 0
        istart = 0
        nsavc = 0
        delta = 0.0
        namnf = 0
        freeindexes = []
        reverseEndian = 0
        charmm = 0

        readheaderresult, nnatoms, nset, istart, nsavc, delta, namnf, reverseEndian, charmm = dcdio.read_dcdheader(
            infile)
        coor = numpy.zeros((nset, nnatoms, 3), numpy.float)

        num_fixed = 0
        result = 1

        sum = 0.0
        for i in xrange(nset):
            print '.',
            sys.stdout.flush()
            read_start_time = time.time()
            tx = numpy.zeros(nnatoms, dtype=numpy.float32)
            ty = numpy.zeros(nnatoms, dtype=numpy.float32)
            tz = numpy.zeros(nnatoms, dtype=numpy.float32)

            result = dcdio.read_dcdstep(infile, tx, ty, tz, num_fixed, i,
                                        reverseEndian, charmm)
            read_end_time = time.time()

            sum += read_end_time - read_start_time

            coor[i, :, 0] = tx.astype(numpy.float)
            coor[i, :, 1] = ty.astype(numpy.float)
            coor[i, :, 2] = tz.astype(numpy.float)

        result = dcdio.close_dcd_read(infile)
        self._coor = numpy.array(coor)

        print

        return
Ejemplo n.º 3
0
    def read_single_dcd_step(self,filename,frame):
        '''
        This method reads a single dcd step in the Charmm/Xplor data format.
	
        The method simply reads all frames up until frame and then assigns
        coordinates to the last frame (no seek option is utilizied)

        '''

        infile=dcdio.open_dcd_read(filename)
        num_fixed=0
        result = 1

        print 'calling read dcd header'
        readheaderresult,nnatoms,nset,istart,nsavc,delta,namnf,reverseEndian,charmm=dcdio.read_dcdheader(infile)
        if(readheaderresult!=0):
            print 'failed to read header'
            print 'readheaderresult = ',readheaderresult	

        print 'done with read dcd header'

        coor=numpy.zeros((1,nnatoms,3),numpy.float)	
	
        tx=numpy.zeros(nnatoms,dtype=numpy.float32)
        ty=numpy.zeros(nnatoms,dtype=numpy.float32)
        tz=numpy.zeros(nnatoms,dtype=numpy.float32)

        first = 1  # since num_fixed = 0 ; the "first" variable is inconsequential
		
        print 'calling read_dcdstep'
        for i in xrange(frame):	
            result=dcdio.read_dcdstep(infile,tx,ty,tz,num_fixed,first,reverseEndian,charmm)

        print 'back from read_dcdstep'
        print 'result = ',result

        coor[0,:,0]=tx.astype(numpy.float) ; coor[0,:,1]=ty.astype(numpy.float) ; coor[0,:,2]=tz.astype(numpy.float)
		
        result = dcdio.close_dcd_read(infile)
        self._coor=numpy.array(coor)
	
        if(result!=0):
            print 'failed to read coordinates'	
            print 'result = ',result

        return
Ejemplo n.º 4
0
    def read_dcd(self,filename):

        '''
        This method reads data in the Charmm/Xplor data format.
        '''

        infile=dcdio.open_dcd_read(filename)

        nnatoms=0 ; nset=0 ; istart=0 ; nsavc=0 ; delta=0.0
        namnf=0 ; freeindexes=[] ; reverseEndian=0 ; charmm=0

        readheaderresult,nnatoms,nset,istart,nsavc,delta,namnf,reverseEndian,charmm=dcdio.read_dcdheader(infile)
        coor=numpy.zeros((nset,nnatoms,3),numpy.float)	
	
        num_fixed=0 
        result=1

        
        sum=0.0
        print('Reading DCD')
        for i in xrange(nset):
            sys.stdout.write('\r')
            
            eq = int(numpy.ceil(numpy.true_divide(i*100,nset*5)))
            sys.stdout.write("[{:20s}] {}/{} frames  ".format('='*eq, i+1,nset))
            sys.stdout.flush()
            read_start_time=time.time()
            tx=numpy.zeros(nnatoms,dtype=numpy.float32)
            ty=numpy.zeros(nnatoms,dtype=numpy.float32)
            tz=numpy.zeros(nnatoms,dtype=numpy.float32)
		
            result=dcdio.read_dcdstep(infile,tx,ty,tz,num_fixed,i,reverseEndian,charmm)
            read_end_time=time.time()
	
            sum+=read_end_time-read_start_time

            coor[i,:,0]=tx.astype(numpy.float) ; coor[i,:,1]=ty.astype(numpy.float) ; coor[i,:,2]=tz.astype(numpy.float)
        print	
        result = dcdio.close_dcd_read(infile)
        self._coor=numpy.array(coor)

        print

        return
Ejemplo n.º 5
0
    def open_dcd_read(self,filename):
        '''
        This method opens a file to read in the Charmm/Xplor data format.
        by calling a pre-compiled C module (dcdio).
        '''

        filepointer=dcdio.open_dcd_read(filename)

        num_fixed=0
        result = 1

        readheaderresult,nnatoms,nset,istart,nsavc,delta,namnf,reverseEndian,charmm=dcdio.read_dcdheader(filepointer)
        if(readheaderresult!=0):
            print 'failed to read header'
            print 'readheaderresult = ',readheaderresult	
	
        dcdfile = [filepointer,nnatoms,nset,reverseEndian,charmm]
	
        return dcdfile
Ejemplo n.º 6
0
    def read_dcd(self,filename):

        '''
        This method reads data in the Charmm/Xplor data format.
        '''

        infile=dcdio.open_dcd_read(filename)

        nnatoms=0 ; nset=0 ; istart=0 ; nsavc=0 ; delta=0.0
        namnf=0 ; freeindexes=[] ; reverseEndian=0 ; charmm=0

        readheaderresult,nnatoms,nset,istart,nsavc,delta,namnf,reverseEndian,charmm=dcdio.read_dcdheader(infile)
        coor=numpy.zeros((nset,nnatoms,3),numpy.float)	
	
        num_fixed=0 
        result=1

        sum=0.0
        for i in xrange(nset):
            print '.',
            sys.stdout.flush()
            read_start_time=time.time()
            tx=numpy.zeros(nnatoms,dtype=numpy.float32)
            ty=numpy.zeros(nnatoms,dtype=numpy.float32)
            tz=numpy.zeros(nnatoms,dtype=numpy.float32)
		
            result=dcdio.read_dcdstep(infile,tx,ty,tz,num_fixed,i,reverseEndian,charmm)
            read_end_time=time.time()
	
            sum+=read_end_time-read_start_time

            coor[i,:,0]=tx.astype(numpy.float) ; coor[i,:,1]=ty.astype(numpy.float) ; coor[i,:,2]=tz.astype(numpy.float)
	
        result = dcdio.close_dcd_read(infile)
        self._coor=numpy.array(coor)

        print

        return
Ejemplo n.º 7
0
    y = y + 5.0
    z = z + 5.0
    stepresult = dcdio.write_dcdstep(fp, x, y, z, blah)

end_time = time.time()

dt = end_time - start_time

print '\ntotal time = ', dt, ' time per structure = ', dt / nset

dcdio.close_dcd_write(fp)

filename = '200c.dcd'
filename = 'c7.dcd'

ifp = dcdio.open_dcd_read(filename)

nnatoms = 0
nset = 0
istart = 0
nsavc = 0
delta = 0.0
namnf = 0
freeindexes = []
reverseEndian = 0
charmm = 0

print 'nnatoms = ', nnatoms
print 'nset = ', nset
print 'freeindexes = ', freeindexes
Ejemplo n.º 8
0
     z=z+5.0
     stepresult=dcdio.write_dcdstep(fp,x,y,z,blah)

end_time=time.time()

dt=end_time-start_time

print '\ntotal time = ',dt,' time per structure = ',dt/nset

dcdio.close_dcd_write(fp)


filename='200c.dcd'
filename='c7.dcd'

ifp=dcdio.open_dcd_read(filename)

nnatoms=0 ; nset=0 ; istart=0 ; nsavc=0 ; delta=0.0
namnf=0 ; freeindexes=[] ; reverseEndian=0 ; charmm=0

print 'nnatoms = ',nnatoms
print 'nset = ',nset
print 'freeindexes = ',freeindexes

readheaderresult,nnatoms,nset,istart,nsavc,delta,namnf,reverseEndian,charmm=dcdio.read_dcdheader(ifp)

print 'read header result = ',readheaderresult

print 'nnatoms = ',nnatoms
print 'nset = ',nset
print 'istart = ',istart