def test_gaps():
    hg19 = Genome("hg19", chromosomes=["chr1"])
    assert "chr1" in hg19
    assert "chr2" not in hg19
    filled = hg19.filled(chromosomes=["chr1"])
    hg19.bed_to_sequence(filled)
    hg19.delete()
def test_tessellate():
    hg19 = Genome("hg19", chromosomes=["chrM"])
    filled = hg19.filled(chromosomes=["chrM"])
    tessellate_bed(filled, window_size=200, alignment="left")
    tessellate_bed(filled, window_size=200, alignment="right")
    tessellate_bed(filled, window_size=200, alignment="center")
    hg19.delete()
def test_simulated_download_failure():
    for _ in Genome("sacCer3", chromosomes=sacCer3_chromosomes).items():
        pass
    sacCer3 = Genome("sacCer3", chromosomes=sacCer3_chromosomes)
    path = sacCer3._chromosome_path("chrI")
    with open(path, "w") as f:
        f.write("Totally not JSON")
    with pytest.raises(Exception):
        sacCer3 = Genome("sacCer3", chromosomes=sacCer3_chromosomes)
    sacCer3.delete()
def test_create_new_genome_object():
    sacCer3 = Genome(
        "sacCer3",
        chromosomes=sacCer3_chromosomes,
    )
    for path in glob("{path}/*.json".format(path=sacCer3.path)):
        os.remove(path)
    with pytest.warns(RuntimeWarning):
        sacCer3 = Genome("sacCer3", chromosomes=sacCer3_chromosomes)
    sacCer3 = Genome("sacCer3", chromosomes=sacCer3_chromosomes)
    sacCer3.gaps()
    sacCer3.filled()
    str(sacCer3)
    sacCer3.delete()
Beispiel #5
0
def test_wiggle():
    hg19 = Genome("hg19", chromosomes=["chr17"])
    filled = hg19.filled(chromosomes=["chr17"])
    wiggles = wiggle_bed_regions(
        filled,
        max_wiggle_size=100,
        wiggles=10,
        seed=42
    )
    path = "{pwd}/expected_wiggles.csv".format(
        pwd=os.path.dirname(os.path.abspath(__file__))
    )
    if not os.path.exists(path):
        wiggles.to_csv(path, index=False)
    pd.testing.assert_frame_equal(
        wiggles,
        pd.read_csv(path),
        check_dtype=False
    )
    hg19.delete()
Beispiel #6
0
def test_gaps():
    hg19 = Genome("hg19", chromosomes=["chr1"])
    assert "chr1" in hg19
    assert "chr2" not in hg19
    # Check that no gap is with 0 length
    gaps = hg19.gaps(["chr1"])
    assert (gaps.chromEnd - gaps.chromStart != 0).all()
    # Converting gaps to sequences: should all be Nns
    gaps_tesselate = tessellate_bed(gaps, 200, verbose=False)
    gaps_sequences = hg19.bed_to_sequence(gaps_tesselate)
    for gap in gaps_sequences:
        assert set(gap.lower()) == set(["n"])
    filled = hg19.filled(["chr1"])
    assert (filled.chromEnd - filled.chromStart != 0).all()
    filled_tesselate = tessellate_bed(filled, 200, verbose=False)
    filled_sequences = hg19.bed_to_sequence(filled_tesselate)
    for fl in filled_sequences:
        assert "n" not in fl.lower()
    filled_tesselate["strand"] = "."
    filled_sequences = hg19.bed_to_sequence(filled_tesselate)
    for fl in filled_sequences:
        assert "n" not in fl.lower()
    hg19.delete()