예제 #1
0
def test_Runner_openmm_other_settings(tmp_path):
    if not os.path.exists(tmp_path):
        os.mkdir(tmp_path)
    mymodel = make_test_model.make_test_model(tmp_path)
    #sim_openmm_factory = sim_openmm.Sim_openmm_factory()
    myanchor = mymodel.anchors[1]
    mmvt_output_filename = os.path.join(
        tmp_path, myanchor.name, "prod", "%s%d.%s" %
        (mmvt_base.OPENMMVT_BASENAME, 1, mmvt_base.OPENMMVT_EXTENSION))
    loading_state_filename = os.path.join(tmp_path, "start.state")
    runner = runner_openmm.Runner_openmm(mymodel, myanchor)
    default_output_file, state_file_prefix, restart_index = runner.prepare(
        False, True)
    my_sim_openmm = mmvt_sim_openmm.create_sim_openmm(mymodel, myanchor,
                                                      mmvt_output_filename,
                                                      state_file_prefix)

    my_sim_openmm.simulation.saveState(loading_state_filename)

    runner.run(my_sim_openmm, False, load_state_file=loading_state_filename)
    assert my_sim_openmm.integrator.getOutputFileName() == mmvt_output_filename
    lines = 0
    assert os.path.exists(mmvt_output_filename)
    assert os.path.exists(loading_state_filename)
    #print("glob.glob(state_file_prefix+'*')", glob.glob(state_file_prefix+'*'))
    #assert len(glob.glob(state_file_prefix+'*')) > 0
    with open(mmvt_output_filename, "r") as f:
        for line in f:
            lines += 1
예제 #2
0
def test_mmvt_sim_openmm_forcefield(tmp_path):

    mymodel = make_test_model.make_test_model(tmp_path, mode='forcefield')
    myanchor = mymodel.anchors[1]
    output_file = os.path.join(tmp_path, "output.txt")
    my_sim_openmm = mmvt_sim_openmm.create_sim_openmm(mymodel, myanchor,
                                                      output_file)
    return
예제 #3
0
def test_mmvt_sim_namd_amber(tmp_path):

    mymodel = make_test_model.make_test_model(tmp_path, engine="namd")
    myanchor = mymodel.anchors[1]
    output_file = os.path.join(tmp_path, "output.txt")
    my_sim_openmm = mmvt_sim_namd.create_sim_namd(mymodel, myanchor,
                                                  output_file)
    return
예제 #4
0
def test_Runner_openmm_forcefield(tmp_path):
    if not os.path.exists(tmp_path):
        os.mkdir(tmp_path)
    mymodel = make_test_model.make_test_model(tmp_path, mode="forcefield")
    #sim_openmm_factory = sim_openmm.Sim_openmm_factory()
    myanchor = mymodel.anchors[1]
    mmvt_output_filename = os.path.join(
        tmp_path, myanchor.name, "prod", "%s%d.%s" %
        (mmvt_base.OPENMMVT_BASENAME, 1, mmvt_base.OPENMMVT_EXTENSION))
    runner = runner_openmm.Runner_openmm(mymodel, myanchor)
    default_output_file, state_file_prefix, restart_index = runner.prepare()
    my_sim_openmm = mmvt_sim_openmm.create_sim_openmm(mymodel, myanchor,
                                                      mmvt_output_filename)

    runner.run(my_sim_openmm, False)

    assert os.path.exists(mmvt_output_filename)
    lines = 0
    with open(mmvt_output_filename, "r") as f:
        for line in f:
            lines += 1
예제 #5
0
def test_Runner_namd_default(tmp_path):
    if not os.path.exists(tmp_path):
        os.mkdir(tmp_path)
    mymodel = make_test_model.make_test_model(tmp_path, engine="namd")
    #sim_namd_factory = sim_namd.Sim_namd_factory()
    myanchor = mymodel.anchors[1]
    mmvt_output_filename = os.path.join(
                    tmp_path, myanchor.name, "prod", 
                    "%s%d" % (mmvt_base.NAMDMMVT_BASENAME, 1))
    namd_command = "namd2"
    namd_arguments = ""
    runner = runner_namd.Runner_namd(mymodel, myanchor, namd_command, 
                                     namd_arguments)
    default_output_file, output_basename, state_file_prefix, restart_index = \
    runner.prepare()
    #sim_namd_factory = sim_namd.Sim_namd_factory()
    my_sim_namd = mmvt_sim_namd.create_sim_namd(mymodel, myanchor, 
                                                      mmvt_output_filename)
    my_sim_namd.namd_root.periodic_boundary_conditions.PMEGridSpacing = None
    print("PME turned off")
    runner.run(my_sim_namd, mmvt_output_filename+".out")
    myglob = mmvt_output_filename+".out*"
    outfiles = glob.glob(myglob)
    outfile = outfiles[0]
    assert os.path.exists(outfile)
    has_correct_line1 = False
    has_correct_line2 = False
    with open(outfile,"r") as f:
        for line in f:
            if re.search("^WallClock", line):
                has_correct_line1 = True
            if re.search("^WRITING", line):
                has_correct_line2 = True
    assert has_correct_line1 == True
    assert has_correct_line2 == True
    """
    namd_arguments = "+wtf"
    runner = runner_namd.Runner_namd(mymodel, myanchor, namd_command, 
                                     namd_arguments)
    default_output_file, output_basename, state_file_prefix, restart_index = \
    runner.prepare(force_overwrite=True)
    #sim_namd_factory = sim_namd.Sim_namd_factory()
    my_sim_namd = mmvt_sim_namd.create_sim_namd(mymodel, myanchor, 
                                                      mmvt_output_filename)
    runner.run(my_sim_namd, mmvt_output_filename+".out")
    myglob = mmvt_output_filename+".out*"
    outfiles = glob.glob(myglob)
    outfile = outfiles[0]
    assert os.path.exists(outfile)
    has_correct_line1 = False
    has_correct_line2 = False
    with open(outfile,"r") as f:
        for line in f:
            print("line:", line)
            
            if re.search("^WallClock", line):
                has_correct_line1 = True
            if re.search("^WRITING", line):
                has_correct_line2 = True
    
    with pytest.raises(Exception):
        assert has_correct_line1 == True
    with pytest.raises(Exception):
        assert has_correct_line2 == True
    """
    return
예제 #6
0
def test_runner_browndye2_b_surface_default(tmp_path):
    model = make_test_model.make_test_model(tmp_path)
    b_surface_abs_path = os.path.join(tmp_path, "b_surface")
    receptor_pqr_filename = os.path.join(
        b_surface_abs_path, model.browndye_settings.receptor_pqr_filename)
    ligand_pqr_filename = os.path.join(
        b_surface_abs_path, model.browndye_settings.ligand_pqr_filename)
    bd_milestone = model.k_on_info.bd_milestones[0]

    ghost_index_rec = \
                sim_browndye2.add_ghost_atom_to_pqr_from_atoms_center_of_mass(
                    receptor_pqr_filename, bd_milestone.receptor_indices)
    ghost_index_lig = \
                sim_browndye2.add_ghost_atom_to_pqr_from_atoms_center_of_mass(
                    ligand_pqr_filename, bd_milestone.ligand_indices)
    assert ghost_index_rec == 148
    assert ghost_index_lig == 16

    receptor_xml_filename = sim_browndye2.make_pqrxml(receptor_pqr_filename)
    ligand_xml_filename = sim_browndye2.make_pqrxml(ligand_pqr_filename)

    debye_length, reaction_filename = \
        runner_browndye2.make_browndye_input_xml(
        model, tmp_path, receptor_xml_filename, ligand_xml_filename,
        model.k_on_info.b_surface_num_steps)
    model.browndye_settings.debye_length = debye_length
    assert os.path.exists(os.path.join(b_surface_abs_path, "apbs_input.xml"))
    assert os.path.exists(os.path.join(b_surface_abs_path, "input.xml"))
    abs_reaction_path = os.path.join(b_surface_abs_path, reaction_filename)
    runner_browndye2.make_browndye_reaction_xml(model, abs_reaction_path)
    assert os.path.exists(abs_reaction_path)
    bd_directory = b_surface_abs_path
    runner_browndye2.run_bd_top(model.browndye_settings.browndye_bin_dir,
                                bd_directory)
    #runner_browndye2.modify_variables(bd_directory, 10000)
    runner_browndye2.run_nam_simulation(
        model.browndye_settings.browndye_bin_dir, bd_directory,
        model.k_on_info.bd_output_glob)
    #assert os.path.exists(os.path.join(b_surface_abs_path, "results.xml"))
    assert len(glob.glob(os.path.join(b_surface_abs_path, "results*.xml"))) > 0
    """
    bd_milestone_abs_path = os.path.join(tmp_path, bd_milestone.directory)
    assert os.path.exists(bd_milestone_abs_path)
    runner_browndye2.extract_bd_surface(model, bd_milestone, 10)
    bd_directory_list = runner_browndye2.make_fhpd_directories(
        model, bd_milestone)
    
    for bd_directory in bd_directory_list:
        runner_browndye2.run_bd_top(model.browndye_settings.browndye_bin_dir, 
                           bd_directory)
        runner_browndye2.modify_variables(bd_directory, n_trajectories=1000)
        runner_browndye2.run_nam_simulation(
            model.browndye_settings.browndye_bin_dir, bd_directory, 
            model.k_on_info.bd_output_glob)
    
    runner_browndye2.combine_fhpd_results(
        model, bd_milestone, bd_directory_list)
    assert os.path.exists(os.path.join(bd_milestone_abs_path, "results.xml"))
    """
    return


# TODO: bd_milestone test runs