示例#1
0
def main():
	# First read the data:

	fc = rd( options.fcFN )
	
	dataList = []
	for FN in options.dataFNs:
		temp = rd(FN)
		if len(temp.shape) !=1:
			temp = temp[:,options.dataCol]
		dataList.append( temp )

	TSind = where( (0.5-options.eps<=fc)*(fc<=0.5+options.eps) )[0]

	wd( ['TSE',str(options.eps) ], TSind )

	avgList = []
	stdList = []
#	if dataList:
#		for item in dataList:
#			avgList.append( item[TSind].mean() )
#			stdList.append( item[TSind].std() )

#	avgList = array(avgList)
#	stdList = array(stdList)

	nameFN = wd( ['TSEaverages','Names'], array(dataList) )
#	avgFN = wd( ['TSEaverages','Averages','eps-%.2f'%options.eps], avgList )
#	stdFN = wd( ['TSEaverages','StdDevs','eps-%.2f'%options.eps], stdList )

	figure()
	width = 0.5
	#bar( arange(len(avgList))+width/2., avgList,width, yerr=stdList, color='red',alpha=0.5,ecolor='black',edgecolor='black')
	boxplot( [ item[TSind] for item in dataList ] )
	barNames = [ '.'.join( thing.split('_')[-1].split('.')[:-2] ) for thing in options.dataFNs ]
	title('TSE State Averages Pfold=0.5%s %.2f' % ( u"\u00B1", options.eps) )
	ylabel('Fraction Native Contacts')
	xticks( arange(1,len(options.dataFNs)+1), barNames, rotation=60 )
	ylim([0,1])
	savefig('TSEaverages_box_eps-%.2f.pdf'%options.eps)	 
示例#2
0
def main():

	print "Reading data...",
	print " %s."% options.rawFN,
	raw = rd( options.rawFN )
	print " %s." % options.msmFN,
	msm = rd( options.msmFN )
	msm = msm[:,1] # Use the center column (This is how my data is formated.)
	print " %s." % options.AsFN,
	As = Serializer.LoadData( options.AsFN )
	print " %s." % options.projFN,
	P = Serializer.LoadFromHDF( options.projFN )
	print " %s." % options.tFN
	T = mmread( options.tFN )
	

	lens = [ ( P['TrajLengths'][i], i ) for i in range( P['TrajLengths'].shape[0] ) ]
	lens = sorted(lens,reverse=True)
	
	trajList = [ b for (a,b) in lens[:options.nTraj] ]

	rawFmt = ones( As.shape ) * -1
	tempSum = 0

	print raw.shape

	for i in range( len( P['TrajLengths'] ) ):
		rawFmt[i][ : P['TrajLengths'][i] ] = raw[ tempSum : tempSum + P['TrajLengths'][i] ]
		tempSum += P['TrajLengths'][i]

	# Generate the trajectory data:
	trajData = []
	msmData = []
	N = int( P['TrajLengths'].max() / options.lag ) + 1
	
	for traj in trajList:
		print "\nCalculating trajectory %d" % traj,
		print "Raw data.",
		trajData.append( array(rawObs( traj, P['TrajLengths'], raw ) ) )
		print "MSM Average."
		start = zeros( len(msm) )
		start[ As[ traj ][0] ] += 1
		Cor, Traj, ObsTraj = Correlation.RawMSMCorrelation( T, rawFmt, As, Steps = N, StartingState = As[ traj ][0] ) 
		msmData.append( Cor )

	# Generate the autocorrelations:
	print "Calculating the convolutions ... "
	trajCorr = [ autocorrelate.fft_autocorrelate( thing ) for thing in trajData ]
	msmCorr = [ autocorrelate.fft_autocorrelate( thing ) for thing in msmData ]
	msmCorr = [ thing for thing in msmData ]

	for i in range(1000):
		if not os.path.exists('Autocorr%d'%i):
			outDir = 'Autocorr%d'%i
			os.mkdir( outDir )
			break

	if not outDir:
		print "You have a lot of Autocorr directories..."
		print "Writing output to ./ which could overwrite other data!"
		outDir = './'

	print "Writing the autocorrelation data"
	for index, traj in enumerate( trajList ):
		wd( [ 'autocorr','traj%d'%traj,'msm','lag%d'%options.lag ], msmCorr[index], dir=outDir )
		wd( [ 'autocorr','traj%d'%traj,'raw'], trajCorr[index], dir=outDir )

	plotData( msmCorr, trajCorr, trajList, options.lag )