Commit 336a5a94 authored by van den Berg's avatar van den Berg
Browse files

Add tests for quality and depth filter

parent 26922303
Pipeline #2745 failed with stage
in 22 seconds
......@@ -5,22 +5,14 @@ from vtools.evaluate import site_concordancy
from cyvcf2 import VCF
@pytest.fixture
@pytest.fixture(scope='module')
def known_concordant():
known = 'tests/cases/gatk.vcf.gz'
d, disc = site_concordancy(VCF(known, gts012=True), VCF(known,
gts012=True),
['NA12878'], ['NA12878'], min_gq=0,
min_dp=0)
return d
@pytest.fixture
def blank_NA12878():
filename = 'tests/cases/gatk.vcf.gz'
d, disc = site_concordancy(VCF(filename, gts012=True), VCF(filename,
gts012=True),
['NA12878'], ['BLANK'], min_gq=0, min_dp=0)
call = VCF(filename, gts012=True)
positive = VCF(filename, gts012=True)
d, disc = site_concordancy(call, positive, call_samples=['NA12878'],
positive_samples=['NA12878'],
min_gq=0, min_dp=0)
return d
......@@ -56,8 +48,8 @@ def test_alleles_discordant(known_concordant):
assert known_concordant['alleles_discordant'] == 0
def test_alleles_no_call(blank_NA12878):
assert blank_NA12878['alleles_no_call'] == 8
def test_alleles_no_call(known_concordant):
assert known_concordant['alleles_no_call'] == 0
def test_alleles_low_qual(known_concordant):
......@@ -66,3 +58,41 @@ def test_alleles_low_qual(known_concordant):
def test_alleles_low_depth(known_concordant):
assert known_concordant['alleles_low_depth'] == 0
@pytest.fixture(scope='module')
def BLANK_NA12878():
filename = 'tests/cases/gatk.vcf.gz'
call = VCF(filename, gts012=True)
positive = VCF(filename, gts012=True)
d, disc = site_concordancy(call, positive, call_samples=['BLANK'],
positive_samples=['NA12878'],
min_gq=30, min_dp=20)
return d
def test_low_qual_30(BLANK_NA12878):
assert BLANK_NA12878['alleles_low_qual'] == 42
def test_low_depth_20(BLANK_NA12878):
assert BLANK_NA12878['alleles_low_depth'] == 44
def test_no_call(BLANK_NA12878):
assert BLANK_NA12878['alleles_no_call'] == 8
@pytest.fixture(scope='module')
def NA12878_BLANK():
filename = 'tests/cases/gatk.vcf.gz'
call = VCF(filename, gts012=True)
positive = VCF(filename, gts012=True)
d, disc = site_concordancy(call, positive, call_samples=['NA12878'],
positive_samples=['BLANK'],
min_gq=30, min_dp=20)
return d
# def test_no_call2(NA12878_BLANK):
# assert NA12878_BLANK['alleles_no_call'] == 8
......@@ -98,6 +98,7 @@ def site_concordancy(call_vcf: VCF,
# If the site does not pass the quality requirements
c_gq = call_record.gt_quals[c_s]
c_dp = call_record.gt_depths[c_s]
print(f'{call_record.POS}\tc_gt: {c_gt} p_gt: {p_gt}')
if c_gq < min_gq or c_dp < min_dp:
if c_gq < min_gq:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment