Commit 8786b514 authored by van den Berg's avatar van den Berg

Add check for non-diploid calls

Since it is not clear how we should handle non-diploid calls, we check
if variants are haploid/polyploid and error out if this is the case.
parent 05ade21d
Pipeline #2779 failed with stage
in 22 seconds
......@@ -158,3 +158,29 @@ def test_decomposed_call_file():
match='Decomposed variants are not supported'):
site_concordancy(call, positive, call_samples=['BLANK'],
positive_samples=['NA12878'])
def test_haploid_positive_file():
""" Test error message when the positive vcf contains non-diploid variants
"""
filename = 'tests/cases/gatk.vcf.gz'
haploid = 'tests/cases/dummy_haploid.vcf.gz'
call = VCF(filename, gts012=True)
positive = VCF(haploid, gts012=True)
with pytest.raises(NotImplementedError,
match='Non-diploid variants are not supported'):
site_concordancy(call, positive, call_samples=['NA12878'],
positive_samples=['BLANK'])
def test_haploid_call_file():
""" Test error message when the call vcf contains non-diploid variants
"""
filename = 'tests/cases/gatk.vcf.gz'
haploid = 'tests/cases/dummy_haploid.vcf.gz'
call = VCF(haploid, gts012=True)
positive = VCF(filename, gts012=True)
with pytest.raises(NotImplementedError,
match='Non-diploid variants are not supported'):
site_concordancy(call, positive, call_samples=['BLANK'],
positive_samples=['NA12878'])
......@@ -174,6 +174,10 @@ def site_concordancy(call_vcf: VCF,
pos = pos_record.genotypes[p_s]
cal = call_record.genotypes[c_s]
# If the genotypes are not diploid
if len(pos) != 3 or len(cal) != 3:
raise NotImplementedError('Non-diploid variants are not '
'supported')
# If the genotypes are phased
if pos[2] or cal[2]:
raise NotImplementedError('Phased variants are not supported')
......
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