Commit 0cbc5c3d authored by Mikaël Salson's avatar Mikaël Salson

fuse.py: pre-processing with --pre

- Define a function that could be used for post-processing
- Use defs.py to determine where the pre-process are stored
- Should tests

See #3647
parent 0ad34586
Pipeline #57369 passed with stage
in 7 seconds
......@@ -40,6 +40,7 @@ from operator import itemgetter, le
from utils import *
from defs import *
from collections import defaultdict
from pipes import quote
FUSE_VERSION = "vidjil fuse"
......@@ -672,7 +673,25 @@ lw2.d["clones"].append(w8)
lw2.d["diversity"] = Diversity()
def exec_command(command, directory, input_file):
'''
Execute the command `command` from the directory
`directory`. The executable must exist in
this directory. No path changes are allowed in `command`.
Returns the output filename (a .vidjil).
'''
assert (not os.path.sep in command), "No {} allowed in the command name".format(os.path.sep)
ff = tempfile.NamedTemporaryFile(suffix='.vidjil', delete=False)
basedir = os.path.dirname(os.path.abspath(sys.argv[0]))
command_fullpath = basedir+os.path.sep+directory+os.path.sep+command
com = '%s %s %s' % (quote(command_fullpath), quote(os.path.abspath(input_file)), ff.name)
print(com)
os.system(com)
print()
return ff.name
def main():
......@@ -729,12 +748,8 @@ def main():
print("Pre-processing files...")
pre_processed_files = []
for f in files:
ff = tempfile.NamedTemporaryFile(suffix='.vidjil', delete=False)
com = '%s %s %s' % (args.pre, f, ff.name)
print(com)
os.system(com)
pre_processed_files.append(ff.name)
print()
out_name = exec_command(args.pre, PRE_PROCESS_DIR, f)
pre_processed_files.append(out_name)
files = pre_processed_files
#filtre
......
#!/bin/bash
INPUT=$1
OUTPUT=$2
sed 's/IGH/TRG/g' < "$INPUT" > "$OUTPUT"
TMP_DEFS=`tempfile`
# Not satisfactory
cp ../../defs.py $TMP_DEFS
echo "PRE_PROCESS_DIR='tests/data/pre_process'" >> ../../defs.py
python3 ../../fuse.py $FUSE_OPTIONS --pre igh-to-trg.sh ../../../algo/tests/data/results-two-clones-1-2.vidjil ../../../algo/tests/data/results-two-clones-1-2.vidjil; cat fused.vidjil
mv $TMP_DEFS ../../defs.py
cat fused.vidjil
6:TRG
0:IGH
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment