Esempio n. 1
0
def construct_conditions(args, fileformatter):
    conditions_map = {
        'temp': args.temps,
        'staple_m': [args.staple_m],
        'bias': [biases.NoBias()]
    }

    return conditions.AllSimConditions(conditions_map, fileformatter)
def construct_conditions_map(args):
    conditions_map = {
        'temp': args.temps,
        'staple_m': [0],
        'bias': [biases.NoBias()]
    }

    return conditions_map
def main():
    args = parse_args()
    system_file = files.JSONStructInpFile(args.system_filename)
    inp_filebase = create_input_filepathbase(args)
    fileformatter = construct_fileformatter()
    all_conditions = construct_conditions(args, fileformatter, inp_filebase,
                                          system_file)
    staple_lengths = system_file._staple_lengths
    out_filebase = create_output_filepathbase(args)
    conds = conditions.SimConditions(
        {
            'temp': args.temp,
            'staple_m': args.staple_m,
            'bias': biases.NoBias()
        }, fileformatter, staple_lengths)

    # Expecations along OP slices
    mbarws = []
    all_decor_outs = []
    sampled_ops = []
    for i in range(1, args.assembled_op + 1):
        sim_collections = create_simplesim_collections(args, inp_filebase,
                                                       all_conditions)
        decor_outs = decorrelate.SimpleDecorrelatedOutputs(
            sim_collections, all_conditions)
        decor_outs.read_decors_from_files()
        filtered_count = decor_outs.filter_collections(args.tag, i)
        if filtered_count == 0:
            continue

        sampled_ops.append(i)
        all_decor_outs.append(decor_outs)
        mbarw = mbar_wrapper.MBARWrapper(decor_outs)
        mbarw.perform_mbar()
        mbarws.append(mbarw)

    # Calculate expectations across selected order parameter
    all_tags = []
    for i in range(1, args.staple_types + 1):
        all_tags.append('staples{}'.format(i))
        all_tags.append('staplestates{}'.format(i))

    for i in range(args.scaffold_domains):
        all_tags.append('domainstate{}'.format(i))

    aves, stds = calc_reduced_expectations(conds, mbarws, all_decor_outs,
                                           all_tags)

    aves = np.concatenate([[sampled_ops], np.array(aves).T])
    aves_file = files.TagOutFile('{}-{}.aves'.format(out_filebase, args.tag))
    aves_file.write([args.tag] + all_tags, aves.T)

    stds = np.concatenate([[sampled_ops], np.array(stds).T])
    stds_file = files.TagOutFile('{}-{}.stds'.format(out_filebase, args.tag))
    stds_file.write([args.tag] + all_tags, stds.T)
def main():
    args = parse_args()
    system_file = files.JSONStructInpFile(args.system_filename)
    fileformatter = construct_fileformatter()
    all_conditions = construct_conditions(args, fileformatter, system_file)
    staple_lengths = all_conditions._staple_lengths
    inp_filebase = create_input_filepathbase(args)

    mbarws = []
    all_decor_outs = []
    sampled_ops = []
    for i in range(1, args.assembled_op + 1):
        sim_collections = outputs.create_sim_collections(
            inp_filebase, all_conditions, args.reps)
        decor_outs = decorrelate.DecorrelatedOutputs(sim_collections,
                                                     all_conditions)
        decor_outs.read_decors_from_files(data_only=True)
        filtered_count = decor_outs.filter_collections(args.tag, i)
        if filtered_count == 0:
            continue

        sampled_ops.append(i)
        all_decor_outs.append(decor_outs)
        mbarw = mbar_wrapper.MBARWrapper(decor_outs)
        mbarw.perform_mbar()
        mbarws.append(mbarw)

    out_filebase = create_output_filepathbase(args)

    # Calculate expectations across selected order parameter
    conds = conditions.SimConditions(
        {
            'temp': args.temp,
            'staple_m': args.staple_m,
            'bias': biases.NoBias()
        }, fileformatter, staple_lengths)
    all_tags = []
    for i in range(1, args.staple_types + 1):
        all_tags.append('staples{}'.format(i))
        all_tags.append('staplestates{}'.format(i))

    for i in range(args.scaffold_domains):
        all_tags.append('domainstate{}'.format(i))

    aves, stds = calc_reduced_expectations(conds, mbarws, all_decor_outs,
                                           all_tags)

    aves = np.concatenate([[sampled_ops], np.array(aves).T])
    aves_file = files.TagOutFile('{}-{}.aves'.format(out_filebase, args.tag))
    aves_file.write([args.tag] + all_tags, aves.T)

    stds = np.concatenate([[sampled_ops], np.array(stds).T])
    stds_file = files.TagOutFile('{}-{}.stds'.format(out_filebase, args.tag))
    stds_file.write([args.tag] + all_tags, stds.T)

    # Hacky calculation for plotting a melting temperature LFE curve
    sim_collections = outputs.create_sim_collections(inp_filebase,
                                                     all_conditions, args.reps)
    decor_outs = decorrelate.DecorrelatedOutputs(sim_collections,
                                                 all_conditions)
    decor_outs.read_decors_from_files()
    mbarw = mbar_wrapper.MBARWrapper(decor_outs)
    mbarw.perform_mbar()
    values = decor_outs.get_concatenated_series(args.tag)
    decor_enes = decor_outs.get_concatenated_datatype('enes')
    decor_ops = decor_outs.get_concatenated_datatype('ops')
    decor_staples = decor_outs.get_concatenated_datatype('staples')
    bins = list(set(values))
    bins.sort()
    value_to_bin = {value: i for i, value in enumerate(bins)}
    bin_index_series = [value_to_bin[i] for i in values]
    bin_index_series = np.array(bin_index_series)
    conds = conditions.SimConditions(
        {
            'temp': args.temp,
            'staple_m': args.staple_m,
            'bias': biases.NoBias()
        }, fileformatter, staple_lengths)
    lfes, lfe_stds = calc_lfes(mbarw, conds, bins, bin_index_series,
                               decor_enes, decor_ops, decor_staples)
    header = np.array(['ops', args.temp])
    lfes_filebase = '{}_{}-lfes-melting'.format(out_filebase, args.tag)
    lfes_file = files.TagOutFile('{}.aves'.format(lfes_filebase))
    lfes = np.concatenate([[bins], [lfes]]).T
    lfes_file.write(header, lfes)
    stds_file = files.TagOutFile('{}.stds'.format(lfes_filebase))
    lfe_stds = np.concatenate([[bins], [lfe_stds]]).T
    stds_file.write(header, lfe_stds)
Esempio n. 5
0
def main():
    args = parse_args()
    system_file = files.JSONStructInpFile(args.system_filename)
    fileformatter = construct_fileformatter()
    all_conditions = construct_conditions(args, fileformatter, system_file)
    staple_lengths = all_conditions._staple_lengths
    inp_filebase = create_input_filepathbase(args)
    sim_collections = outputs.create_sim_collections(inp_filebase,
                                                     all_conditions, args.reps)
    decor_outs = decorrelate.DecorrelatedOutputs(
        sim_collections, all_conditions)
    decor_outs.read_decors_from_files()

    mbarw = mbar_wrapper.MBARWrapper(decor_outs)
    mbarw.perform_mbar()

    out_filebase = create_output_filepathbase(args)

    values = decor_outs.get_concatenated_series(args.tag)
    decor_enes = decor_outs.get_concatenated_datatype('enes')
    decor_ops = decor_outs.get_concatenated_datatype('ops')
    decor_staples = decor_outs.get_concatenated_datatype('staples')
    bins = list(set(values))
    bins.sort()
    value_to_bin = {value: i for i, value in enumerate(bins)}
    bin_index_series = [value_to_bin[i] for i in values]
    bin_index_series = np.array(bin_index_series)
    conds = conditions.SimConditions({'temp': args.guess_temp, 'staple_m': args.staple_m,
                                      'bias': biases.NoBias()}, fileformatter, staple_lengths)
    melting_temp = minimize(squared_barrier_diff, args.guess_temp,
                            args=(mbarw, values, bins, bin_index_series, decor_enes, decor_ops, decor_staples,
                                  conds)).x[0]
    lfes, lfe_stds = calc_lfes(mbarw, conds, bins, bin_index_series, decor_enes,
                               decor_ops, decor_staples)
    barrier_height = np.around(calc_forward_barrier_height(lfes), decimals=3)
    barrier_i = find_barrier(lfes)
    melting_temp = '{:.3f}'.format(np.around(melting_temp, decimals=3))

    print('Estimated melting temperature: {} K'.format(melting_temp))
    print('Barrier height: {:.3f} kT'.format(barrier_height))
    print('Barrier peak: {:.3f}'.format(bins[barrier_i]))

    header = np.array(['ops', melting_temp])
    lfes_filebase = '{}_{}-lfes-melting'.format(out_filebase, args.tag)

    lfes_file = files.TagOutFile('{}.aves'.format(lfes_filebase))
    lfes = np.concatenate([[bins], [lfes]]).T
    lfes_file.write(header, lfes)

    stds_file = files.TagOutFile('{}.stds'.format(lfes_filebase))
    lfe_stds = np.concatenate([[bins], [lfe_stds]]).T
    stds_file.write(header, lfe_stds)

    # Calculated 2D LFEs
    tag2 = 'numfulldomains'
    decor_op_pairs = list(zip(decor_outs.get_concatenated_series(args.tag),
                              decor_outs.get_concatenated_series(tag2)))
    bins = list(set(decor_op_pairs))
    value_to_bin = {value: i for i, value in enumerate(bins)}
    bin_index_series = [value_to_bin[i] for i in decor_op_pairs]
    bin_index_series = np.array(bin_index_series)
    lfes, lfe_stds = calc_lfes(mbarw, conds, bins, bin_index_series, decor_enes,
                               decor_ops, decor_staples)
    header = np.array([args.tag, tag2, melting_temp])
    lfes_filebase = '{}_{}-{}-lfes-melting'.format(
        out_filebase, args.tag, tag2)
    bins = np.array(bins).reshape(len(bins), 2)

    lfes = np.concatenate([bins, np.array(lfes, ndmin=2).T], axis=1)
    lfes_file = files.TagOutFile('{}.aves'.format(lfes_filebase))
    lfes_file.write(header, lfes)

    lfe_stds = np.concatenate([bins, np.array(lfe_stds, ndmin=2).T], axis=1)
    stds_file = files.TagOutFile('{}.stds'.format(lfes_filebase))
    stds_file.write(header, lfe_stds)

    # Calculate expectations along the selected OP
    mbarws = []
    all_decor_outs = []
    sampled_ops = []
    for i in range(1, args.assembled_op + 1):
        sim_collections = outputs.create_sim_collections(inp_filebase,
                                                         all_conditions, args.reps)
        decor_outs = decorrelate.DecorrelatedOutputs(
            sim_collections, all_conditions)
        decor_outs.read_decors_from_files(data_only=True)
        filtered_count = decor_outs.filter_collections(args.tag, i)
        if filtered_count == 0:
            continue

        sampled_ops.append(i)
        all_decor_outs.append(decor_outs)
        mbarw = mbar_wrapper.MBARWrapper(decor_outs)
        mbarw.perform_mbar()
        mbarws.append(mbarw)

    out_filebase = create_output_filepathbase(args)

    # Calculate expectations across selected order parameter
    all_tags = []
    for i in range(1, args.staple_types + 1):
        all_tags.append('staples{}'.format(i))
        all_tags.append('staplestates{}'.format(i))

    for i in range(args.scaffold_domains):
        all_tags.append('domainstate{}'.format(i))

    aves, stds = calc_reduced_expectations(
        conds, mbarws, all_decor_outs, all_tags)

    aves = np.concatenate([[sampled_ops], np.array(aves).T])
    aves_file = files.TagOutFile('{}-{}.aves'.format(out_filebase, args.tag))
    aves_file.write([args.tag] + all_tags, aves.T)

    stds = np.concatenate([[sampled_ops], np.array(stds).T])
    stds_file = files.TagOutFile('{}-{}.stds'.format(out_filebase, args.tag))
    stds_file.write([args.tag] + all_tags, stds.T)
Esempio n. 6
0
def main():
    args = parse_args()
    system_file = files.JSONStructInpFile(args.system_filename)
    inp_filebase = create_input_filepathbase(args)
    fileformatter = construct_fileformatter()
    all_conditions = construct_conditions(args, fileformatter, inp_filebase,
                                          system_file)
    staple_lengths = system_file._staple_lengths
    sim_collections = create_simplesim_collections(args, inp_filebase,
                                                   all_conditions)
    decor_outs = decorrelate.SimpleDecorrelatedOutputs(sim_collections,
                                                       all_conditions)
    decor_outs.read_decors_from_files()

    mbarw = mbar_wrapper.MBARWrapper(decor_outs)
    mbarw.perform_mbar()

    out_filebase = create_output_filepathbase(args)
    conds = conditions.SimConditions(
        {
            'temp': args.temp,
            'staple_m': args.staple_m,
            'bias': biases.NoBias()
        }, fileformatter, staple_lengths)
    all_tags = decor_outs.all_conditions.condition_tags
    aves = []
    stds = []
    for tag in decor_outs.all_series_tags:
        all_tags.append(tag)
        series = decor_outs.get_concatenated_series(tag)
        ave, std = mbarw.calc_expectation(series, conds)
        aves.append(ave)
        stds.append(std)

        # Hack calculate LFEs
        values = decor_outs.get_concatenated_series(tag)
        decor_enes = decor_outs.get_concatenated_datatype('enes')
        decor_ops = decor_outs.get_concatenated_datatype('ops')
        bins = list(set(values))
        bins.sort()
        value_to_bin = {value: i for i, value in enumerate(bins)}
        bin_index_series = [value_to_bin[i] for i in values]
        bin_index_series = np.array(bin_index_series)
        rpots = utility.calc_reduced_potentials(decor_enes, decor_ops, conds)
        lfes, lfe_stds = mbarw._mbar.computePMF(rpots, bin_index_series,
                                                len(bins))

        # Hack write LFEs to file
        header = np.array(['ops', args.temp])
        lfes_filebase = '{}_{}-lfes-melting'.format(out_filebase, tag)
        lfes_file = files.TagOutFile('{}.aves'.format(lfes_filebase))
        lfes = np.concatenate([[bins], [lfes]]).T
        lfes_file.write(header, lfes)
        stds_file = files.TagOutFile('{}.stds'.format(lfes_filebase))
        lfe_stds = np.concatenate([[bins], [lfe_stds]]).T
        stds_file.write(header, lfe_stds)

    # Hack to write expectations to file
    aves_file = files.TagOutFile('{}.aves'.format(out_filebase))
    cond_char_values = conds.condition_to_characteristic_value
    cond_values = [v for k, v in sorted(cond_char_values.items())]
    aves_file.write(all_tags, [np.concatenate([cond_values, np.array(aves)])])
    stds_file = files.TagOutFile('{}.stds'.format(out_filebase))
    stds_file.write(all_tags, [np.concatenate([cond_values, np.array(stds)])])