From 3cd1e7b7638f8fd10f913b7131b94ac8512335dd Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:20:03 +0200 Subject: [PATCH 1/3] Add type annotation for HasExtraFilesPath.extra_files_path Otherwise is considered as None --- lib/galaxy/datatypes/protocols.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/datatypes/protocols.py b/lib/galaxy/datatypes/protocols.py index ac4e3de166ca..4f5bd1593371 100644 --- a/lib/galaxy/datatypes/protocols.py +++ b/lib/galaxy/datatypes/protocols.py @@ -27,7 +27,7 @@ def ext(self): ... class HasExtraFilesPath(Protocol): @property - def extra_files_path(self): ... + def extra_files_path(self) -> str: ... class HasFileName(Protocol): From 8f6610f0ae7fe27e000da8449a30284ae0fd2d39 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:21:39 +0200 Subject: [PATCH 2/3] Avoid type mismatch for reusing variables in genetics.py --- lib/galaxy/datatypes/genetics.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/galaxy/datatypes/genetics.py b/lib/galaxy/datatypes/genetics.py index a17ee92c9b08..3d48649eecbd 100644 --- a/lib/galaxy/datatypes/genetics.py +++ b/lib/galaxy/datatypes/genetics.py @@ -863,16 +863,16 @@ def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd) -> N pp = os.path.join(dataset.extra_files_path, pn) dataset.metadata.pheno_path = pp try: - with open(pp) as f: - pf = f.readlines() # read the basename.phenodata in the extra_files_path + with open(pp) as file: + pf = file.readlines() # read the basename.phenodata in the extra_files_path except Exception: pf = None if pf: - h = pf[0].strip() - h = h.split("\t") # hope is header - h = [escape(x) for x in h] - dataset.metadata.column_names = h - dataset.metadata.columns = len(h) + header = pf[0].strip() + columns = header.split("\t") # hope is header + columns = [escape(x) for x in columns] + dataset.metadata.column_names = columns + dataset.metadata.columns = len(columns) dataset.peek = "".join(pf[:5]) else: dataset.metadata.column_names = [] From 422221d9094752e04cfb3b1c3c36765cd6fc9249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B3pez?= <46503462+davelopez@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:13:00 +0200 Subject: [PATCH 3/3] Refactor header split Co-authored-by: Nicola Soranzo --- lib/galaxy/datatypes/genetics.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/galaxy/datatypes/genetics.py b/lib/galaxy/datatypes/genetics.py index 3d48649eecbd..1ce24261aebf 100644 --- a/lib/galaxy/datatypes/genetics.py +++ b/lib/galaxy/datatypes/genetics.py @@ -869,8 +869,7 @@ def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd) -> N pf = None if pf: header = pf[0].strip() - columns = header.split("\t") # hope is header - columns = [escape(x) for x in columns] + columns = [escape(x) for x in header.split("\t")] # hope is header dataset.metadata.column_names = columns dataset.metadata.columns = len(columns) dataset.peek = "".join(pf[:5])