Example #1
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)
Example #2
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():
    # 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)
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)