示例#1
0
def test_analysis_flags(yaml_file, n_expected_outputs, expected_files):
    """
    Runs full simulation with input.yaml with some unusual flags, check the number of created plots and their names to
    ensure correct metrics were take into account.
    Parameters
    ----------
    yaml_file : str
        Path to input.yaml
    n_expected_outputs : int
        Number of expected plots.
    expected_files : List[str]
        List of expected plot names.
    Returns
    -------
        Folder with plots
    """
    output_folder = "../pele_platform/Examples/analysis/data/results/plots/"
    if os.path.exists(output_folder):
        shutil.rmtree(output_folder)

    main.run_platform(yaml_file)

    for file in expected_files:
        file_path = os.path.join(output_folder, file)
        assert os.path.exists(file_path)

    all_files = glob.glob(os.path.join(output_folder, "*png"))
    assert len(all_files) == n_expected_outputs
示例#2
0
def test_analysis_flag(ext_args=ANALYSIS_FLAGS):
    main.run_platform(ext_args)
    assert os.path.exists(
        "data/results/Plots/numberOfAcceptedPeleSteps_currentEnergy_distance0_plot.png"
    )
    assert os.path.exists(
        "data/results/Plots/distance0_currentEnergy_plot.png")
    assert len(glob.glob("data/results/Plots/*.png")) == 2
示例#3
0
def test_rotamer_error(yaml=yaml):
    try:
        job = main.run_platform(yaml)
    except ce.RotamersFileNotFound as e:
        assert str(e).strip("'") == "File mgadeaz not found"
        return
    assert False
def test_lig_preparation_error(args=LIG_PREP_ARGS):
    try:
        job = main.run_platform(args)
    except ce.LigandPreparationError:
        assert True
        return
    assert False
示例#5
0
def test_mutagenesis_production():
    """
    Tests end-to-end saturated mutagenesis run on 5 CPUs to make sure we get the right output and pele.conf looks
    as expected (i.e. has induced_fit_exhaustive defaults).
    TODO: This is a very primitive implementation, needs a lot more testing!
    """
    yaml = os.path.join(test_path, "saturated_mutagenesis.yaml")
    all_jobs = main.run_platform(yaml)

    # List of mutated PDBs expected in each job
    expected_pdbs = [('T454A_processed.pdb', 'T454D_processed.pdb'),
                     ('T454E_processed.pdb', )]

    for i, job in enumerate(all_jobs):
        # Output files exist
        output_files = glob.glob(os.path.join(job.pele_dir, job.output, "*/traj*.pdb"))
        assert output_files

        # Check if the default induced fit exhaustive lines are present in pele configuration file
        induced_fit_lines = test_adaptive_defaults.INDUCE_FIT_PELE
        errors = test_adaptive_defaults.check_file(job.pele_dir, "pele.conf", induced_fit_lines, [])
        assert not errors

        # Make sure all subset directories have correct names
        assert "Subset" in os.path.basename(job.pele_dir)

        # Analysis should not run
        results_folder = os.path.exists(os.path.join(job.pele_dir, "results"))
        assert not results_folder

        # Check if the jobs were properly split between subsets based on available CPUs
        job_dir = os.path.join(job.pele_dir, "input", "*.pdb")
        job_input = [os.path.basename(file) for file in glob.glob(job_dir)]
        for expected_pdb in expected_pdbs[i]:
            assert expected_pdb in job_input
示例#6
0
def test_yaml_errors(yaml_file, error):
    try:
        job = main.run_platform(yaml_file)
    except Exception as e:
        assert str(e) == error
        return
    assert False
示例#7
0
def test_global_defaults(ext_args=GLOBAL_ARGS):
    errors = []
    job = main.run_platform(ext_args)
    errors = check_file(job.pele_dir, "adaptive.conf", GLOBAL_DEFAULTS_ADAPTIVE, errors)
    errors = check_file(job.pele_dir, "pele.conf", GLOBAL_DEFAULTS_PELE, errors)
    assert len(glob.glob(os.path.join(job.inputs_dir, "input*.pdb"))) == (job.cpus-1)
    assert not errors
def test_gpcr_defaults(ext_args=GPCR_ARGS):
    errors = []
    job = main.run_platform(ext_args)
    errors = check_file(job.pele_dir, "adaptive.conf", GPCR_DEFAULTS_ADAPTIVE,
                        errors)
    errors = check_file(job.pele_dir, "pele.conf", GPCR_DEFAULTS_PELE, errors)
    assert not errors
def test_rescoring_defaults(ext_args=RESCORING_ARGS):
    errors = []
    job = main.run_platform(ext_args)
    errors = check_file(job.pele_dir, "adaptive.conf", REF_DEFAULTS_ADAPTIVE,
                        errors)
    errors = check_file(job.pele_dir, "pele.conf", REF_DEFAULTS_PELE, errors)
    assert not errors
示例#10
0
def test_water(yaml=yaml):

    water_lines = [
        "HETATM 1699  OW  HOH A 202      51.000  92.000  14.000  1.00  0.00           O",
        "HETATM 1700 1HW  HOH A 202      51.757  92.586  14.000  1.00  0.00           H",
        "HETATM 1701 2HW  HOH A 202      50.243  92.586  14.000  1.00  0.00           H",
        "HETATM 1702  OW  HOH A 203      71.000  60.000  20.000  1.00  0.00           O",
        "HETATM 1703 1HW  HOH A 203      71.757  60.586  20.000  1.00  0.00           H",
        "HETATM 1704 2HW  HOH A 203      70.243  60.586  20.000  1.00  0.00           H",
        "HETATM 1705  OW  HOH A 204      82.000  86.000  74.000  1.00  0.00           O",
        "HETATM 1706 1HW  HOH A 204      82.757  86.586  74.000  1.00  0.00           H",
        "HETATM 1707 2HW  HOH A 204      81.243  86.586  74.000  1.00  0.00           H"
    ]

    water_output = []

    # Function to test
    job = main.run_platform(yaml)

    # checkpoints
    output = glob.glob(os.path.join(job.pele_dir,
                                    "results/top_poses/0.1.0*"))[0]

    with open(output, "r") as file:
        lines = file.readlines()

        for line in lines:
            if line[17:21].strip() == "HOH":
                water_output.append(line.strip())

    # test
    assert water_lines == water_output
def test_induced_fast_defaults(ext_args=INDUCED_FAST_ARGS):
    errors = []
    job = main.run_platform(ext_args)
    errors = check_file(job.pele_dir, "adaptive.conf",
                        INDUCE_FIT_FAST_DEFAULTS_ADAPTIVE, errors)
    errors = check_file(job.pele_dir, "pele.conf", INDUCE_FIT_PELE, errors)
    assert not errors
def test_softexit_defaults(ext_args=EXITSOFT_ARGS):
    errors = []
    job = main.run_platform(ext_args)
    errors = check_file(job.pele_dir, "adaptive.conf",
                        EXIT_SOFT_DEFAULTS_ADAPTIVE, errors)
    errors = check_file(job.pele_dir, "pele.conf", EXIT_DEFAULTS_PELE, errors)
    assert not errors
示例#13
0
def test_env_variable(ext_args=ENV_ARGS):
    try:
        job = main.run_platform(ext_args)
    except ce.EnvVariableNotFound as e:
        assert True
        return
    assert False
示例#14
0
def test_sdf_joiner(ext_args=FRAG_JOINER_ARGS):
    files = glob.glob(ext_args)
    for file in files:
        try:
            job = main.run_platform(file)
        except Exception:
            assert False
def test_allosteric_skipref(yaml=yaml):

    job, job2 = main.run_platform(yaml)
    refinement_simulation = os.path.join(os.path.dirname(job.pele_dir), "2_refinement_simulation")
    # checkpoints
    assert not os.path.exists(refinement_simulation)
    assert not job2
def test_all_metal_constraints(ext_args=ALL_METAL_CONSTR_ARGS,
                               ext_args_permissive=PERMISSIVE_EXCEPTION):

    # checks constrain_all_metals -> should add whatever atoms in range
    errors = []
    job = main.run_platform(ext_args)
    errors = tk.check_file(job.pele_dir, "pele.conf", ALL_METAL_CONSTR, errors)
    assert not errors

    # same system, but permissive -> should fail due to lack of geometry
    try:
        job = main.run_platform(ext_args_permissive)
    except ce.NoGeometryAroundMetal:
        assert ce.NoGeometryAroundMetal
        return
    assert False
示例#17
0
def test_input_yaml_error():
    yaml = os.path.join(test_path, "gpcr/complex.pdb")
    try:
        job = main.run_platform(yaml)
    except ce.WrongYamlFile:
        assert True
        return
    assert False
示例#18
0
def test_atom_error(ext_args=ATOM_GPCR_ERROR_ARGS):
    try:
        job = main.run_platform(ext_args)
    except ce.WrongAtomSpecified as e:
        assert str(e).strip(
            "'") == "Atom A:114:CM could not be found in structure"
        return
    assert False
示例#19
0
def test_atom_string_underscore(yaml=yaml):
    try:
        job = main.run_platform(yaml)
    except ce.WrongAtomStringFormat as e:
        assert (
            str(e).strip("'") ==
            "The specified atom is wrong 'A_106:OH'. Should be 'chain:resnumber:atomname"
        )
def test_permissive_constraints(passed=PASS_PERMISSIVE_METAL_CONSTR_ARGS,
                                failed=FAIL_PERMISSIVE_METAL_CONSTR_ARGS):

    # non-permissive -> supposed to fail due to lack of geometry
    try:
        job = main.run_platform(failed)
    except ce.NoGeometryAroundMetal:
        assert ce.NoGeometryAroundMetal
        return
    assert False

    # same system, but permissive -> should add constraints around the metal
    errors = []
    job = main.run_platform(passed)
    errors = tk.check_file(job.pele_dir, "pele.conf", PASS_METAL_CONSTR,
                           errors)
    assert not errors
示例#21
0
def test_polarisation(ext_args_true=POLARISATION_ARGS,
                      ext_args_false=SQUARE_PLANAR_ARGS):

    # no polarisation
    job1 = main.run_platform(ext_args_false)
    mg_template_file_false = glob.glob(
        os.path.join(job1.pele_dir,
                     "DataLocal/Templates/OPLS2005/HeteroAtoms/mgz"))
    assert not mg_template_file_false

    # polarisation with factor 10
    errors = []
    job2 = main.run_platform(ext_args_true)
    errors = tk.check_file(job2.pele_dir,
                           "DataLocal/Templates/OPLS2005/HeteroAtoms/mgz",
                           POLARISATION, errors)
    assert not errors
def test_site_finder_skipref():
    yaml_file = os.path.join(test_path, "site_finder/input_skipref.yaml")
    job, job2 = main.run_platform(yaml_file)
    refinement_simulation = os.path.join(os.path.dirname(job.pele_dir),
                                         "2_refinement_simulation")

    assert not os.path.exists(refinement_simulation)
    assert not job2
示例#23
0
def test_out_in_flag(yaml=yaml):
    try:
        job = main.run_platform(yaml)
    except ce.OutInError as e:
        assert (str(e).strip("'") ==
                "flag final_site must be specified for out_in package")
        return
    assert False
示例#24
0
def test_gpcr(args=GPCR_ARGS):
    errors = []
    job = main.run_platform(args)
    errors = check_file(job.pele_dir, "pele.conf", GPCR_VALUES, errors)
    input_file = os.path.join(job.inputs_dir, "complex_processed.pdb")
    if not os.path.exists(input_file):
        errors.append("skip_ppp")
    assert not errors
示例#25
0
def test_flag_similarity():
    yaml = os.path.join(test_path, "checker/input.yaml")
    try:
        job = main.run_platform(yaml)
    except KeyError as e:
        assert str(e).strip("'") == "Incorrect flag posis. Did you mean poses?"
        return
    assert False
示例#26
0
def test_str_pca(ext_args=PCA2_ARGS, output="PCA_result"):
    if os.path.exists(output):
        shutil.rmtree(output, ignore_errors=True)
    errors = []
    job = main.run_platform(ext_args)
    folder = job.folder
    errors = check_file(folder, "pele.conf", PCA_VALUES, errors)
    assert not errors
示例#27
0
def test_checker():
    yaml = os.path.join(test_path, "checker/input.yaml")
    try:
        job = main.run_platform(yaml)
    except KeyError:
        assert KeyError
        return
    assert False
示例#28
0
def test_water_with_previous_water(yaml=yaml_previous_water):
    # Function to test
    errors = []
    job = main.run_platform(yaml)
    errors = tk.check_file(job.pele_dir, "pele.conf", WATER_PREVIOUS_PELE,
                           errors)
    errors = tk.check_file(job.pele_dir, "adaptive.conf",
                           WATER_PREVIOUS_ADAPTIVE, errors)
    assert not errors
def test_allosteric_skipref(yaml=yaml):

    job, _ = main.run_platform(yaml)

    # checkpoints
    files_refinement = glob.glob(os.path.join(job.pele_dir, "refinement_simulation/results/BestStructs/epoch*"))

    # test
    assert not files_refinement
def test_allosteric_restart(yaml=yaml):
    job, job2 = main.run_platform(yaml)
    # checkpoints
    output_csv = pd.read_csv(os.path.join(job.pele_dir, "output/clustering_output.csv"))
    nfiles = len(glob.glob(os.path.join(os.path.dirname(job.pele_dir), "refinement_input/*.pdb")))
    nfiles_refinement = len(glob.glob(os.path.join(job2.pele_dir, "results/BestStructs/epoch*")))
    # test
    assert nfiles == job.n_components 
    assert nfiles_refinement