Beispiel #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
Beispiel #2
0
    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
Beispiel #3
0
    def open_dcd_write(self,filename):
        '''
        This method opens a file and writes the headerfile in the Charmm/Xplor data format.
        by calling a pre-compiled C module (dcdio).

        This function will OVERWRITE a file with the same name without prompting.
        '''

        filepointer=dcdio.open_dcd_write(filename)

        self.write_dcd_header(filepointer,1)

        return filepointer
Beispiel #4
0
natoms = A.natoms()

x = A.coor()[:, 0]
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()
Beispiel #5
0
natoms = A.natoms()

x=A.coor()[:,0]
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