aboutsummaryrefslogtreecommitdiff
path: root/quality_control/parsing.py
diff options
context:
space:
mode:
Diffstat (limited to 'quality_control/parsing.py')
-rw-r--r--quality_control/parsing.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/quality_control/parsing.py b/quality_control/parsing.py
index 5b1809b..9f8e8ee 100644
--- a/quality_control/parsing.py
+++ b/quality_control/parsing.py
@@ -4,7 +4,7 @@ import os
import collections
from enum import Enum
from functools import partial
-from typing import Union, Iterable, Generator, Callable
+from typing import Iterable, Generator, Callable, Optional
import quality_control.average as avg
import quality_control.standard_error as se
@@ -65,7 +65,8 @@ def se_errors(line_number, fields):
def collect_errors(
filepath: str, filetype: FileType, strains: list,
- update_progress: Union[Callable, None] = None) -> Generator:
+ update_progress: Optional[Callable] = None,
+ user_aborted: Optional[Callable] = lambda: False) -> Generator:
"""Run checks against file and collect all the errors"""
errors = tuple()
def __process_errors__(line_number, line, error_checker_fn, errors = tuple()):
@@ -80,6 +81,9 @@ def collect_errors(
with open(filepath, encoding="utf-8") as input_file:
for line_number, line in enumerate(input_file, start=1):
+ if user_aborted():
+ break
+
if line_number == 1:
for error in __process_errors__(
line_number, line, partial(header_errors, strains=strains),