Пример #1
0
def test_venn_gchart_png_is_saved_correctly():

    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, "gchart-expected.png")).read()

    original = pybedtools.example_bedtool(
        "rmsk.hg18.chr21.small.bed").sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = (pybedtools.BedTool(original[:20]).saveas().cat(
        pybedtools.BedTool(original[400:500]).saveas()))
    c = (pybedtools.BedTool(original[15:30]).saveas().cat(
        pybedtools.BedTool(original[450:650]).saveas()))

    colors = "00FF00,FF0000,0000FF"
    outfn = "gchart_out.png"
    labels = "a,b,c"

    data = venn_gchart.venn_gchart(
        a=a.fn,
        b=b.fn,
        c=c.fn,
        colors=colors.split(","),
        labels=labels.split(","),
        size="300x300",
    )

    venn_gchart.gchart(data, outfn)
    assert_equal(open(outfn).read(), expected)
    os.unlink(outfn)
Пример #2
0
def test_venn_gchart_png_is_saved_correctly():
    from nose.plugins.skip import SkipTest
    raise SkipTest('Small differences between fonts in PNG are sometimes produced and need to be accounted for')
    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, 'gchart-expected.png')).read()

    original = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(pybedtools.BedTool(original[450:650]).saveas())

    colors='00FF00,FF0000,0000FF'
    outfn = 'gchart_out.png'
    labels = 'a,b,c'

    data = venn_gchart.venn_gchart(a=a.fn,
                            b=b.fn,
                            c=c.fn,
                            colors=colors.split(','),
                            labels=labels.split(','),
                            size='300x300')

    venn_gchart.gchart(data, outfn)
    assert_equal(open(outfn).read(), expected)
    os.unlink(outfn)
Пример #3
0
def test_venn_gchart_png_is_saved_correctly():
    from nose.plugins.skip import SkipTest
    raise SkipTest('Small differences between fonts in PDF are sometimes produced and need to be accounted for')
    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, 'gchart-expected.png')).read()

    original = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(pybedtools.BedTool(original[450:650]).saveas())

    colors='00FF00,FF0000,0000FF'
    outfn = 'gchart_out.png'
    labels = 'a,b,c'

    data = venn_gchart.venn_gchart(a=a.fn,
                            b=b.fn,
                            c=c.fn,
                            colors=colors.split(','),
                            labels=labels.split(','),
                            size='300x300')

    venn_gchart.gchart(data, outfn)
    assert_equal(open(outfn).read(), expected)
    os.unlink(outfn)
Пример #4
0
def test_venn_gchart():
    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, 'gchart-expected.png')).read()

    original = pybedtools.example_bedtool(
        'rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(
        pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(
        pybedtools.BedTool(original[450:650]).saveas())

    colors = '00FF00,FF0000,0000FF'
    outfn = 'gchart_out.png'
    labels = 'a,b,c'

    expected_data = {
        'chco': '00FF00,FF0000,0000FF',
        'chd':
        't:1.0,0.4,0.716666666667,0.0666666666667,0.05,0.183333333333,0.0166666666667',
        'chs': '300x300',
        'cht': 'v',
        'chdl': 'a|b|c'
    }

    data = venn_gchart.venn_gchart(a=a.fn,
                                   b=b.fn,
                                   c=c.fn,
                                   colors=colors.split(','),
                                   labels=labels.split(','),
                                   size='300x300')

    print data
    for key in expected_data.keys():
        e = expected_data[key]
        o = data[key]
        print 'key:', key
        print 'expected:', e
        print 'observed:', o
        assert e == o

    venn_gchart.gchart(data, outfn)

    assert open(outfn).read() == expected
    os.unlink(outfn)
Пример #5
0
def test_venn_gchart():
    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, 'gchart-expected.png')).read()


    pybedtools.bedtool.random.seed(1)
    a = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed')
    b = a.random_subset(100).shuffle(genome='hg19', seed=1)
    b = b.cat(a.random_subset(100, seed=1))
    c = a.random_subset(200).shuffle(genome='hg19', seed=2)
    c = c.cat(b.random_subset(100, seed=1))
    colors='00FF00,FF0000,0000FF'
    outfn = 'out.png'
    labels = 'a,b,c'

    expected_data = {'chco': '00FF00,FF0000,0000FF',
                     'chd': 't:1.0,0.2,0.3,0.104,0.048,0.1,0.048',
                     'chs': '300x300',
                     'cht': 'v',
                     'chdl': 'a|b|c'}

    data = venn_gchart.venn_gchart(a=a.fn,
                            b=b.fn,
                            c=c.fn,
                            colors=colors.split(','),
                            labels=labels.split(','),
                            size='300x300')

    print data
    for key in expected_data.keys():
        e = expected_data[key]
        o = data[key]
        print 'key:', key
        print 'expected:', e
        print 'observed:', o
        assert e == o

    venn_gchart.gchart(data, outfn)

    assert open(outfn).read() == expected
    os.unlink(outfn)
Пример #6
0
def test_venn_gchart():
    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, 'gchart-expected.png')).read()

    original = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(pybedtools.BedTool(original[450:650]).saveas())

    colors='00FF00,FF0000,0000FF'
    outfn = 'gchart_out.png'
    labels = 'a,b,c'

    expected_data = {'chco': '00FF00,FF0000,0000FF',
                     'chd': 't:1.0,0.4,0.716666666667,0.0666666666667,0.05,0.183333333333,0.0166666666667',
                     'chs': '300x300',
                     'cht': 'v',
                     'chdl': 'a|b|c'}

    data = venn_gchart.venn_gchart(a=a.fn,
                            b=b.fn,
                            c=c.fn,
                            colors=colors.split(','),
                            labels=labels.split(','),
                            size='300x300')

    print(data)
    for key in list(expected_data.keys()):
        e = expected_data[key]
        o = data[key]
        print('key:', key)
        print('expected:', e)
        print('observed:', o)
        assert e == o

    venn_gchart.gchart(data, outfn)

    assert open(outfn).read() == expected
    os.unlink(outfn)
Пример #7
0
def test_venn_gchart_png_is_saved_correctly():

    here = os.path.dirname(__file__)
    expected = open(os.path.join(here, 'gchart-expected.png')).read()

    original = pybedtools.example_bedtool('rmsk.hg18.chr21.small.bed').sort().merge()
    a = pybedtools.BedTool(original[:300]).saveas()
    b = pybedtools.BedTool(original[:20]).saveas().cat(pybedtools.BedTool(original[400:500]).saveas())
    c = pybedtools.BedTool(original[15:30]).saveas().cat(pybedtools.BedTool(original[450:650]).saveas())

    colors='00FF00,FF0000,0000FF'
    outfn = 'gchart_out.png'
    labels = 'a,b,c'

    data = venn_gchart.venn_gchart(a=a.fn,
                            b=b.fn,
                            c=c.fn,
                            colors=colors.split(','),
                            labels=labels.split(','),
                            size='300x300')

    venn_gchart.gchart(data, outfn)
    assert_equal(open(outfn).read(), expected)
    os.unlink(outfn)