def simulate(sim_mode, **params): ## Setup initialization parameters peppercorn_params = {'k_fast': 5e-7} kinda_params = { 'stop_macrostate_mode': sim_mode, 'start_macrostate_mode': 'ordered-complex' } ## Construct System object sstats = kinda.from_pil(PILPATH, peppercorn_params=peppercorn_params, kinda_params=kinda_params) ## Find relevant resting sets rs_InputA = sstats.get_restingset(complex_name='InA') rs_InputB = sstats.get_restingset(complex_name='InB') rs_OR = sstats.get_restingset(complex_name='OR') ## Get the relevant reactions with the OR gate complex rxns = [ sstats.get_reaction(reactants=[rs_InputA, rs_OR], spurious=False, unproductive=False), sstats.get_reaction(reactants=[rs_InputB, rs_OR], spurious=False, unproductive=False) ] print "Reaction analysis order:" for i, rxn in enumerate(rxns): print i, rxn rxn_times = [] for rxn in rxns: print "Analyzing", rxn start_time = time.time() ## Run simulations rxn_stats = sstats.get_stats(rxn) rxn_stats.get_k1(verbose=1, **params) rxn_stats.get_k2(verbose=1, **params) end_time = time.time() print "k1: {} +/- {}".format(rxn_stats.get_k1(max_sims=0), rxn_stats.get_k1_error(max_sims=0)) print "k2: {} +/- {}".format(rxn_stats.get_k2(max_sims=0), rxn_stats.get_k2_error(max_sims=0)) rxn_times.append(end_time - start_time) print "Finished analyzing {} in {} seconds\n".format( rxn, end_time - start_time) ## Store results kinda.export_data(sstats, '{}_{}.kinda'.format(OUTPUT_PREFIX, sim_mode)) return sstats, zip(rxns, rxn_times)
c.name for c in restingset.complexes ] # Get all conformation names in the resting set (most of the time there are only 1 or 2) confs.append( None ) # None refers to spurious conformations (that aren't similar to any expected conformations) print "Conformation probabilities for resting set {0}".format(restingset) for c in confs: p = rs_stats.get_conformation_prob(c, .025, max_sims=500) print "\t{0}: {1}%".format(c, p * 100) ## Getting the top 10 MFE structures mfe_structs = rs_stats.get_top_MFE_structs(10) print "Top 10 MFE structures for resting set {0}".format(restingset) for i, s in enumerate(mfe_structs): print "\t{0}: {1} ({2})".format(i, s[0], s[1]) kinda.export_data(kinda_obj, 'analyze.db') kinda_obj = kinda.import_data('analyze.db') # DOES NOT WORK!!! ## Getting the (fractional) reactant depletion due to unproductive reactions #unproductive_depletion = rs_stats.get_temp_depletion(0.5) # Get depletion with 50% error on any relevant reaction rate ## Getting the rate constant of reactant depletion due to spurious reactions (units: /s) #spurious_depletion = rs_stats.get_perm_depletion(0.5) # Get depletion with 50% error on any relevant reaction rate #### To get a system-level score, use the convenience functions in stats_utils.py #kinda.statistics.stats_utils.calc_unproductive_rxn_score(kinda_obj) #kinda.statistics.stats_utils.calc_spurious_rxn_score(kinda_obj) print 'done'
for i, r in enumerate(desired_rxns): print "\nAnalyzing desired reaction {}: {}".format(i, r) # Get stats object rxn_stats = sstats.get_stats(r) # Query k1 and k2 reaction rates to requested precision rxn_stats.get_k1(verbose=1, **params) rxn_stats.get_k2(verbose=1, **params_uni) print "k1: {} +/- {}".format(rxn_stats.get_k1(max_sims=0), rxn_stats.get_k1_error(max_sims=0)) print "k2: {} +/- {}".format(rxn_stats.get_k2(max_sims=0), rxn_stats.get_k2_error(max_sims=0)) ## Export all collected data (we'll do it again later, but in case the system crashes...) kinda.export_data(sstats, DATA_PATH) ## Simulate the most probable leak reactions, with the same accuracy goals. We know they're there, so find them! for i, r in enumerate(leak_rxns): print "\nAnalyzing potential leak reaction {}: {}".format(i, r) # Get stats object rxn_stats = sstats.get_stats(r) # Query k1 and k2 reaction rates to requested precision rxn_stats.get_k1(verbose=1, **params) rxn_stats.get_k2(verbose=1, **params_uni) print "k1: {} +/- {}".format(rxn_stats.get_k1(max_sims=0), rxn_stats.get_k1_error(max_sims=0)) print "k2: {} +/- {}".format(rxn_stats.get_k2(max_sims=0),