import numpy as np
import warnings 


warnings.filterwarnings('ignore','Warning: overflow encountered in exp')

def f( x , a, b ):
	return np.exp( - b * x )
print "Loading data"
proj = Serializer.Serializer.LoadFromHDF( options.proj_FN )

data = dataIO.readData( options.raw_FN )
data2d = msmTools.reshapeRawData( data, proj )

print "Calculating autocorrelations"
Autos = [ autocorrelate.fft_autocorrelate( trj[ np.where( trj != -1 ) ] ) for trj in data2d ]

print "Fitting the data to single exponentials"
Fits = [ curve_fit( f, np.arange( len( corr ) ), corr )[0] for corr in Autos ]

outName = '.'.join( options.out_FN.split('.')[:-1] )
Fits = np.array( Fits )
np.savetxt( outName + '.dat', Fits )


print "Plotting some fits"

indList = np.random.permutation( np.arange( len( Autos ) ) )

minLength = min( [ len( trj[ np.where( trj != -1 ) ] ) for trj in Autos ] )
xi = np.linspace(0,minLength,10000)
Esempio n. 2
0
parser = OptionParser()
parser.add_option('-f',dest='traj_FN',help='A trajectory file that GROMACS can understand.' )
parser.add_option('-s',dest='struc_FN',help='A structure file to use to define the native state. GROMACS must be able to read it.' )
parser.add_option('--uc',dest='u_cut',type=float,help='Unfolded cutoff')

options, args = parser.parse_args()
 
from numpy import *
from pyschwancr import dataIO, msmTools
from msmbuilder import autocorrelate
import os, sys, re
 
# first make the xvg.

os.system('echo "0 0" | g_rms -f %s -s %s' % ( options.traj_FN, options.struc_FN ) )

xvgIn = open( 'rmsd.xvg', 'r' )

dat = []
for line in xvgIn:
	if line[0] in [ '#', '@' ]:
		continue
	else:
		dat.append( [ float( i ) for i in line.split() ] )

dat = array( dat )

autoCorr = autocorrelate.fft_autocorrelate( dat[:,1] )

savetxt( options.traj_FN[:-4] + '_autocorr.dat', autoCorr )