Skip to content

Commit

Permalink
Don't fail set_peek if file does not look like GRO file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 27, 2024
1 parent 3cd64e7 commit 54db4e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/galaxy/datatypes/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 54db4e9

Please sign in to comment.