Ejemplo n.º 1
0
	def run(self):
		sim=self.sim
		sys.stderr.write("Creating file %s\n" % (self.evntsfile))
		events=histseg.make_events_from_braneyfn(self.braneyfn)
		# Need to change the id to distinguish from other braney files. 
		for evnt in events:
			for i in xrange(len(evnt.histories)):
				evnt.histories[i] = evnt.histories[i] + sim*histseg.Global_BINWIDTH
				(idhist, order) = map(int, evnt.id.split('.'))
			evnt.id = "%d.%d" % (idhist+(sim*histseg.Global_BINWIDTH), order)
		sortedevents=sorted(events, key=lambda x:(x.segstr, x.cnval, x.prevals[0]))	
		pickle.dump(sortedevents, open(self.evntsfile, 'wb'), pickle.HIGHEST_PROTOCOL)
		self.logToMaster("Created file %s\n" % (self.evntsfile))
Ejemplo n.º 2
0
 def run(self):
     sim = self.sim
     sys.stderr.write("Creating file %s\n" % (self.evntsfile))
     events = histseg.make_events_from_braneyfn(self.braneyfn)
     # Need to change the id to distinguish from other braney files.
     for evnt in events:
         for i in xrange(len(evnt.histories)):
             evnt.histories[
                 i] = evnt.histories[i] + sim * histseg.Global_BINWIDTH
             (idhist, order) = map(int, evnt.id.split('.'))
         evnt.id = "%d.%d" % (idhist +
                              (sim * histseg.Global_BINWIDTH), order)
     sortedevents = sorted(events,
                           key=lambda x: (x.segstr, x.cnval, x.prevals[0]))
     pickle.dump(sortedevents, open(self.evntsfile, 'wb'),
                 pickle.HIGHEST_PROTOCOL)
     self.logToMaster("Created file %s\n" % (self.evntsfile))
				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) 
Ejemplo n.º 4
0
        '--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)