예제 #1
0
def test_drop_by_id():
    vcf = viola.read_vcf(os.path.join(HERE, 'data/test.manta.vcf'))
    vcf_dropped_expected = viola.read_vcf(os.path.join(HERE, 'data/test.dropped.manta.vcf'))
    vcf_dropped2_expected = viola.read_vcf(os.path.join(HERE, 'data/test.dropped2.manta.vcf'))
    vcf_dropped = vcf.drop_by_id('test1')
    vcf_dropped2 = vcf.drop_by_id(['test2', 'test3'])
    assert_vcf_equal(vcf_dropped, vcf_dropped_expected)
    assert_vcf_equal(vcf_dropped2, vcf_dropped2_expected)
예제 #2
0
def test_add_info_table():
    vcf = viola.read_vcf(os.path.join(HERE, 'data/test.manta.vcf'))
    vcf_expected = viola.read_vcf(
        os.path.join(HERE, 'data/test.info.added.manta.vcf'))
    table = vcf.svlen
    table.columns = ['id', 'value_idx', 'test']
    vcf.add_info_table('test', table, 1, 'Integer', 'test info')
    assert_vcf_equal(vcf, vcf_expected)
def test_breakend2breakpoint():
    vcf = viola.read_vcf(StringIO(HEADER + body), variant_caller='lumpy')
    vcf_expected = viola.read_vcf(StringIO(HEADER_expected + body_expected),
                                  variant_caller='lumpy')
    ex_svpos = vcf_expected.get_table('positions')
    ex_svpos.loc[3, 'svtype'] = 'INV'
    ex_svtype = vcf_expected.get_table('svtype')
    ex_svtype.iloc[3, 2] = 'INV'
    ex_infos_meta = vcf_expected.get_table('infos_meta')
    ex_infos_meta.index = [
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17
    ]
    vcf_expected._odict_alltables['positions'] = ex_svpos
    vcf_expected._odict_alltables['svtype'] = ex_svtype
    vcf_expected._odict_alltables['infos_meta'] = ex_infos_meta
    vcf_result = vcf.breakend2breakpoint()
    assert_vcf_equal(vcf_result, vcf_expected)
예제 #4
0
def test_copy():
    manta_path = os.path.join(HERE, '../io/data/test.manta.vcf')
    delly_path = os.path.join(HERE, '../io/data/test.delly.vcf')
    lumpy_path = os.path.join(HERE, '../io/data/test.lumpy.vcf')
    gridss_path = os.path.join(HERE, '../io/data/test.gridss.vcf')
    manta_vcf = viola.read_vcf(manta_path)
    delly_vcf = viola.read_vcf(delly_path, variant_caller='delly')
    lumpy_vcf = viola.read_vcf(lumpy_path, variant_caller='lumpy')
    gridss_vcf = viola.read_vcf(gridss_path, variant_caller='gridss')
    assert_vcf_equal(manta_vcf, manta_vcf.copy())
    assert_vcf_equal(delly_vcf, delly_vcf.copy())
    assert_vcf_equal(lumpy_vcf, lumpy_vcf.copy())
    assert_vcf_equal(gridss_vcf, gridss_vcf.copy())
예제 #5
0
def test_replace_svid():
    vcf = viola.read_vcf(StringIO(HEADER + body))
    vcf_expected1 = viola.read_vcf(StringIO(HEADER + body_expected1))
    vcf_expected2 = viola.read_vcf(StringIO(HEADER + body_expected2))

    vcf1 = vcf.copy()
    vcf1.replace_svid('test1', 'a')
    assert_vcf_equal(vcf1, vcf_expected1)

    vcf1_ex = vcf.copy()
    vcf1_ex.replace_svid(['test1'], ['a'])
    assert_vcf_equal(vcf1_ex, vcf_expected1)

    vcf2 = vcf.copy()
    vcf2.replace_svid(['test2', 'test3'], ['a', 'b'])
    assert_vcf_equal(vcf2, vcf_expected2)
def test_breakend2breakpoint():
    vcf = viola.read_vcf(StringIO(HEADER + body))
    vcf_expected = viola.read_vcf(StringIO(HEADER_expected + body_expected))
    vcf_result = vcf.breakend2breakpoint()
    assert_vcf_equal(vcf_result, vcf_expected)
def test_remove_info_table():
    vcf = viola.read_vcf(os.path.join(HERE, 'data/test.info.added.manta.vcf'))
    vcf_expected = viola.read_vcf(os.path.join(HERE, 'data/test.manta.vcf'))
    vcf.remove_info_table('test')
    assert_vcf_equal(vcf, vcf_expected)
def test_breakend2breakpoint():
    vcf = viola.read_vcf(StringIO(HEADER + body), variant_caller='delly')
    print(vcf.infos_meta)
    vcf_expected = viola.read_vcf(StringIO(HEADER_expected + body_expected), variant_caller='delly')
    vcf_result = vcf.breakend2breakpoint()
    assert_vcf_equal(vcf_result, vcf_expected)