def main():
    curr_dir = os.getcwd()
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    m = MCCEParams(os.path.abspath("../code/mcce3.5"))
    m.edit_parameters(DO_PREMCCE="t", DO_ROTAMERS="f", TERMINALS="t")
    os.chdir(input_dir)
    terminal_atoms = ['CY', 'OY', 'NT', 'C1', 'C2', 'OG']

    with open('noh_test_01.pdb', "r") as oldfile, open('input_struct_01.pdb', 'w') as newfile:
        for line in oldfile:
            atm_name = line[13:15]
            if not any(at == atm_name for at in terminal_atoms):
                newfile.write(line)

    m.edit_parameters(INPDB=input_dir + "/input_struct_01.pdb")
    m.write_runprm(input_dir + "/")

    run_command = m.mcce_directory + "/mcce > prep_struct_run.log"
    os.system(run_command)
    os.chdir(curr_dir)
Ejemplo n.º 2
0
def main():
    # get current working dir
    curr_dir = os.getcwd()
    # set dict for using different water charges
    charge_sets = {
        "t3p": [-0.834, 0.417, 0.417],
        "pm6": [-2.000, 1.000, 1.000]
    }
    # fix number of conformers per water to 1
    n_conf = 5
    # set number of separate MC runs
    n_runs = 10
    # obtain water charge set option from the command-line
    prefix = sys.argv[1]
    charge_set = charge_sets[prefix]

    # set input directories
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    home_dir = os.path.abspath(
        "../data/gramicidin/simulations/apolar_gram_%s" % prefix)
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")
    water_dir = os.path.abspath("../data/gramicidin/water_placement")

    # set filenames
    src_run_prm = os.path.join(input_dir, "run.prm")
    src_newtpl = os.path.join(input_dir, "new.tpl")

    # run n different MC simulations, each on a different protein conf and coresponding water orientations
    for n in range(n_runs):
        run_dir = os.path.join(home_dir, "run_%02d" % n)
        print("Run number %d, dir %s" % (n, run_dir))

        if os.path.exists(run_dir):
            rmtree(run_dir)
        os.makedirs(run_dir)
        os.chdir(run_dir)
        # copy files to where MCCE will be run
        copy2(src_run_prm, run_dir)
        copy2(src_newtpl, run_dir)

        # obtain correct step2out
        src_step2out = os.path.join(input_dir, "%02d_final_step2_out.pdb" % n)
        write_step2out = os.path.join(run_dir, "temp_%02d_step2_out.pdb" % n)
        #print(src_step2out)
        #print(write_step2out)
        #copy2(src_step2out, write_step2out)

        with open(src_step2out, "r") as f1, open(write_step2out, "w") as f2:
            for l in f1.readlines():
                if "EM" not in l:
                    new_l = l[:68] + " 0.000" + l[74:]
                    f2.write(new_l)
                else:
                    f2.write(l)

        # obtain corresponding water positions and generate conformers
        init_waters = os.path.join(water_dir,
                                   "%02d_init_wat_placement.pdb" % n)
        start_index = get_last_prot_at_index(write_step2out)
        coords = generate_conformers(init_waters, n_conf)
        write_filename = os.path.join(run_dir, "water_confs")
        write_watpdb_from_coords_ext(write_filename, coords, start_index,
                                     charge_set)
        water_conformers = write_filename + ".pdb"

        # assemble full step2out and write ms_gold
        last_prot_at = get_last_prot_at_index(write_step2out)
        assemble_step2_out(water_conformers, write_step2out, "step2_out.pdb",
                           last_prot_at)
        write_msgold("step2_out.pdb", "W", "HOH")

        # set up MCCE run
        m = MCCEParams(mcce_exec_dir)
        m.edit_parameters(INPDB="step2_out.pdb",
                          DO_PREMCCE="f",
                          DO_ROTAMERS="f",
                          DO_ENERGY="t",
                          DO_MONTE="t",
                          MONTE_ADV_OPT="f",
                          MONTE_MS="t",
                          MONTE_REDUCE="0.0001",
                          BIG_PAIRWISE="1.0",
                          MONTE_RUNS="20")
        m.write_runprm(run_dir + "/")
        # run MCCE
        m.write_submitsh("", run_name=str(n))
        call("qsub submit.sh", shell=True)
        time.sleep(10)
        os.chdir(curr_dir)
def main():
    curr_dir = os.getcwd()
    init_struct_dir = os.path.abspath("../data/gramicidin/init_structures")
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    mcce_dir = os.path.abspath("../code/mcce3.5")
    ipece_dir = os.path.abspath("../code/ipece")

    os.chdir(input_dir)
    init_structs = sorted([
        f for f in os.listdir(init_struct_dir)
        if not f.startswith("noh") and f.endswith("pdb")
    ])
    print(init_structs)
    for index, st in enumerate(init_structs):
        formatted_index = "%02d" % index
        print("Processing structure: ", formatted_index)
        st_infile = os.path.join(init_struct_dir, st)
        st_writefile = os.path.join(init_struct_dir, "noh_" + st)
        # remove hydrogens
        reduce_command = "reduce -T %s > %s" % (st_infile, st_writefile)
        os.system(reduce_command)

        # replace termini
        terminal_rep = {
            'CY  VAL': "CA  FOR",
            'OY  VAL': "O   FOR",
            'NT  TRP': "N   ENA",
            'C1  TRP': "CA  ENA",
            'C2  TRP': "CB  ENA",
            'OG  TRP': "OG1 ENA"
        }
        input_struct_file = "%s_%s" % (formatted_index, "input_struct.pdb")
        with open(st_writefile, "r") as oldfile, open(input_struct_file,
                                                      'w') as newfile:
            for line in oldfile:
                atm_res_name = line[13:20]
                for terminal_atom in terminal_rep.keys():
                    if terminal_atom == atm_res_name:
                        new_name = terminal_rep[terminal_atom]
                        #print(line[:13] + atm_res_name + line[20:])
                        #print(line[:13] + new_name + line[20:])
                        line = line[:13] + new_name + line[20:]

                #print(line)
                newfile.write(line)

        # generate a protein step1 file
        m = MCCEParams(mcce_dir)
        m.edit_parameters(INPDB=input_struct_file)
        m.edit_parameters(DO_PREMCCE="t", DO_ROTAMERS="f", TERMINALS="f")
        m.write_runprm(input_dir + "/")
        run_command = m.mcce_directory + "/mcce > prep_struct_run.log"
        os.system(run_command)
        copy2("step1_out.pdb", formatted_index + "_step1_out.pdb")

        # insert membrane
        ipece_parm = os.path.join(ipece_dir, input_dir, "ipece.prm")
        input_pdb = formatted_index + "_step1_out.pdb"
        output_pdb = formatted_index + "_mem_step1_out.pdb"
        # assemble ipece command and run
        run_command = ipece_dir + "/ipece " + ipece_parm + " " + input_pdb + " " + output_pdb
        #print(run_command)
        os.system(run_command)

        # run step 2
        m = MCCEParams(os.path.abspath(mcce_dir))
        m.edit_parameters(DO_PREMCCE="t",
                          DO_ROTAMERS="t",
                          INPDB=os.path.join(input_dir, output_pdb))
        m.write_runprm(input_dir + "/")
        run_command = m.mcce_directory + "/mcce > prep_struct_run.log"
        os.system(run_command)
        copy2("step2_out.pdb", formatted_index + "_step2_out.pdb")

        # fix membrane atom names in step2
        pdb = os.path.join(input_dir, formatted_index + "_step2_out.pdb")
        fixed_pdb = os.path.join(input_dir,
                                 formatted_index + "_final_step2_out.pdb")
        with open(pdb, "r") as f1:
            with open(fixed_pdb, "w") as f2:
                lines = f1.readlines()
                for l in lines:
                    if "EM_ _" in l:
                        l = l.replace("x", "C")
                        l = l.replace("EM_ _", "MEM M")
                        f2.write(l)
                    else:
                        f2.write(l)
        break
    os.chdir(curr_dir)
Ejemplo n.º 4
0
def main():
    # get current working dir
    curr_dir = os.getcwd()
    # set dict for using different water charges
    charge_sets = {"t3p" : [-0.834, 0.417, 0.417], "pm6" : [-2.000, 1.000, 1.000]}
    # fix number of conformers per water to 1
    n_conf = 5
    # obtain water charge set option from the command-line
    prefix = sys.argv[1]
    charge_set = charge_sets[prefix]

    #  set input directories
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    run_dir = os.path.abspath("../data/gramicidin/simulations/wat_charges")
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")
    water_dir = os.path.abspath("../data/gramicidin/water_placement")
    
    # set filenames
    src_run_prm = os.path.join(input_dir, "run.prm")
    src_step2out = os.path.join(input_dir, "00_step2_out.pdb")
    src_newtpl = os.path.join(input_dir, "new.tpl")
    src_ms_gold = os.path.join(input_dir, "new.tpl")

    # copy files to where MCCE will be run
    copy2(src_run_prm, run_dir)
    copy2(src_step2out, run_dir + "/temp_step2_out.pdb")
    copy2(src_newtpl, run_dir)

    # cd to directory where MCCE will be run
    os.chdir(run_dir)

    # generate water conformers
    init_waters = os.path.join(water_dir, "00_init_wat_placement.pdb")
    start_index = get_last_prot_at_index(src_step2out)
    coords = generate_conformers(init_waters, n_conf)
    write_filename = os.path.join(run_dir, "water_confs")
    write_watpdb_from_coords_ext(write_filename, coords, start_index, charge_set)
    water_conformers = write_filename + ".pdb"

    # assemble full step2out
    last_prot_at = get_last_prot_at_index("temp_step2_out.pdb")
    assemble_step2_out(water_conformers, "temp_step2_out.pdb", "step2_out.pdb", last_prot_at)
    # write ms_gold
    write_msgold("step2_out.pdb", "W", "HOH")

    # set up MCCE run
    m = MCCEParams(mcce_exec_dir)
    m.edit_parameters(INPDB="step2_out.pdb",
                    DO_PREMCCE="f", DO_ROTAMERS="f", DO_ENERGY="f",
                    DO_MONTE="t", MONTE_ADV_OPT="f", MONTE_MS="t",
                    MONTE_REDUCE="0.0", BIG_PAIRWISE="1.0", MONTE_RUNS="10")
    m.write_runprm(run_dir + "/")
    copy2(prefix + "_energies.opp", "energies.opp")
    copy2(prefix + "_head3.lst", "head3.lst")

    # run MCCE
    run_command = m.mcce_directory + "/mcce > " + run_dir + "/" + prefix + "_run.log"
    print("Running MCCE ...")
    print(run_command)
    os.system(run_command)

    # post-processing
    copy2("fort.38", prefix + "_fort.38")
    copy2("energies.opp", prefix + "_energies.opp")
    copy2("head3.lst", prefix + "_head3.lst")
    copy2("step2_out.pdb", prefix + "_step2_out.pdb")
    copy2("ms.dat", prefix + "_ms.dat")

    # cd back to where started
    os.chdir(curr_dir)
Ejemplo n.º 5
0
def main():
    # get current working dir
    curr_dir = os.getcwd()
    # set dict for using different water charges
    charge_sets = {
        "t3p": [-0.834, 0.417, 0.417],
        "pm6": [-2.000, 1.000, 1.000]
    }
    # fix number of conformers per water to 1
    n_conf = 1
    # set number of separate MC runs
    n_runs = 1
    # obtain water charge set option from the command-line
    prefix = sys.argv[1]
    charge_set = charge_sets[prefix]

    # set input directories
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    run_dir = os.path.abspath("../data/gramicidin/simulations/mc_type")
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")
    water_dir = os.path.abspath("../data/gramicidin/water_placement")

    # set filenames
    src_run_prm = os.path.join(input_dir, "run.prm")
    src_step2out = os.path.join(input_dir, "00_step2_out.pdb")
    src_newtpl = os.path.join(input_dir, "new.tpl")
    src_ms_gold = os.path.join(input_dir, "new.tpl")

    # copy files to where MCCE will be run
    copy2(src_run_prm, run_dir)
    copy2(src_step2out, run_dir + "/temp_step2_out.pdb")
    copy2(src_newtpl, run_dir)

    # cd to directory where MCCE will be run
    os.chdir(run_dir)

    # get assembled full step2out
    copy2("../wat_charges/" + prefix + "_step2_out.pdb", "step2_out.pdb")
    copy2("../wat_charges/" + prefix + "_head3.lst", "head3.lst")

    write_msgold("step2_out.pdb", "W", "HOH")

    # set up MCCE run
    m = MCCEParams(mcce_exec_dir)
    m.edit_parameters(INPDB="step2_out.pdb",
                      DO_PREMCCE="f",
                      DO_ROTAMERS="f",
                      DO_ENERGY="f",
                      DO_MONTE="t",
                      MONTE_ADV_OPT="t",
                      MONTE_MS="t",
                      MONTE_REDUCE="0.0",
                      BIG_PAIRWISE="-0.5")
    m.write_runprm(run_dir + "/")

    # copy corresponding energy opp files into energies.opp (must ensure these runs are for 00 conf
    copy2("../wat_charges/" + prefix + "_energies.opp", "energies.opp")
    # run MC for n_runs
    for n in range(n_runs):
        prefix = sys.argv[1] + "_%02d" % n
        run_command = m.mcce_directory + "/mcce > " + run_dir + "/" + prefix + "_run.log"
        print("Running MCCE ...")
        print(run_command)
        os.system(run_command)

        # post-processing
        copy2("ms.dat", prefix + "_ms.dat")
        copy2("fort.38", prefix + "_fort.38")
        copy2("head3.lst", prefix + "_head3.lst")

    os.chdir(curr_dir)
Ejemplo n.º 6
0
def main():
    # get current working dir
    curr_dir = os.getcwd()
    # set dict for using different water charges
    charge_sets = {
        "t3p": [-0.834, 0.417, 0.417],
        "pm6": [-2.000, 1.000, 1.000]
    }
    # fix number of conformers per water to 1
    n_conf = 5
    # set number of separate MC runs
    n_runs = 1
    # obtain water charge set option from the command-line
    prefix = sys.argv[1]
    charge_set = charge_sets[prefix]

    # set input directories
    input_dir = os.path.abspath(
        "../data/gramicidin/simulations/input_struct_%s/run_00" % prefix)
    home_dir = os.path.abspath(
        "../data/gramicidin/simulations/vdw_scaling_%s" % prefix)
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")

    scalings = [
        1.0, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4,
        0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.00
    ]
    n_runs = len(scalings)

    src_run_prm = os.path.join(input_dir, "run.prm")
    src_step2out = os.path.join(input_dir, "step2_out.pdb")
    src_newtpl = os.path.join(input_dir, "new.tpl")
    src_head3lst = os.path.join(input_dir, "head3.lst")
    src_energies = os.path.join(input_dir, "energies.opp")
    src_ms_gold = os.path.join(input_dir, "ms_gold")

    #scalings = scalings[:5]
    n_runs = len(scalings)
    # run n different MC simulations, each on a different protein conf and coresponding water orientations
    for n in range(n_runs):
        run_dir = os.path.join(home_dir, "run_%02d" % n)
        print("Run number %d, dir %s" % (n, run_dir))

        if os.path.exists(run_dir):
            rmtree(run_dir)
        os.makedirs(run_dir)
        os.chdir(run_dir)
        # copy files to where MCCE will be run
        copy2(src_run_prm, run_dir)
        copy2(src_newtpl, run_dir)
        copy2(src_step2out, run_dir)
        copy2(src_head3lst, run_dir)
        copy2(src_energies, run_dir)
        copy2(src_ms_gold, run_dir)

        with open("extra.tpl", "w") as f1:
            f1.write("SCALING  VDW0        1.00\n")
            f1.write("SCALING  VDW1        1.00\n")
            f1.write("SCALING  VDW         %s\n" % str(scalings[n]))
            f1.write("SCALING  TORS       1.0\n")
        # set up MCCE run
        extra = os.path.join(run_dir, "extra.tpl")

        m = MCCEParams(mcce_exec_dir)
        m.edit_parameters(INPDB="step2_out.pdb",
                          DO_PREMCCE="f",
                          DO_ROTAMERS="f",
                          DO_ENERGY="f",
                          EXTRA=extra,
                          DO_MONTE="t",
                          MONTE_ADV_OPT="f",
                          MONTE_MS="t",
                          MONTE_REDUCE="0.0001",
                          BIG_PAIRWISE="1.0",
                          MONTE_RUNS="20")
        m.write_runprm(run_dir + "/")
        # run MCCE
        m.write_submitsh("", run_name=str(n))
        call("qsub submit.sh", shell=True)
        time.sleep(10)
        os.chdir(curr_dir)
Ejemplo n.º 7
0
def main():

    # get current working directory
    curr_dir = os.getcwd()
    # set dict for using different water charges
    charge_sets = {"t3p" : [-0.834, 0.417, 0.417], "pm6" : [-2.000, 1.000, 1.000]}
    # fix number of conformers per water to 1
    n_conf = 1

    # obtain water charge set option from the command-line
    prefix = sys.argv[1]
    charge_set = charge_sets[prefix]

    # set input directories
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    run_dir = os.path.abspath("../data/gramicidin/simulations/vdw_scaling_new")
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")
    water_dir = os.path.abspath("../data/gramicidin/water_placement")

    # set filenames
    src_run_prm = os.path.join(input_dir, "run.prm")
    src_step2out = os.path.join(input_dir, "00_step2_out.pdb")
    src_newtpl = os.path.join(input_dir, "new.tpl")
    src_ms_gold = os.path.join(input_dir, "new.tpl")

    # copy files to where MCCE will be run
    copy2(src_run_prm, run_dir)
    copy2(src_step2out, run_dir + "/temp_step2_out.pdb")
    copy2(src_newtpl, run_dir)

    os.chdir(run_dir)

    # get assembled full step2out
    copy2("../wat_charges/" + prefix + "_step2_out.pdb", "step2_out.pdb")
    copy2("../wat_charges/" + prefix + "_energies.opp", "energies.opp")
    copy2("../wat_charges/" + prefix + "_head3.lst", "head3.lst")
    write_msgold("step2_out.pdb", "W", "HOH")
    # set up MCCE run
    scalings = [1.0, 0.95, 0.90, 0.85, 0.80, 0.75, 0.70, 0.65, 0.60, 0.55, 0.50] #, 0.45, 0.40, 0.35, 0.30, 0.25, 0.20, 0.15, 0.10, 0.05, 0.00]
    n_runs = len(scalings)
    for n in range(n_runs):
        with open("extra.tpl", "w") as f1:
            f1.write("#EXTRA energy:\n")
            f1.write("#      Scaling factors for non-bonded energy terms\n")
            f1.write("#\n")
            f1.write("# VDW0: self-vdw\n")
            f1.write("SCALING  VDW0       1.0\n")
            f1.write("# VDW1: bkbone\n")
            f1.write("SCALING  VDW1       %s\n" % str(scalings[n]))
            f1.write("# VDW: pairwise?\n")
            f1.write("SCALING  VDW        %1.0\n")
            f1.write("# TORS: side-chain angles\n")
            f1.write("SCALING  TORS       1.0\n")

            #f1.write("SCALING  VDW0        1.00\n")
            #f1.write("SCALING  VDW1        1.00\n")
            #f1.write("SCALING  TORS       1.0\n")

        extra = os.path.join(run_dir, "extra.tpl")
        m = MCCEParams(mcce_exec_dir)
        m.edit_parameters(INPDB="step2_out.pdb", EXTRA=extra,
                          DO_PREMCCE="f", DO_ROTAMERS="f", DO_ENERGY="f",
                          DO_MONTE="t", MONTE_ADV_OPT="f", MONTE_MS="t",
                          MONTE_REDUCE="0.0", BIG_PAIRWISE="-0.5")
        m.write_runprm(run_dir + "/")
        prefix = sys.argv[1] + "_%02d" % n
        run_command = m.mcce_directory + "/mcce > " + run_dir + "/" + prefix + "_run.log"
        print("Running MCCE ...")
        print(run_command)
        os.system(run_command)
        # post-processing
        copy2("extra.tpl", prefix + "_extra.tpl")
        copy2("run.prm", prefix + "_run.prm")
        copy2("ms.dat", prefix + "_ms.dat")
        copy2("fort.38", prefix + "_fort.38")
        copy2("head3.lst", prefix + "_head3.lst")

    os.chdir(curr_dir)
Ejemplo n.º 8
0
def main():
    curr_dir = os.getcwd()
    charge_sets = {"t3p" : [-0.834, 0.417, 0.417], "pm6" : [-2.000, 1.000, 1.000]}
    n_conf = 1
    n_runs = 10
    prefix = sys.argv[1]
    charge_set = charge_sets[prefix]
    # set input directories
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    run_dir = os.path.abspath("../data/gramicidin/simulations/apolar_gram")
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")
    water_dir = os.path.abspath("../data/gramicidin/water_placement")
    
    # set filenames
    src_run_prm = os.path.join(input_dir, "run.prm")
    src_step2out = os.path.join(input_dir, "00_step2_out.pdb")
    src_newtpl = os.path.join(input_dir, "new.tpl")
    src_ms_gold = os.path.join(input_dir, "new.tpl")

    # copy files to where MCCE will be run
    copy2(src_run_prm, run_dir)
    copy2(src_step2out, run_dir + "/temp_step2_out.pdb")
    copy2(src_newtpl, run_dir)

    os.chdir(run_dir)

    with open(src_step2out, "r") as f1, open("temp_step2_out.pdb", "w") as f2:
        for l in f1.readlines():
            if "EM" not in l:
                new_l = l[:68] + " 0.000" + l[74:]
                f2.write(new_l)
            else:
                f2.write(l)

    init_waters = os.path.join(water_dir, "00_init_wat_placement.pdb")
    start_index = get_last_prot_at_index(src_step2out)
    coords = generate_conformers(init_waters, n_conf)
    write_filename = os.path.join(run_dir, "water_confs")
    write_watpdb_from_coords_ext(write_filename, coords, start_index, charge_set)
    water_conformers = write_filename + ".pdb"

    # assemble full step2out
    last_prot_at = get_last_prot_at_index("temp_step2_out.pdb")
    assemble_step2_out(water_conformers, "temp_step2_out.pdb", "step2_out.pdb", last_prot_at)


    write_msgold("step2_out.pdb", "W", "HOH")
    # set up MCCE run
    m = MCCEParams(mcce_exec_dir)
    m.edit_parameters(INPDB="step2_out.pdb",
                    DO_PREMCCE="f", DO_ROTAMERS="f", DO_ENERGY="t",
                    DO_MONTE="t", MONTE_ADV_OPT="f", MONTE_MS="t",
                    MONTE_REDUCE="0.0", BIG_PAIRWISE="-0.5")
    m.write_runprm(run_dir + "/")
    # run MCCE

    #copy2(prefix + "energies.opp", "energies.opp")
    for n in range(n_runs):
        prefix = sys.argv[1] + "_%02d" % n
        run_command = m.mcce_directory + "/mcce > " + run_dir + "/" + prefix + "_run.log"
        print("Running MCCE ...")
        print(run_command)
        os.system(run_command)
        # post-processing
        copy2("ms.dat", prefix + "_ms.dat")
        copy2("fort.38", prefix + "_fort.38")
        copy2("head3.lst", prefix + "_head3.lst")        
        copy2("energies.opp", prefix + "_energies.opp")

    os.chdir(curr_dir)
def main():
    curr_dir = os.getcwd()
    charge_sets = ["t3p", "pm6"]
    chg = sys.argv[1]
    if chg not in charge_sets:
        sys.exit("Charge set %s not allowed!" % chg)
    # input directories
    input_dir = os.path.abspath("../data/gramicidin/prep_structures")
    run_dir = os.path.abspath("../data/gramicidin/simulations/wat_charges")
    mcce_exec_dir = os.path.abspath("../code/mcce3.5")
    water_dir = os.path.abspath("../data/gramicidin/water_placement")

    # filenames
    src_run_prm = os.path.join(input_dir, "run.prm")
    src_step2out = os.path.join(input_dir, "fixed_step2_out.pdb")
    src_newtpl = os.path.join(input_dir, "new.tpl")
    src_ms_gold = os.path.join(input_dir, "new.tpl")
    # copy files to where MCCE will be run
    copy2(src_run_prm, run_dir)
    copy2(src_step2out, run_dir + "/temp_step2_out.pdb")
    copy2(src_step2out, run_dir + "/ms_gold")
    copy2(src_newtpl, run_dir)

    prefix = chg + "_"
    n_conf = "%02d" % 1
    water_conformers = os.path.join(
        water_dir,
        str(n_conf) + "_n_conf_perwater_" + chg + ".pdb")

    # assemble full step2out
    os.chdir(run_dir)
    last_prot_at = get_last_prot_at_index("temp_step2_out.pdb")
    assemble_step2_out(water_conformers, "temp_step2_out.pdb", "step2_out.pdb",
                       last_prot_at)
    write_msgold("step2_out.pdb", "W", "HOH")
    # set up MCCE run
    m = MCCEParams(mcce_exec_dir)
    m.edit_parameters(INPDB="step2_out.pdb",
                      DO_PREMCCE="f",
                      DO_ROTAMERS="f",
                      DO_ENERGY="f",
                      DO_MONTE="t",
                      MONTE_ADV_OPT="f",
                      MONTE_MS="t",
                      MONTE_REDUCE="0.0",
                      BIG_PAIRWISE="-0.5")
    m.write_runprm(run_dir + "/")

    # run MCCE
    run_command = m.mcce_directory + "/mcce > " + run_dir + "/" + prefix + "run.log"
    print("Running MCCE ...")
    print(run_command)
    copy2(prefix + "energies.opp", "energies.opp")

    os.system(run_command)

    # post-processing
    copy2("fort.38", prefix + "fort.38")
    copy2("energies.opp", prefix + "energies.opp")
    copy2("head3.lst", prefix + "head3.lst")
    copy2("ms.dat", prefix + "ms.dat")
    copy2("step2_out.pdb", prefix + "step2_out.pdb")

    os.chdir(curr_dir)