From f54e2750986260e74512fc7f1de26e0145dc3632 Mon Sep 17 00:00:00 2001 From: Ivan Blagoev Topolsky Date: Fri, 5 Jul 2024 18:13:20 +0200 Subject: [PATCH] [bugfix] filters: empty cli option and quotes - supports `lollipop deconvolute --filters="" ...` to skip filters - supports statement with quotes around column `- "column" == val` --- lollipop/cli/deconvolute.py | 2 ++ lollipop/preprocessors.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lollipop/cli/deconvolute.py b/lollipop/cli/deconvolute.py index 47bce76..5c94fe4 100755 --- a/lollipop/cli/deconvolute.py +++ b/lollipop/cli/deconvolute.py @@ -151,6 +151,8 @@ def deconvolute( filters = yaml.load(file) print(f"{len(filters)} filter{ '' if len(filters) == 1 else 's' } loaded") + else: + filters = None # data try: diff --git a/lollipop/preprocessors.py b/lollipop/preprocessors.py index 3702140..62af257 100644 --- a/lollipop/preprocessors.py +++ b/lollipop/preprocessors.py @@ -121,15 +121,15 @@ def general_preprocess( def filter_mutations(self, filters=None): """filter out hardcoded problematic mutations""" - if filters is None: + if not filters: return self types = self.df_tally.dtypes rxprser = re.compile( - r"^ *(?:(?P" + r"^ *(?P['\"]?)(?:(?P" + r"|".join(self.df_tally.columns) - + r")|(?P\w+)) *(?Pin|[<>=~!]*) *(?P['\"]?)(?P.+)(?P=qv) *$" + + r")|(?P\w+))(?P=qc) *(?Pin|[<>=~!]*) *(?P['\"]?)(?P.+)(?P=qv) *$" ) def apply_filter_statement(name, fs):