Skip to content

Commit

Permalink
[bugfix] filters: empty cli option and quotes
Browse files Browse the repository at this point in the history
- supports `lollipop deconvolute  --filters="" ...` to skip filters
- supports statement with quotes around column `- "column" == val`
  • Loading branch information
DrYak committed Jul 5, 2024
1 parent bc7d1cd commit f54e275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lollipop/cli/deconvolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions lollipop/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<col>"
r"^ *(?P<qc>['\"]?)(?:(?P<col>"
+ r"|".join(self.df_tally.columns)
+ r")|(?P<bad>\w+)) *(?P<op>in|[<>=~!]*) *(?P<qv>['\"]?)(?P<val>.+)(?P=qv) *$"
+ r")|(?P<bad>\w+))(?P=qc) *(?P<op>in|[<>=~!]*) *(?P<qv>['\"]?)(?P<val>.+)(?P=qv) *$"
)

def apply_filter_statement(name, fs):
Expand Down

0 comments on commit f54e275

Please sign in to comment.