Skip to content

Commit 24dbf20

Browse files
authored
Merge pull request #45 from bbglab/44-openvariant-bug-breaks-when-input-has-empty-lines
44 OpenVariant Bug breaks when input has empty lines
2 parents 7aa8339 + cabed95 commit 24dbf20

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

openvariant/variant/variant.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import ctypes
99
import gzip
1010
import lzma
11+
import warnings
1112
from fnmatch import fnmatch
1213
from functools import lru_cache
1314
import mmap
@@ -242,8 +243,15 @@ def _parser(self, file_path: str, annotation: Annotation, group_by: str, display
242243

243244
if row and not _exclude(line_dict, annotation.excludes):
244245
yield row
245-
246-
except (ValueError, IndexError, KeyError) as e:
246+
except IndexError as e:
247+
if line == ['']:
248+
warnings.warn(f"Warning: empty line {lnum} on {file_path}.", UserWarning)
249+
pass
250+
else:
251+
self.mm.close()
252+
self.file.close()
253+
raise ValueError(f"Error parsing line: {lnum} {file_path}: {e}")
254+
except (ValueError, KeyError) as e:
247255
self.mm.close()
248256
self.file.close()
249257
raise ValueError(f"Error parsing line: {lnum} {file_path}: {e}")

0 commit comments

Comments
 (0)