From ba5d76eb934598227102ae1cb0ff4e89e0ab0b9c Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 29 Oct 2018 18:01:40 +0100 Subject: [PATCH] Avoid exception if no match This fixes the sniffing unit test, the datatype framework would just continue anyway. --- lib/galaxy/datatypes/sequence.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/datatypes/sequence.py b/lib/galaxy/datatypes/sequence.py index 85a9e23f514..d02c9d4b007 100644 --- a/lib/galaxy/datatypes/sequence.py +++ b/lib/galaxy/datatypes/sequence.py @@ -697,9 +697,11 @@ class BaseFastq(Sequence): headers = get_headers(file_prefix, sep='\n', count=4) if len(headers) == 4 and headers[0][0] and headers[0][0][0] == "@" and headers[2][0] and headers[2][0][0] == "+" and headers[1][0]: # Check the sequence line, make sure it contains only G/C/A/T/N - start, end = cls.bases_regexp.match(headers[1][0]).span() - if (end - start) == len(headers[1][0]): - return True + match = cls.bases_regexp.match(headers[1][0]) + if match: + start, end = match.span() + if (end - start) == len(headers[1][0]): + return True return False