Пример #1
0
def main():

	print "Reading data...",
	print " %s."% options.rawFN,
	raw = rd( options.rawFN )
	print " %s." % options.projFN,
	P = Serializer.LoadFromHDF( options.projFN )
	print " %s." % options.msmFN
	msmDict = Serializer.LoadFromHDF( options.msmFN ) 

	lens = [ ( P['TrajLengths'][i], i ) for i in range( P['TrajLengths'].shape[0] ) ]
	lens = sorted(lens,reverse=True)

	print lens
	
	trajList = [ b for (a,b) in lens[:options.nTraj] ]
	print trajList
	# Generate the trajectory data:
	trajData = []
	
	for traj in trajList:
		trajData.append( array(rawObs( traj, P['TrajLengths'], raw ) ) )

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

	print "Plotting the data ... "
	plotData( msmDict, trajCorr, trajList )
Пример #2
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)	 
Пример #3
0
parser.add_option('-x',dest='xFN',help='This is the x-coordinates for all the states')
parser.add_option('-y',dest='yFN',help='This is the y-coordinates for all the states')
parser.add_option('--xc',dest='xcol',type=int,help='The column in the x-data to use')
parser.add_option('--yc',dest='ycol',type=int,help='The column in the y-data to use')
parser.add_option('-d',dest='dataFN',help='Data to plot for all the states.')
parser.add_option('--pos-or-neg',dest='pos_or_neg',help='Pass this flag if you want to change the data to 1 and 0 corresponding to whether it is positive or negative. Like if you are plotting an eigenvector of a transition probability matrix.', default=False, action='store_true')
options,args = parser.parse_args()

import matplotlib
matplotlib.use('Pdf')
from matplotlib.pyplot import *
from numpy import *
from pyschwancr.dataIO import readData as rd
from pyschwancr.dataIO import writeData as wd

X = rd( options.xFN ).real
Y = rd( options.yFN ).real
data = rd( options.dataFN ).real
print X.shape, Y.shape, data.shape
if len( X.shape ) > 1:
   print "X formatted strangely... Need to choose a column"
   if not options.xcol:
      print "Need to input the column to use as --xc!"
      print "Continuing using column 0. Careful this could give wacky results!"
      X = X[:,0]
   else:
      X = X[:,options.xcol]

if len( Y.shape ) > 1:
   print "Y formatted strangely... Need to choose a column"
   if not options.ycol:
Пример #4
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 )