From e96e591ee1291f4e77ce15058ba3d5e3431833ea Mon Sep 17 00:00:00 2001 From: rjchallis Date: Wed, 28 Jul 2021 13:04:57 +0000 Subject: [PATCH] catch AttributeError when setting window sizes Fixes #34 --- lib/hits.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/hits.py b/lib/hits.py index aa002785..b920f230 100644 --- a/lib/hits.py +++ b/lib/hits.py @@ -110,26 +110,29 @@ def set_windows(meta, taxrule): """Set window sizes from dataset metadata.""" windows = [] chunk = 0.1 - if "bestsum" in taxrule: - chunk = 1 - elif "blast_max_chunks" in meta.settings: - chunk = 1 / int(meta.settings["blast_max_chunks"]) - if "stats_windows" in meta.settings: - for x in meta.settings["stats_windows"]: - window = { - "key": ("%f" % x).rstrip("0").rstrip("."), - "window": True, - "value": float(x), - "chunk": False, - } - if window["key"] == "0.1": - window["title"] = "windows" - else: - window["title"] = "windows_%s" % window["key"] - if chunk is not None and float(x) == chunk: - window.update({"chunk": True}) - chunk = None - windows.append(window) + try: + if "bestsum" in taxrule: + chunk = 1 + elif "blast_max_chunks" in meta.settings: + chunk = 1 / int(meta.settings["blast_max_chunks"]) + if "stats_windows" in meta.settings: + for x in meta.settings["stats_windows"]: + window = { + "key": ("%f" % x).rstrip("0").rstrip("."), + "window": True, + "value": float(x), + "chunk": False, + } + if window["key"] == "0.1": + window["title"] = "windows" + else: + window["title"] = "windows_%s" % window["key"] + if chunk is not None and float(x) == chunk: + window.update({"chunk": True}) + chunk = None + windows.append(window) + except AttributeError: + pass if chunk is not None: windows.append( {