diff --git a/Snakefile_d2 b/Snakefile_d2 index 047beaf91fad75afdd4dcdbc53d1273976b50ef3..3cc97f50ab2c71cb378636143fc034f42bd0944c 100644 --- a/Snakefile_d2 +++ b/Snakefile_d2 @@ -35,14 +35,13 @@ rule compress_data: rule d2_simplification: input: - barcode_graph="{barcode_path}.gexf", d2_raw="{barcode_path}_d2_raw_{method}.gexf" output: simplified_d2="{barcode_path}_d2_simplified_{method}.gexf" wildcard_constraints: method="[A-Za-z0-9]+" 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: @@ -54,7 +53,7 @@ rule d2_generation: wildcard_constraints: method="[A-Za-z0-9]+" 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: diff --git a/Snakefile_d2_eval b/Snakefile_d2_eval index b59d8232494bd61134de2bdd821afc725490bc4a..e88cef73de92b44c40ba1db4bdbdd45273cf8a1f 100644 --- a/Snakefile_d2_eval +++ b/Snakefile_d2_eval @@ -3,10 +3,10 @@ include: "Snakefile_d2" include: "Snakefile_d2_path" WORKDIR = "snake_experiments" if "workdir" not in config else config["workdir"] -N = [5000, 10000] -D = [10] -M = [2, 3] -DEV = [0, 1] +N = [500] +D = [6] +M = [2] +DEV = [0] rule generate_compare: input: diff --git a/Snakefile_d2_path b/Snakefile_d2_path index 70feb45768926b6e9ec9c789d60209dfc0116b9e..a57e3ec70b708e48a05eaf13733a79f870e4a278 100644 --- a/Snakefile_d2_path +++ b/Snakefile_d2_path @@ -5,14 +5,13 @@ threshold = 0.9 rule d2_path_generation: input: - barcode="{path}.gexf", d2="{path}_d2_{type}_{method}.gexf" output: "{path}_d2_{type}_{method}_path.gexf" run: best = 0 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 with open(f"{output}_tmp.out") as out: score_line = out.readlines()[-2].strip() diff --git a/deconvolution/main/to_d2_graph.py b/deconvolution/main/to_d2_graph.py index cb308524c11551dc0e8ef450b81a32677fcc84d0..b4ea801bb307819f78cce99a590b74d8b8ece316 100755 --- a/deconvolution/main/to_d2_graph.py +++ b/deconvolution/main/to_d2_graph.py @@ -10,7 +10,7 @@ from deconvolution.d2graph import d2_graph as d2 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.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('--debug', '-d', action='store_true', help="Debug") parser.add_argument('--verbose', '-v', action='store_true', help="Verbose") @@ -20,8 +20,8 @@ def parse_arguments(): args = parser.parse_args() - if args.output_prefix == "": - args.output_prefix = ".".join(args.barcode_graph.split(".")[:-1]) + "_lcpg" + if args.outfile == "": + args.outfile = ".".join(args.barcode_graph.split(".")[:-1]) + "_lcpg.gexf" return args @@ -43,7 +43,7 @@ def main(): debug_path = "/dev/null" if args.debug: debug = True - debug_path = f"{args.output_prefix}_debug" + debug_path = ".".join(args.barcode_graph.split(".")[:-1]) + "_debug" import os, shutil if os.path.isdir(debug_path): shutil.rmtree(debug_path) @@ -58,7 +58,7 @@ def main(): verbose=args.verbose ) - nx.write_gexf(d2g, f"{args.output_prefix}.gexf") + nx.write_gexf(d2g, args.outfile) if __name__ == "__main__":