Exemplo n.º 1
0
def test_writer_bad_fmt(yrb_writer):
    v = Variant('1', 12345, 'G', 'C')
    v.annotate('PART', '42')
    v.annotate('CONTIG', 'A' * 100)
    v.format('NA19238', 'GT', '0/0')
    v.format('NA19240', 'GT', '0/1')
    v.format('NA19239', 'ALTABUND', '0,0,0')
    v.format('NA19240', 'ALTABUND', '0,0,0')
    errormsg = r'samples not annotated with the same FORMAT fields'
    with pytest.raises(kevlar.vcf.VariantAnnotationError, match=errormsg):
        yrb_writer.write(v)
Exemplo n.º 2
0
def test_writer(yrb_writer, capsys):
    yrb_writer = kevlar.vcf.VCFWriter(sys.stdout, source='py.test')
    yrb_writer.register_sample('NA19238')
    yrb_writer.register_sample('NA19239')
    yrb_writer.register_sample('NA19240')
    yrb_writer.describe_format('GT', 'String', '1', 'Genotype')
    yrb_writer.write_header()

    v = Variant('1', 12345, 'G', 'C')
    v.annotate('PART', '42')
    v.annotate('CONTIG', 'A' * 100)
    v.format('NA19238', 'GT', '0/0')
    v.format('NA19239', 'GT', '0/0')
    v.format('NA19240', 'GT', '0/1')
    v.format('NA19238', 'ALTABUND', '12,9,8')
    v.format('NA19239', 'ALTABUND', '0,0,0')
    v.format('NA19240', 'ALTABUND', '0,0,0')
    yrb_writer.write(v)

    out, err = capsys.readouterr()
    print(out)

    outlines = out.strip().split('\n')
    fmtlines = [l for l in outlines if l.startswith('##FORMAT')]
    assert len(fmtlines) == 2
    gtfmt = '##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">'
    assert gtfmt in fmtlines

    varlines = [l for l in outlines if not l.startswith('#')]
    assert len(varlines) == 1
    values = varlines[0].split('\t')
    assert len(values) == 12
    assert values[8:12] == [
        'ALTABUND:GT', '12,9,8:0/0', '0,0,0:0/0', '0,0,0:0/1'
    ]
Exemplo n.º 3
0
def test_format():
    v = Variant('1', 12345, 'G', 'C')
    v.format('NA19238', 'GT', '0/0')
    assert v.format('NA19238', 'GT') == '0/0'
    assert v.format('NA19238', 'XYZ') is None
    assert v.format('NA19239', 'GT') is None