Commit 03f6d8de authored by Yoann Dufresne's avatar Yoann Dufresne

modification of snakefiles according to the refactored pieces

parent e268c918
...@@ -35,14 +35,13 @@ rule compress_data: ...@@ -35,14 +35,13 @@ rule compress_data:
rule d2_simplification: rule d2_simplification:
input: input:
barcode_graph="{barcode_path}.gexf",
d2_raw="{barcode_path}_d2_raw_{method}.gexf" d2_raw="{barcode_path}_d2_raw_{method}.gexf"
output: output:
simplified_d2="{barcode_path}_d2_simplified_{method}.gexf" simplified_d2="{barcode_path}_d2_simplified_{method}.gexf"
wildcard_constraints: wildcard_constraints:
method="[A-Za-z0-9]+" method="[A-Za-z0-9]+"
shell: shell:
"python3 deconvolution/main/d2_reduction.py -o {output.simplified_d2} {input.barcode_graph} {input.d2_raw}" "python3 deconvolution/main/d2_reduction.py -o {output.simplified_d2} {input.d2_raw}"
rule d2_generation: rule d2_generation:
...@@ -54,7 +53,7 @@ rule d2_generation: ...@@ -54,7 +53,7 @@ rule d2_generation:
wildcard_constraints: wildcard_constraints:
method="[A-Za-z0-9]+" method="[A-Za-z0-9]+"
run: run:
shell(f"python3 deconvolution/main/to_d2_graph.py {{input.barcode_graph}} --{{wildcards.method}} -t {{threads}} -o {WORKDIR}/{{wildcards.file}}_d2_raw_{{wildcards.method}}") shell(f"python3 deconvolution/main/to_d2_graph.py {{input.barcode_graph}} --{{wildcards.method}} -t {{threads}} -o {WORKDIR}/{{wildcards.file}}_d2_raw_{{wildcards.method}}.gexf")
rule setup_workdir: rule setup_workdir:
......
...@@ -3,10 +3,10 @@ include: "Snakefile_d2" ...@@ -3,10 +3,10 @@ include: "Snakefile_d2"
include: "Snakefile_d2_path" include: "Snakefile_d2_path"
WORKDIR = "snake_experiments" if "workdir" not in config else config["workdir"] WORKDIR = "snake_experiments" if "workdir" not in config else config["workdir"]
N = [5000, 10000] N = [500]
D = [10] D = [6]
M = [2, 3] M = [2]
DEV = [0, 1] DEV = [0]
rule generate_compare: rule generate_compare:
input: input:
......
...@@ -5,14 +5,13 @@ threshold = 0.9 ...@@ -5,14 +5,13 @@ threshold = 0.9
rule d2_path_generation: rule d2_path_generation:
input: input:
barcode="{path}.gexf",
d2="{path}_d2_{type}_{method}.gexf" d2="{path}_d2_{type}_{method}.gexf"
output: output:
"{path}_d2_{type}_{method}_path.gexf" "{path}_d2_{type}_{method}_path.gexf"
run: run:
best = 0 best = 0
for _ in range(number_try): for _ in range(number_try):
shell("python3 deconvolution/main/d2_to_path.py {input.barcode} {input.d2} > {output}_tmp.out") shell("python3 deconvolution/main/d2_to_path.py {input.d2} > {output}_tmp.out")
score = 0 score = 0
with open(f"{output}_tmp.out") as out: with open(f"{output}_tmp.out") as out:
score_line = out.readlines()[-2].strip() score_line = out.readlines()[-2].strip()
......
...@@ -10,7 +10,7 @@ from deconvolution.d2graph import d2_graph as d2 ...@@ -10,7 +10,7 @@ from deconvolution.d2graph import d2_graph as d2
def parse_arguments(): def parse_arguments():
parser = argparse.ArgumentParser(description='Transform a barcode graph into a lcp graph. The program dig for a set of lcps and then merge them into a lcp graph.') parser = argparse.ArgumentParser(description='Transform a barcode graph into a lcp graph. The program dig for a set of lcps and then merge them into a lcp graph.')
parser.add_argument('barcode_graph', help='The barcode graph file. Must be a gefx formated file.') parser.add_argument('barcode_graph', help='The barcode graph file. Must be a gefx formated file.')
parser.add_argument('--output_prefix', '-o', default="", help="Output file prefix.") parser.add_argument('--outfile', '-o', default="", help="Output file name for lcp graph.")
parser.add_argument('--threads', '-t', default=8, type=int, help='Number of thread to use for dgraph computation') parser.add_argument('--threads', '-t', default=8, type=int, help='Number of thread to use for dgraph computation')
parser.add_argument('--debug', '-d', action='store_true', help="Debug") parser.add_argument('--debug', '-d', action='store_true', help="Debug")
parser.add_argument('--verbose', '-v', action='store_true', help="Verbose") parser.add_argument('--verbose', '-v', action='store_true', help="Verbose")
...@@ -20,8 +20,8 @@ def parse_arguments(): ...@@ -20,8 +20,8 @@ def parse_arguments():
args = parser.parse_args() args = parser.parse_args()
if args.output_prefix == "": if args.outfile == "":
args.output_prefix = ".".join(args.barcode_graph.split(".")[:-1]) + "_lcpg" args.outfile = ".".join(args.barcode_graph.split(".")[:-1]) + "_lcpg.gexf"
return args return args
...@@ -43,7 +43,7 @@ def main(): ...@@ -43,7 +43,7 @@ def main():
debug_path = "/dev/null" debug_path = "/dev/null"
if args.debug: if args.debug:
debug = True debug = True
debug_path = f"{args.output_prefix}_debug" debug_path = ".".join(args.barcode_graph.split(".")[:-1]) + "_debug"
import os, shutil import os, shutil
if os.path.isdir(debug_path): if os.path.isdir(debug_path):
shutil.rmtree(debug_path) shutil.rmtree(debug_path)
...@@ -58,7 +58,7 @@ def main(): ...@@ -58,7 +58,7 @@ def main():
verbose=args.verbose verbose=args.verbose
) )
nx.write_gexf(d2g, f"{args.output_prefix}.gexf") nx.write_gexf(d2g, args.outfile)
if __name__ == "__main__": if __name__ == "__main__":
......
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