def construct_conditions(args, fileformatter, inp_filebase, system_file): bias_tags, windows = us_process.read_windows_file(args.windows_filename) bias_functions = json.load(open(args.bias_functions_filename)) op_tags = us_process.get_op_tags_from_bias_functions( bias_functions, bias_tags) # Linear square well functions are all the same for bias_function in bias_functions['origami']['bias_functions']: if bias_function['type'] == 'LinearStepWell': slope = bias_function['slope'] min_outside_bias = bias_function['min_bias'] grid_biases = [] for window in windows: for rep in range(args.reps): filebase = '{}_run-{}_rep-{}'.format(inp_filebase, args.run, rep) grid_biases.append(biases.GridBias(op_tags, window, min_outside_bias, slope, args.temp, filebase)) conditions_map = {'temp': [args.temp], 'staple_m': [args.staple_m], 'bias': grid_biases} # either get rid of this too or make a list of filebases for creating sim collections return conditions.AllSimConditions(conditions_map, fileformatter, system_file)
def main(): filebase = 'inps/snodin-staple_temp-344_run-0_rep-0' # simualation identification name wins_filename = 'inps/snodin_344_staple.windows' # windows file tags, wins = us_process.read_windows_file( wins_filename ) # returns [tag1, tag2, ..,] and [((min1, max1), (min2, max2), ...)] pmfs_filename = 'outs/snodin-long_temp-344_run-1_rep-0_pmfs.sds' pmf_array = np.loadtxt(pmfs_filename, skiprows=1) pmfs = {(i[0], i[1]): i[2] for i in pmf_array} # dictionary for each line{(col1, col2):col3} for win in wins: biases = {'biases': []} domain_lims = [win[0][0], win[1][0]] staple_lims = [win[0][1], win[1][1]] for domain in range(domain_lims[0], domain_lims[1] + 1): for staple in range(staple_lims[0], staple_lims[1] + 1): point = (staple, domain) if point not in pmfs: continue elif np.isnan(pmfs[point]): continue else: biases_entry = {} biases_entry['point'] = [domain, staple] biases_entry['bias'] = -pmfs[point] biases['biases'].append(biases_entry) win_filename = us_process.create_win_filename(win, filebase) json.dump(biases, open(win_filename, 'w'), indent=4, separators=(',', ': '))
def main(): args = parse_args() tags, wins = us_process.read_windows_file(args.wins_filename) for i, win in enumerate(wins): inp_postfix = '_iter-{}.trj'.format(args.iteration) trj_inp_filename = us_process.create_win_filename(win, args.inp_filebase, inp_postfix) trj_out_filename = us_process.create_win_filename(win, args.out_filebase, '.trj.restart') trj_file = files.UnparsedMultiLineStepInpFile(trj_inp_filename) with open(trj_out_filename, 'w') as out: out.write(trj_file.get_last_step())
def main(): args = parse_args() # random.seed(123450897) traj_file = files.TxtTrajInpFile(args.sim_filebase + '.trj', args.system_file) bias_tags, wins = us_process.read_windows_file(args.win_file) bias_functions = json.load(open(args.bias_functions_filename)) op_tags = us_process.get_op_tags_from_bias_functions( bias_functions, bias_tags) ops = datatypes.OrderParams.from_file(args.sim_filebase) op_to_config = sort_by_ops(ops, op_tags) for i, win in enumerate(wins): config = us_process.select_config_by_op_in_win(i, win, ops, op_to_config) win_filename = us_process.create_win_filename(win, args.out_filebase, args.ext) config_file = files.TxtTrajOutFile(win_filename) config_file.write_config(traj_file.get_chains(config), 0)
def main(): parser = argparse.ArgumentParser() parser.add_argument( 'system_file', type=str, help='System file') parser.add_argument( 'win_file', type=str, help='Windows file') parser.add_argument( 'sim_filebase', type=str, help='Filebase of simulation to select configs from') parser.add_argument( 'out_filebase', type=str, help='Filebase of starting config trj files') parser.add_argument( 'ext', type=str, help='Starting config trj file extension') args = parser.parse_args() system_filename = args.system_file wins_filename = args.win_file sim_filebase = args.sim_filebase out_filebase = args.out_filebase ext = args.ext traj_file = PlainTextTrajFile(sim_filebase + '.trj', system_filename) tags, wins = read_windows_file(wins_filename) ops = read_ops_from_file(sim_filebase + '.ops', tags, 0) op_to_config = sort_by_ops(ops, tags) for i, win in enumerate(wins): config = select_config_by_op_in_win(i, win, ops, op_to_config) win_filename = create_win_filename(win, out_filebase, ext) config_file = PlainTextTrajOutFile(win_filename) config_file.write_config(traj_file.chains(config), 0)
def main(): args = parse_args() skip = 1 out_filebase = '{}/{}-{}_timeseries'.format(args.output_dir, args.system, args.vari) tags = ['numstaples', 'numfulldomains', 'nummisdomains', 'numstackedpairs'] labels = [ 'Bound staples', 'Bound domains', 'Misbound domains', 'Stacked pairs' ] bias_tags, windows = us_process.read_windows_file(args.windows_filename) figsize = (plot.cm_to_inches(18), plot.cm_to_inches(36 * len(windows))) plot.set_default_appearance() f, axes = plt.subplots(3 * len(windows), 1, figsize=figsize, dpi=300) ax_i = -1 for window in windows: for rep in range(args.reps): ax_i += 1 ax = axes[ax_i] ax.set_xlabel('Walltime / s') timeseries = {} times = [] for tag in tags: timeseries[tag] = [] # Create window file postfix postfix = '_win' for win_min in window[0]: postfix += '-' + str(win_min) postfix += '-' for win_max in window[1]: postfix += '-' + str(win_max) filebase = '{}/{}-{}_run-{}_rep-{}{}_iter-prod'.format( args.input_dir, args.system, args.vari, args.run, rep, postfix) ops_filename = '{}.ops'.format(filebase) ops = read_ops_from_file(ops_filename, tags, skip) times_filename = '{}.times'.format(filebase) times = np.loadtxt(times_filename, skiprows=1)[::skip, 1] for tag in tags: timeseries[tag] = ops[tag] # Plot timeseries for i, tag in enumerate(tags): ax.plot(times, timeseries[tag], marker=None, label=labels[i], color='C{}'.format(i), zorder=4 - i) # Plot expected value for i, tag in enumerate(tags): if args.assembled_values[i] != 0: ax.axhline(args.assembled_values[i], linestyle='--', color='C{}'.format(i)) # Plot legend ax = axes[0] handles, labels = ax.get_legend_handles_labels() lgd = ax.legend(handles, labels, frameon=False, loc='center', bbox_to_anchor=(0.7, 0.25)) plt.tight_layout(pad=0.5, h_pad=0, w_pad=0) f.savefig('{}.pdf'.format(out_filebase), transparent=True) f.savefig('{}.png'.format(out_filebase), transparent=True)