コード例 #1
0
def test_str_cli_generator():
    """
    Tests if str_cli_generator() is working correctlly.
    """
    # Define arguments
    arg = mockups.Arguments()
    k_val = 4
    outfile = "str_K4_rep1"
    arg.params = None
    seed = None

    mock_cli = ["EP", "-K", str(k_val), "-i", "IF", "-o", outfile]
    returned_cli, returned_outfile = sw.str_cli_generator(arg, k_val, 1, seed)

    assert returned_cli == mock_cli
    assert returned_outfile == outfile

    # Add a seed to the test
    seed = "1234"
    mock_cli += ["-D", "1234"]
    returned_cli, returned_outfile = sw.str_cli_generator(arg, k_val, 1, seed)

    assert returned_cli == mock_cli
    assert returned_outfile == outfile

    # Add an argument to the test
    arg.params = "test"

    mock_cli += arg.params
    returned_cli, returned_outfile = sw.str_cli_generator(arg, k_val, 1, seed)

    assert returned_cli == mock_cli
    assert returned_outfile == outfile
コード例 #2
0
def test_str_param_checker():
    """
    Tests if the STRUCTURE parameter file checker is working.
    """
    arg = mockups.Arguments()
    arg.infile = "smalldata/Reduced_dataset.structure"
    arg.params = "mainparams"
    sw.str_param_checker(arg)
    assert arg.params == ["-m", "mainparams", "-e", "extraparams"]
コード例 #3
0
def test_vcf_to_matrix():
    """
    Tests if vcf_to_matrix() is working correctlly.
    Converts a known file, and compares the result with a known good conversion
    """
    # Define arguments
    arg = mockups.Arguments()
    arg.infile = "smalldata/SmallTestData.vcf"
    k_val = 4
    alsw.vcf_to_matrix(arg.infile)

    assert filecmp.cmp(arg.infile[:-4] + ".tsv",
                       "smalldata/SmallTestData_reference.tsv")
コード例 #4
0
def test_alstr_cli_generator():
    """
    Tests if alstr_cli_generator() is working correctlly.
    """
    # Define arguments
    arg = mockups.Arguments()
    arg.infile += ".bed"
    k_val = 4

    # "Rscript", arg.external_prog, infile, str(k_val), output_file

    mock_cli = ["Rscript", "EP", "IF", str(k_val), "alstr_K4"]

    returned_cli, out_file = alsw.alstr_cli_generator(arg, k_val)
    assert returned_cli == mock_cli
    assert out_file == "alstr_K4"
コード例 #5
0
def test_mav_cli_generator():
    """
    Tests if mav_cli_generator() is working correctlly.
    """
    # Define arguments
    arg = mockups.Arguments()
    k_val = 4
    parameters = {}

    mock_cli = ["EP", "-Kmin", str(k_val), "-Kmax", str(k_val), "-data",
                "IF", "-outputRoot", "mav_K4/", "-masterRoot", "/",
                "-parameters", "smalldata/parameters.txt"]

    # Perform test with and without TI
    for ti_value in (False, True):
        arg.notests = ti_value
        if arg.notests is True:
            mock_cli += ["-thermodynamic_on", "f"]

        returned_cli, out_dir = mw.mav_cli_generator(arg, k_val, parameters)
        assert returned_cli == mock_cli
        assert out_dir == "mav_K4/"
def test_fs_cli_generator():
    """
    Tests if fs_cli_generator() is working correctlly.
    """
    # Define arguments
    arg = mockups.Arguments()
    k_val = 4

    for prog in ["EP", "EP.py"]:

        arg.external_prog = prog
        mock_cli = [
            prog, "-K",
            str(k_val), "--input", "IF", "--output", "fS_run_K", "--format",
            "str", "--prior=logistic"
        ]
        if prog.endswith(".py"):
            mock_cli = ["python2"] + mock_cli

        returned_cli, returned_outdir = fsw.fs_cli_generator(k_val, arg)

        assert returned_cli == mock_cli
        assert returned_outdir == "fS_run_K"