From c10cf50240eb3b572c49da353218397dcf52da62 Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Thu, 16 Nov 2023 11:15:01 +0100 Subject: [PATCH] Fallback to default attribut when title and desc are not provided --- jass/models/inittable.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jass/models/inittable.py b/jass/models/inittable.py index f49fef2e..292d7311 100644 --- a/jass/models/inittable.py +++ b/jass/models/inittable.py @@ -32,11 +32,15 @@ def get_inittable_meta(file_name): nb_snps = init_store.get_storer("SumStatTab").nrows init_store.close() nb_phenotypes = read_hdf(file_name, "PhenoList").shape[0] - - f = h5py.File(file_name, mode='r') - name=f.attrs['title'] - desc=f.attrs["description"] - f.close() + + try: + f = h5py.File(file_name, mode='r') + name=f.attrs['title'] + desc=f.attrs["description"] + f.close() + except KeyError: + name = f"Filename: {file_name.split('/')[-1]}" + desc = "No description" return dict( nb_snps=int(nb_snps), nb_phenotypes=int(nb_phenotypes), -- GitLab