Example #1
0
def main():
	parser = OptionParser()
	parser.add_option("-f", "--use-flat", action="store_true", dest="use_flat_flag", default=False,
						help="load plot data from flat files")
	parser.add_option("-n", "--nonpolar-timeseries", action="store_true", dest="run_nonpolar_flag", default=False,
	                  help="run nonpolar timeseries analysis and plot")
	parser.add_option("-p", "--hb-timeseries", action="store_true",
	                  dest="run_polar_flag", default=False,
	                  help="run polar timeseries analysis and plot")
	parser.add_option("-c", "--cluster", action="store_true", dest="run_cluster", default=False,
						help="process and plot cluster size analysis")

	(options, args) = parser.parse_args()

	# print options
	# print args
	if len(args) < 1:
		parser.error("Please specify a .h5 input file")
	
	filename = args[0]
	# option = sys.argv[2]
	# use_flat_flag = False

	h5file = tables.openFile(filename)
	ratio,ext = os.path.splitext(filename)

	# binding.nonpolar_residue(h5file, ratio)
	# binding.intersection(h5file, ratio)
	# dssp.run(h5file)
	
	config.configure_plot()

	if options.run_polar_flag:
		timeseries_hb.run(h5file, ratio, use_flat_files=options.use_flat_flag)
	
	if options.run_nonpolar_flag:
		timeseries_nonpolar.run(h5file, ratio, use_flat_files=options.use_flat_flag)
		
	if options.run_cluster:
		cluster.run(h5file, ratio, use_flat_files=options.use_flat_flag)
Example #2
0
def plot(datalist, labellist, ratio, use_flat_files=False):
	if use_flat_files == True:
		print "using flat files ... "
		datalist,labellist = create_datalist(ratio)

	assert len(datalist) == 3, "%s data lists, expecting 3 for scyllo, chiro, water" % `len(datalist)`
	
	config.configure_plot()
	fig1 = pylab.figure(num=1)
	fig2 = pylab.figure(num=2)
	ax1 = fig1.add_subplot(111)
	ax2 = fig2.add_subplot(111)

	print "plotting data"
	for i in range(0,len(datalist)):
		parts = labellist[i].split()
		isomer = parts[0]
		print "plotting", isomer
		
		if isomer == "water":
			labellist[i] = "no inositol"

		# print "Test: time column for", labellist[i], datalist[i][:,0]
		nrows, ncols = datalist[i].shape
		assert nrows > ncols, "Number of cols greater than rows!"

		time = datalist[i][:,0]/1000
		ax1.fill_between(time, 
						(datalist[i][:,1] - datalist[i][:,2])/config.NMOLECULES, 
						(datalist[i][:,1] + datalist[i][:,2])/config.NMOLECULES,
						alpha=0.5,
						facecolor=config.SHADED_COLOR[isomer],
						edgecolor=config.SHADED_COLOR[isomer], 
						lw=0.5)
		ax2.fill_between(time,
					(datalist[i][:,3] - datalist[i][:,4])/config.NMOLECULES,
					(datalist[i][:,3] + datalist[i][:,4])/config.NMOLECULES, 
					alpha=0.5,
					facecolor=config.SHADED_COLOR[isomer],
					edgecolor=config.SHADED_COLOR[isomer], 
					lw=0.5)
		ax1.plot(time, datalist[i][:,1]/config.NMOLECULES, color=config.LINE_COLOR[isomer], label=labellist[i])
		ax2.plot(time, datalist[i][:,3]/config.NMOLECULES, color=config.LINE_COLOR[isomer], label=labellist[i])
		# print "using line color for", isomer, config.LINE_COLOR[isomer]

	ax2.set_xlabel('Time (ns)')
	ax1.set_ylabel('Intermolecular Hydrogen Bonds per peptide')
	ax2.set_ylabel('Intramolecular Hydrogen Bonds per peptide')
	ax1.grid(True); ax2.grid(True)
	ax1.set_xlim(0, config.RUNTIME_NS); ax2.set_xlim(0, config.RUNTIME_NS)
	ax1.set_ylim(0, 3); ax2.set_ylim(0, 3)

	ax1.legend(loc='upper right', ncol=1, columnspacing=0.5, borderaxespad=0.)
	ax2.legend(loc='upper right', ncol=1, columnspacing=0.5, borderaxespad=0.)

	#frame = leg.get_frame()
	#frame.set_linewidth(0.5)
	print "Saving figure..."

	#this produces a small image of this size, but everything else is way too big
	#need to adjust rcParams for font size and legend size
	# fig1.set_size_inches((3.25,3.5))
	# fig2.set_size_inches((3.25,3.5))
	print "Polar figure 1 size", fig1.get_size_inches()
	print "Polar figure 2 size", fig2.get_size_inches()

	fig1.savefig('inter_%(ratio)s.png' % vars())
	fig2.savefig('intra_%(ratio)s.png' % vars())