From e5ae887bd5a5e0ec8d3f0a6cb72387a1cfce9969 Mon Sep 17 00:00:00 2001 From: Tom White Date: Fri, 27 Sep 2024 13:16:29 +0100 Subject: [PATCH] Get INFO/FORMAT description from attrs if present --- vcztools/vcf_writer.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/vcztools/vcf_writer.py b/vcztools/vcf_writer.py index c7db961..53dae3b 100644 --- a/vcztools/vcf_writer.py +++ b/vcztools/vcf_writer.py @@ -489,10 +489,9 @@ def _generate_header(ds, original_header, sample_ids, *, no_version: bool = Fals category = "INFO" vcf_number = _array_to_vcf_number(category, key, arr) vcf_type = _array_to_vcf_type(arr) - if "comment" in arr.attrs: - vcf_description = arr.attrs["comment"] - else: - vcf_description = RESERVED_INFO_KEY_DESCRIPTIONS.get(key, "") + vcf_description = arr.attrs.get( + "description", RESERVED_INFO_KEY_DESCRIPTIONS.get(key, "") + ) print( f'##INFO=', file=output, @@ -514,10 +513,9 @@ def _generate_header(ds, original_header, sample_ids, *, no_version: bool = Fals category = "FORMAT" vcf_number = _array_to_vcf_number(category, key, arr) vcf_type = _array_to_vcf_type(arr) - if "comment" in arr.attrs: - vcf_description = arr.attrs["comment"] - else: - vcf_description = RESERVED_FORMAT_KEY_DESCRIPTIONS.get(key, "") + vcf_description = arr.attrs.get( + "description", RESERVED_FORMAT_KEY_DESCRIPTIONS.get(key, "") + ) print( f'##FORMAT=', file=output,