From 54db4e9a7a8824712540c8e6b02da8d8ad8271df Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 27 May 2024 10:22:34 +0200 Subject: [PATCH] Don't fail set_peek if file does not look like GRO file --- lib/galaxy/datatypes/molecules.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/datatypes/molecules.py b/lib/galaxy/datatypes/molecules.py index a4cc26b549d2..698ebb2ec07a 100644 --- a/lib/galaxy/datatypes/molecules.py +++ b/lib/galaxy/datatypes/molecules.py @@ -1546,8 +1546,12 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool: def set_peek(self, dataset: DatasetProtocol, **kwd) -> None: if not dataset.dataset.purged: dataset.peek = get_file_peek(dataset.get_file_name()) - atom_number = int(dataset.peek.split("\n")[1]) - dataset.blurb = f"{atom_number} atoms" + peek_lines = dataset.peek.split("\n") + try: + atom_number = int(peek_lines[1]) + dataset.blurb = f"{atom_number} atoms" + except (ValueError, IndexError): + dataset.blurb = "file does not look like valid GRO file." else: dataset.peek = "file does not exist" dataset.blurb = "file purged from disk"