From ebf996f8bcd46c35807dd706ef8d35e1913b79d5 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Fri, 19 Feb 2021 04:56:37 +0000 Subject: [PATCH] Set Vcf metadata also for VcfGz files --- lib/galaxy/datatypes/tabular.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/galaxy/datatypes/tabular.py b/lib/galaxy/datatypes/tabular.py index a9513f9ccb0..ad23827bfc2 100644 --- a/lib/galaxy/datatypes/tabular.py +++ b/lib/galaxy/datatypes/tabular.py @@ -743,13 +743,12 @@ class BaseVcf(Tabular): def set_meta(self, dataset, **kwd): super().set_meta(dataset, **kwd) - source = open(dataset.file_name) - - # Skip comments. line = None - for line in source: - if not line.startswith('##'): - break + with compression_utils.get_fileobj(dataset.file_name) as fh: + # Skip comments. + for line in fh: + if not line.startswith('##'): + break if line and line.startswith('#'): # Found header line, get sample names. @@ -815,7 +814,7 @@ class VcfGz(BaseVcf, binary.Binary): return binascii.hexlify(last28) == b'1f8b08040000000000ff0600424302001b0003000000000000000000' def set_meta(self, dataset, **kwd): - super(BaseVcf, self).set_meta(dataset, **kwd) + super().set_meta(dataset, **kwd) """ Creates the index for the VCF file. """ # These metadata values are not accessible by users, always overwrite index_file = dataset.metadata.tabix_index