if not MODE in MODELIST: print 'Mode not recognized. Using demo mode.' MODE = 'demo' print "Loading data for temperature T = {:d} and {} mode.".format(temp,MODE) # Load the standard raw data file for this temperature and quality DATA_PATH = 'fig7_T{:d}_raw_{}.kinda'.format(temp,MODE) ANALYSIS_PATH = 'fig7_T{:d}_{}_analysis.csv'.format(temp,MODE) out = open(ANALYSIS_PATH, 'w') out.write("# Data analyzed from {} on {}\n,\n".format(DATA_PATH, datetime.datetime.now().strftime("%x at %X"))) ## Import collected data. sys_stats = kinda.import_data(DATA_PATH) ## Regardless of what default concentrations were set during the initial simulations, reset them to the desired values here. # Concentrations are stored as the 'c_max' field of each RestingSetStats object. By default, they are set to kinda_params['max_concentration']. if exp_concs: rs_names = ['Fuel', 'Substrate', 'Catalyst', 'Output', 'Intermediate', 'Signal', 'Waste'] rs_c_max = [13e-9, 10e-9, 1e-9, 10e-9, 10e-9, 10e-9, 10e-9] for name, c_max in zip(rs_names, rs_c_max): sys_stats.get_stats(sys_stats.get_restingset(name = name)).c_max = c_max ## For each reaction, print k_1 and k_2 data. ## We separate the desired reactions from the unproductive reactions rxns = sys_stats.get_reactions(spurious=False, unproductive=False) out.write('# TARGET REACTION RATE DATA\n')
# Make plots for Figure 8D (Multiple fates case study) import numpy as np import kinda # Replace these paths with your own data output from fig8_simulate.py if desired. DATA_PATH1 = 'fig8_unmod_raw.kinda' # path of unmodified system data DATA_PATH2 = 'fig8_mod_raw.kinda' # path of modified system data IMGS_PREFIX = 'fig8D' ## Import collected data sstats1 = kinda.import_data(DATA_PATH1) sstats2 = kinda.import_data(DATA_PATH2) ## Get the relevant resting sets reaction_names = ['Gate + Interloper -> Fate1', 'Gate + Interloper -> Fate2'] reactant_names = ['Gate1', 'Interloper'] product_names = [['Fate1_Cpx1', 'Fate1_Cpx2'], ['Fate2_Cpx1', 'Fate2_Cpx2a']] gate_complex_names = ['Gate1', 'Gate1_open', 'Gate2', 'Gate2_open'] all_k1 = np.empty(shape = (2, len(reaction_names))) all_k1_err = np.empty(shape = (2, len(reaction_names))) all_k2 = np.empty(shape = (2, len(reaction_names))) all_k2_err = np.empty(shape = (2, len(reaction_names))) all_gate_prob = np.empty(shape = (2, len(gate_complex_names)+1)) all_gate_prob_err = np.empty(shape = (2, len(gate_complex_names)+1)) ## Extract reaction rate data for j, (rxn_name, prod_names) in enumerate(zip(reaction_names,product_names)): for i, sstats in enumerate([sstats1, sstats2]):
multistrand_params = { 'sodium': 1.0, 'simulation_time': 100.0, # default timeout is 1.0 seconds; some T = 15 C sims take longer than 10 sec 'temperature': temp } nupack_params = {'sodium': 1.0, 'T': temp} #### Read domains, strands, and complexes from old-style PIL file #### Or recover that information, along with simulation results, from earlier (and perhaps lower-quality) simulations if os.path.exists(DATA_PATH): print "Loading previous data for temperature T = {:d} and {} mode.".format( temp, MODE) sstats = kinda.import_data(DATA_PATH) elif os.path.exists(PREV_DATA_PATH): print "Loading previous data for temperature T = {:d} and {} mode, boosting for {} mode.".format( temp, PREV_MODE, MODE) sstats = kinda.import_data(PREV_DATA_PATH) # The resting set analysis may have a changed analysis parameter. # Since samples are saved, it is OK to update the parameter. (Unlike for the multistrand similarity threshold.) restingsets = sstats.get_restingsets() for rs in restingsets: rs_stats = sstats.get_stats(rs) rs_stats.set_similarity_threshold( kinda_params['nupack_similarity_threshold']) else: sstats = kinda.from_pil(PIL_PATH, kinda_params=kinda_params, multistrand_params=multistrand_params,
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'
axes_k1.set_xticks(xticks) axes_k1.set_xticklabels(xlabels) axes_k1.set_yscale('log') axes_k1.set_ylim(936816.69397475501, 14643556.512799658) axes_k2.legend(dataset_labels) axes_k2.set_ylabel('$k_2, s^{-1}$') axes_k2.set_xticks(xticks) axes_k2.set_xticklabels(xlabels) axes_k2.set_yscale('log') axes_k2.set_ylim(30.510499687666091, 21417005.100912001) axes_k1.set_title(title) plt.savefig('{}.pdf'.format(title)) return k1, k1_err, k2, k2_err # Change these filenames to use your own data sstats_OR_disassoc = kinda.import_data('Groves2016_OR_ordered-complex.kinda') sstats_OR_cbc = kinda.import_data('Groves2016_OR_count-by-complex.kinda') sstats_OR_cbd = kinda.import_data('Groves2016_OR_count-by-domain.kinda') sstats_AND_disassoc = kinda.import_data('Groves2016_AND_ordered-complex.kinda') sstats_AND_cbc = kinda.import_data('Groves2016_AND_count-by-complex.kinda') sstats_AND_cbd = kinda.import_data('Groves2016_AND_count-by-domain.kinda') dataset_labels = ['ordered-complex', 'count-by-complex', 'count-by-domain'] dataset_colors = ['1.0', '0.8', '0.6'] OR_k1, OR_k1_err, OR_k2, OR_k2_err = plot_reaction_data([['InA', 'OR'], ['InB', 'OR']], [sstats_OR_disassoc, sstats_OR_cbc, sstats_OR_cbd], dataset_labels, dataset_colors, 'fig10D_OR', figsize=(3.6,4.8)) AND_k1, AND_k1_err, AND_k2, AND_k2_err = plot_reaction_data([['InB', 'AND'], ['InA', 'AND_InB']], [sstats_AND_disassoc, sstats_AND_cbc, sstats_AND_cbd], dataset_labels, dataset_colors, 'fig10D_AND', figsize=(3.6,4.8))