def run(self): self.logToMaster("CreatePevntsFile\n") opts=self.options if opts.simulation: truefile=os.path.join(opts.cnavgout, "true.braney") truehist=os.path.join(opts.cnavgout, "HISTORIES_0.braney") subprocess.call("grep -v ^$ %s | gzip > %s" % (truefile, truehist), shell=True) make_STATS_from_truebraney(truefile, os.path.join(opts.cnavgout, "HISTORY_STATS_0")) historyScores=histseg.combine_history_statsfiles(opts.cnavgout) np.savetxt(self.historystatsfile, historyScores, fmt='%d', delimiter='\t') totalp=histseg.compute_likelihood_histories(historyScores[:,0], historyScores) events=histseg.get_events_from_cnavgdir(opts.cnavgout, historyScores, totalp) pickle.dump(events, open(self.pevntsfile, 'wb'), pickle.HIGHEST_PROTOCOL)
def score_and_link_cycles(args): if args.binwidth: histseg.Global_BINWIDTH=args.binwidth if not args.historystats and args.cnavg: historyScores=histseg.combine_history_statsfiles(args.cnavg) elif not os.path.isfile(args.historystats) and args.cnavg: historyScores=histseg.combine_history_statsfiles(args.cnavg) np.savetxt(args.historystats, historyScores, fmt="%d", delimiter='\t') elif os.path.isfile(args.historystats): historyScores=np.loadtxt(args.historystats, dtype=int) if not historyScores: sys.exit("Need to use --historystats or --cnavg option") totalp=0 if args.totalp: totalp=args.totalp else: totalp = histseg.compute_likelihood_histories(historyScores[:,0], historyScores) allevents=[] if args.cnavg: sys.stderr.write("using cnavg dir: %s\n" % (args.cnavg)) allevents=histseg.get_events_from_cnavgdir(args.cnavg, historyScores, totalp) elif args.inpickle and os.path.isfile(args.inpickle): sys.stderr.write("using pickle file\n") allevents=pickle.load(open(args.inpickle, 'rb')) sys.stderr.write("there are %d events\n" % (len(allevents))) if args.outpickle: for event in allevents: event.trim() eventfile= open(args.outpickle, 'wb') pickle.dump(allevents, eventfile, pickle.HIGHEST_PROTOCOL) if args.events: eventfile=open(args.events, 'w') for evnt in allevents: eventfile.write("%s" % (str(evnt))) # link the events... if args.links: if not allevents: sys.exit("Need events to link! use --inpickle or --cnavg or --events") if not totalp: sys.exit("Need a --totalp or --cnavg or --historystats options") eventlinks = link_events_by_order_within_histories(allevents) linkfile=open(args.links, 'w') for link in eventlinks: link.likelihood=histseg.compute_likelihood_histories(link.histories, historyScores) linkfile.write("%s" % (str(link)))