From e62c91640de07d218a63f6abd9d3d9051d056b6c Mon Sep 17 00:00:00 2001 From: Redmar van den Berg <RedmarvandenBerg@lumc.nl> Date: Mon, 25 Nov 2019 15:48:14 +0100 Subject: [PATCH] Use get_header_type to determine if RGQ is present --- vtools/evaluate.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/vtools/evaluate.py b/vtools/evaluate.py index 91e18ee..396d689 100644 --- a/vtools/evaluate.py +++ b/vtools/evaluate.py @@ -48,19 +48,13 @@ def parse_variants(ref: str, call: List[str], pos: List[str], def RGQ_header_defined(vcf): """ Determine whether the RGQ annotation is defined in the FORMAT header of the vcf. - - Since the header_iter does not return python dictionaries, we cannot easily - test if a certain key is set, hence the ugly code. """ - for header in vcf.header_iter(): - try: - header['ID'] - except KeyError: - continue - else: - if header['ID'] == 'RGQ': - return True - return False + try: + vcf.get_header_type('RGQ') + except KeyError: + return False + else: + return True def site_concordancy(call_vcf: VCF, -- GitLab