Example #1
0
def test_slopbed_pybedtool():
    """Test function slopbed with pybedtool interval feature 
    """
    f = iter(pybedtools.BedTool('chr1 1 100 asdf 0 + a b c d', from_string=True)).next()
    xf= pycoverage.slopbed(f, [0, 0])
    assert f == xf
    
    xf= pycoverage.slopbed(f, [0, 10])
    assert xf == iter(pybedtools.BedTool('chr1 1 110 asdf 0 + a b c d', from_string=True)).next()
    
    xf= pycoverage.slopbed(f, [1, 0])
    assert xf == iter(pybedtools.BedTool('chr1 0 100 asdf 0 + a b c d', from_string=True)).next()

    xf= pycoverage.slopbed(f, [10, 0]) ## Left coord must remain 0
    assert xf == iter(pybedtools.BedTool('chr1 0 100 asdf 0 + a b c d', from_string=True)).next()

    xf= pycoverage.slopbed(f, [1, 1]) ## Left coord must remain 0
    assert xf == iter(pybedtools.BedTool('chr1 0 101 asdf 0 + a b c d', from_string=True)).next()

    xf= pycoverage.slopbed(f, [0.1, 0.13]) ## Left coord must remain 0
    assert xf == iter(pybedtools.BedTool('chr1 0 113 asdf 0 + a b c d', from_string=True)).next()

    xf= pycoverage.slopbed(f, [0.1, 1.13]) ## Left coord must remain 0
    assert xf == iter(pybedtools.BedTool('chr1 0 212 asdf 0 + a b c d', from_string=True)).next()

    try:
        xf= pycoverage.slopbed(f, [-1, 0])
    except pycoverage.SlopError:
        assert True
    try:
        xf= pycoverage.slopbed(f, [0, '0'])
    except pycoverage.SlopError:
        assert True
Example #2
0
def test_slopbed_list():
    """Test function slopbed with list interval feature 
    """
    f= ['chr1', 1, 100, 'actb']
    xf= pycoverage.slopbed(f, [0, 0])
    assert f == xf

    xf= pycoverage.slopbed(f, [0.1, 1.13]) ## Left coord must remain 0
    assert xf == ['chr1', 0, 212, 'actb']

    try:  
        xf= pycoverage.slopbed(['chr1', '0', 212, 'actb'], [0.1, 1.13]) ## Left coord must remain 0
    except TypeError:
        assert True