示例#1
0
    def read_dcd_step(self,dcdfile,frame,**kwargs):
        '''
        This method reads a single dcd step in the Charmm/Xplor data format.
        '''
        num_fixed=0

        filepointer = dcdfile[0]
        nnatoms = dcdfile[1]
        reverseEndian = dcdfile[3]
        charmm = dcdfile[4]

        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(filepointer,tx,ty,tz,num_fixed,frame,reverseEndian,charmm)

        self._coor[0,:,0]=tx.astype(numpy.float) ; self._coor[0,:,1]=ty.astype(numpy.float) ; self._coor[0,:,2]=tz.astype(numpy.float)
	
        if len(kwargs) < 1:
            sys.stdout.write('.',)
        elif not kwargs['no_print']: 
            try:
                sys.stdout.write('.',)
            except:
                pass

        return
示例#2
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
示例#3
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
示例#4
0
文件: sasio.py 项目: madscatt/sasmol
    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
示例#5
0
文件: sasio.py 项目: ianhi/sasmol
    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
示例#6
0
文件: sasio.py 项目: madscatt/sasmol
    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
示例#7
0
i = 0

#try:
print 'reading dcd file'
start_time = time.time()
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(ifp, tx, ty, tz, num_fixed, i, reverseEndian,
                                charmm)
    read_end_time = time.time()

    sum += read_end_time - read_start_time

    x[i][:] = tx
    y[i][:] = ty
    z[i][:] = tz

end_time = time.time()
dt = end_time - start_time

print '\nread total_time = ', sum, ' time per structure = ', sum / nset
print 'total_time = ', dt, ' time per structure = ', dt / nset
print 'ratio(total time) = ', dt / sum
print 'ratio(per structure) = ', (dt / nset) / (sum / nset)
示例#8
0
i=0

#try:
print 'reading dcd file'
start_time=time.time()
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(ifp,tx,ty,tz,num_fixed,i,reverseEndian,charmm)
 	read_end_time=time.time()
	
	sum+=read_end_time-read_start_time

	x[i][:]=tx ; y[i][:]=ty ; z[i][:]=tz
	
end_time=time.time()
dt=end_time-start_time

print '\nread total_time = ',sum,' time per structure = ',sum/nset
print 'total_time = ',dt,' time per structure = ',dt/nset
print 'ratio(total time) = ',dt/sum
print 'ratio(per structure) = ',(dt/nset)/(sum/nset)