コード例 #1
0
    def write_dcd(self,filename):
        '''
        This method writes data in the Charmm/Xplor data format.
        by calling a pre-compiled C module (dcdio).
        '''
		
        outfile=dcdio.open_dcd_write(filename)

        nset = self._coor[:,0,0].shape[0]
        natoms = self._coor[0,:,0].shape[0]
        istart = 0 ; nsavc = 1 ; delta = 1.0
		
        headerresult=dcdio.write_dcdheader(outfile,filename,natoms,nset,istart,nsavc,delta)

        for frame in xrange(nset):
            print ".",
            sys.stdout.flush()

            tx=self._coor[frame,:,0].astype(numpy.float32)	
            ty=self._coor[frame,:,1].astype(numpy.float32)	
            tz=self._coor[frame,:,2].astype(numpy.float32)	

            stepresult=dcdio.write_dcdstep(outfile,tx,ty,tz,frame+1)

        result = dcdio.close_dcd_write(outfile)

        return
コード例 #2
0
ファイル: file_io.py プロジェクト: hailiangzhang/zazmol
    def write_dcd_frames(self, filename, start, end):
        '''
        This method writes a single step or multiple frames
        in the Charmm/Xplor data format.
        by calling a pre-compiled C module (dcdio).
        '''

        outfile = dcdio.open_dcd_write(filename)
        nset = end - start
        natoms = self._coor[0, :, 0].shape[0]
        istart = 0
        nsavc = 1
        delta = 1.0

        headerresult = dcdio.write_dcdheader(outfile, filename, natoms, nset,
                                             istart, nsavc, delta)

        i = 0
        for frame in xrange(start, end):
            print ".",
            sys.stdout.flush()

            tx = self._coor[frame, :, 0].astype(numpy.float32)
            ty = self._coor[frame, :, 1].astype(numpy.float32)
            tz = self._coor[frame, :, 2].astype(numpy.float32)

            stepresult = dcdio.write_dcdstep(outfile, tx, ty, tz, i + 1)
            i += 1

        result = dcdio.close_dcd_write(outfile)

        return
コード例 #3
0
    def write_dcd_header(self,filepointer,nset):
        '''
        This method writes the headerfile in the Charmm/Xplor data format.
        by calling a pre-compiled C module (dcdio).
        '''
        filename=" "
        natoms = self._coor[0,:,0].shape[0]
        istart = 0 ; nsavc = 1 ; delta = 1.0
        headerresult=dcdio.write_dcdheader(filepointer,filename,natoms,nset,istart,nsavc,delta)

        return 
コード例 #4
0
ファイル: test_dcdio.py プロジェクト: dww100/sasmol
#x=[1.0,2.0,3.0] ; y=[1.0,2.0,3.0] ; z=[1.0,2.0,3.0]

x = numpy.array(x, numpy.float32)
y = numpy.array(y, numpy.float32)
z = numpy.array(z, numpy.float32)

filename = 'c7.dcd'

fp = dcdio.open_dcd_write(filename)

nset = 200
istart = 1
nsavc = 1
delta = 1.0

headerresult = dcdio.write_dcdheader(fp, filename, natoms, nset, istart, nsavc,
                                     delta)

print 'writing ' + str(nset) + ' to disk'
start_time = time.time()

for blah in range(nset):
    print ".",
    sys.stdout.flush()

    x = x + 5.0
    y = y + 5.0
    z = z + 5.0
    stepresult = dcdio.write_dcdstep(fp, x, y, z, blah)

end_time = time.time()
コード例 #5
0
ファイル: test_dcdio.py プロジェクト: ianhi/sasmol
y=A.coor()[:,1]
z=A.coor()[:,2]

#x=[1.0,2.0,3.0] ; y=[1.0,2.0,3.0] ; z=[1.0,2.0,3.0]

x=numpy.array(x,numpy.float32)
y=numpy.array(y,numpy.float32)
z=numpy.array(z,numpy.float32)

filename='c7.dcd'

fp=dcdio.open_dcd_write(filename)

nset=200; istart=1 ; nsavc=1 ; delta=1.0

headerresult=dcdio.write_dcdheader(fp,filename,natoms,nset,istart,nsavc,delta)

print 'writing '+str(nset)+' to disk'
start_time=time.time()

for blah in range(nset):
     print ".",
     sys.stdout.flush()

     x=x+5.0
     y=y+5.0
     z=z+5.0
     stepresult=dcdio.write_dcdstep(fp,x,y,z,blah)

end_time=time.time()