diff --git a/bin/passim.cmd b/bin/passim.cmd index 3769854..c6bbfa3 100644 --- a/bin/passim.cmd +++ b/bin/passim.cmd @@ -1,3 +1,29 @@ @echo off -call %~dp0seriatim --all-pairs ^ - --fields "xxhash64(series)^ as^ gid" -f gid^, |, & in all arguments with a placeholder +:: which will be replaced with the original character in seriatim.py +:: NB: unfortunately, this does not work with the equals sign; use _EQ_, _LTE_ and _GTE_ instead. + +:: make sure variables are not expanded before the script is run: +SETLOCAL EnableDelayedExpansion + +:: first, set up an empty variable that will contain all modified variables: +set modifiedArgs= + +:: loop through all arguments passed to the script (%*) +:: and replace all special characters in them +:: finally, add each argument to the modified arguments list +for %%i in (%*) do ( + set arg=%%i + set arg=!arg:^<=_LT_! + set arg=!arg:^>=_GT_! + set arg=!arg:^|=_PIPE_! + set arg=!arg:^&=_AMPERSAND_! + set modifiedArgs=!modifiedArgs! !arg! + echo !arg! +) +::echo MODIFIED ARGS: +::echo %modifiedArgs% + +echo %~dp0seriatim.cmd --all-pairs --fields "xxhash64(series) as gid" -f gid_LT_gid2 %modifiedArgs% +call %~dp0seriatim.cmd --all-pairs --fields "xxhash64(series) as gid" -f gid_LT_gid2 %modifiedArgs% diff --git a/passim/seriatim.py b/passim/seriatim.py index a5ca6ad..3780089 100644 --- a/passim/seriatim.py +++ b/passim/seriatim.py @@ -545,6 +545,12 @@ def clusterJoin(self, config, corpus): setattr(DataFrame, 'clusterJoin', clusterJoin) +def replace_placeholders(s): + try: + return s.replace("_LT_", "<").replace("_LTE_", "<=").replace("_GT_", ">").replace("_GTE_", ">=").replace("_PIPE_", "|").replace("_AMPERSAND_", "&") + except: + return s + def main(args): parser = argparse.ArgumentParser(description='Passim Alignment', formatter_class=argparse.ArgumentDefaultsHelpFormatter) @@ -597,6 +603,9 @@ def main(args): parser.add_argument('outputPath', metavar='', help='output') config = parser.parse_args(args) + # replace placeholders in the relevant arguments: + config.filterpairs = replace_placeholders(config.filterpairs) + config.link_features = replace_placeholders(config.link_features) print(config) spark = SparkSession.builder.appName('Passim Alignment').getOrCreate()