<commit_before>import yaml
from perses.dispersed import relative_setup
import numpy as np
import pickle
import progressbar
import os
import sys
import logging
from simtk import unit
logging.basicConfig(level=logging.DEBUG)


if __name__ == "__main__":
    try:
       yaml_filename = sys.argv[1]
    except IndexError as e:
        yaml_filename = "/Users/grinawap/perses/examples/cdk2-example/cdk2_setup.yaml"
        print("You need to specify the setup yaml file as an argument to the script.")
        #raise e

    yaml_file = open(yaml_filename, 'r')
    setup_options = yaml.load(yaml_file)
    yaml_file.close()

    trajectory_directory = setup_options['trajectory_directory']
    if 'phases' in setup_options:
        phases = setup_options['phases']
    else:
        phases = ['complex', 'solvent']
    if not os.path.exists(trajectory_directory):
        os.makedirs(trajectory_directory)

    setup_dict = relative_setup.run_setup(setup_options)
    print("setup complete")

    n_equilibration_iterations = setup_dict['n_equilibration_iterations']

    trajectory_prefix = setup_options['trajectory_prefix']
    #write out topology proposals
    np.save(os.path.join(trajectory_directory, trajectory_prefix+"topology_proposals.npy"),
            setup_dict['topology_proposals'])

    if setup_options['fe_type'] == 'nonequilibrium':
        n_cycles = setup_options['n_cycles']
        n_iterations_per_cycle = setup_options['n_iterations_per_cycle']
        total_iterations = n_cycles*n_iterations_per_cycle

        ne_fep = setup_dict['ne_fep']
        for phase in phases:
            ne_fep_run = ne_fep[phase]
            hybrid_factory = ne_fep_run._factory
            np.save(os.path.join(trajectory_directory, "%s_%s_hybrid_factory.npy" % (trajectory_prefix, phase)),
                    hybrid_factory)<commit_msg>Fix bug in setup_relative_calculation script where setup_dict was erroneously used instead of setup_options<commit_after>import yaml
from perses.dispersed import relative_setup
import numpy as np
import pickle
import progressbar
import os
import sys
import logging
from simtk import unit
logging.basicConfig(level=logging.DEBUG)


if __name__ == "__main__":
    try:
       yaml_filename = sys.argv[1]
    except IndexError as e:
        yaml_filename = "/Users/grinawap/perses/examples/cdk2-example/cdk2_setup.yaml"
        print("You need to specify the setup yaml file as an argument to the script.")
        #raise e

    yaml_file = open(yaml_filename, 'r')
    setup_options = yaml.load(yaml_file)
    yaml_file.close()

    trajectory_directory = setup_options['trajectory_directory']
    if 'phases' in setup_options:
        phases = setup_options['phases']
    else:
        phases = ['complex', 'solvent']
    if not os.path.exists(trajectory_directory):
        os.makedirs(trajectory_directory)

    setup_dict = relative_setup.run_setup(setup_options)
    print("setup complete")
    print('setup_dict keys: {}'.format(setup_dict.keys()))

    n_equilibration_iterations = setup_options['n_equilibration_iterations']

    trajectory_prefix = setup_options['trajectory_prefix']
    #write out topology proposals
    np.save(os.path.join(trajectory_directory, trajectory_prefix+"topology_proposals.npy"),
            setup_dict['topology_proposals'])

    if setup_options['fe_type'] == 'nonequilibrium':
        n_cycles = setup_options['n_cycles']
        n_iterations_per_cycle = setup_options['n_iterations_per_cycle']
        total_iterations = n_cycles*n_iterations_per_cycle

        ne_fep = setup_dict['ne_fep']
        for phase in phases:
            ne_fep_run = ne_fep[phase]
            hybrid_factory = ne_fep_run._factory
            np.save(os.path.join(trajectory_directory, "%s_%s_hybrid_factory.npy" % (trajectory_prefix, phase)),
                    hybrid_factory)
{'fraction_non_alphanumeric': 0.08984375, 'fraction_numerical': 0.0015625, 'mean_word_length': 3.7186732186732185, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2217267', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1183, 'n_words': 242}