Exemplo n.º 1
0
if environ.get("TRAVIS"):
    max_examples = 100
    deadline = None
else:
    max_examples = 1000
    deadline = None

merge_command = "bedtools merge -o first -c 6 {} -i <(sort -k1,1 -k2,2n {})"


@pytest.mark.bedtools
@pytest.mark.parametrize("strand", [True, False])
@settings(max_examples=max_examples,
          deadline=deadline,
          suppress_health_check=HealthCheck.all())
@given(gr=dfs_min())  # pylint: disable=no-value-for-parameter
def test_merge(gr, strand):

    bedtools_strand = {True: "-s", False: ""}[strand]

    print(gr)

    with tempfile.TemporaryDirectory() as temp_dir:
        f1 = "{}/f1.bed".format(temp_dir)
        gr.df.to_csv(f1, sep="\t", header=False, index=False)

        cmd = merge_command.format(bedtools_strand, f1)
        print(cmd)

        # ignoring bandit security warning. All strings created by test suite
        result = subprocess.check_output(  # nosec
Exemplo n.º 2
0
                       s4vectors_result.runs,
                       equal_nan=False)
    assert np.allclose(result_pyranges.values,
                       s4vectors_result.values,
                       equal_nan=True)


rle_commute_how = ["__add__", "__mul__"]


@pytest.mark.parametrize("how", rle_commute_how)
@settings(max_examples=max_examples,
          deadline=deadline,
          timeout=unlimited,
          suppress_health_check=HealthCheck.all())
@given(gr=dfs_min(), gr2=dfs_min())
def test_commutative_rles(gr, gr2, how):

    cv = gr.to_rle(strand=True)
    cv2 = gr2.to_rle(strand=True)

    method = getattr(cv, how)
    method2 = getattr(cv2, how)

    result = method(cv2)
    result2 = method2(cv)

    assert result == result2, "\n".join(
        [str(e) for e in [cv, cv2, result, result2, "---" * 10]])