if __name__ == '__main__': 
	import argparse
	parser = argparse.ArgumentParser(description='Print out the prevalence values, historyids, and complexity costs for the given event.')
	parser.add_argument('cnavg', help='the CN-AVG output directory for a sample')
	parser.add_argument('evnts', help='A list of a events to print all of the data for.')
	parser.add_argument('datdir', help='directory to output all the values for prevalence to get distribution information. A .dat file will be created for each event, with the name of the file being the id of the event.')
	args=parser.parse_args()
	cnavgdir=args.cnavg
	if not os.path.exists(args.datdir): 
		os.makedirs(args.outdir)
	eventstokeep=[]
	datfnhash={}
	eventf=open(args.evnts, 'r')
	for eline in eventf: 
		evnt=histseg.Event(eline)
		eventstokeep.append(evnt)
		hashkey="%f+%s" % (evnt.cnval, evnt.segstr) 
		datfnhash[hashkey]="%s.dat" % (evnt.id)

	sys.stderr.write("number of events to keep: %d" % (len(eventstokeep)))
	for sim in xrange(10):
		sys.stderr.write("working on sim: %d\n" % (sim))
		braneyfn="%s/HISTORIES_%d.braney" % (cnavgdir, sim)
		events=histseg.make_events_from_braneyfn(braneyfn)
		for evnt in events: 
			if evnt in eventstokeep:
				hashkey="%f+%s" % (evnt.cnval, evnt.segstr) 
				datfn=args.datdir + "/" + datfnhash[hashkey]
				print_event_details(evnt, datfn) 	

				refevents=get_eventcounts_for_history(historyid, events)
			for evnt in events: 
				if otherid in evnt.histories: 
					otherevents+=1
					if historyid in evnt.histories: 
						inboth+=1
				if refhistoryid2: 
					if historyid in evnt.histories: 
						refevents+=1
			outfh.write("%d\t%d\t%d\t%d\t%d\n" % (historyid, otherid, refevents, otherevents, inboth)) 
			
if __name__ == '__main__': 
	import argparse
	parser=argparse.ArgumentParser(description='compute the number of events that are different across a set of histories')

	parser.add_argument('--braneyfile', help='a HISTORIES*.braney file')
	parser.add_argument('--pevntsfile', help='a *.pevnts file')
	parser.add_argument('--refhistoryid', help='the historyid that you want to take as step 0.', default=2500, type=int)
	parser.add_argument('--refhistoryid2', help='a second historyid that you want to take as step 0.', type=int)
	parser.add_argument('--numsteps', help='the number of steps to take.', default=0, type=int)
	parser.add_argument('--stepsize', help='the step size from the reference id(s) in the mcmc that you want to go.', default=1, type=int)
	parser.add_argument('--stepsize2', help='the step size from the second history id(s) in the mcmc that you want to go.', default=1, type=int)
	args=parser.parse_args()
	if args.braneyfile and not args.pevntsfile: 
		events=histseg.make_events_from_braneyfn(args.braneyfile)
	elif args.pevntsfile: 
		events=pickle.load(open(args.pevntsfile, 'rb'))
		for e in events: 
			e.histories=histseg.listout_ranges(e.histRanges)
	get_history_distances_between_mcmc_steps(events, args.refhistoryid, args.refhistoryid2, args.numsteps, args.stepsize, args.stepsize2, sys.stdout)