Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yoann DUFRESNE
linked reads molecule ordering
Commits
68945d74
Commit
68945d74
authored
May 14, 2020
by
Yoann Dufresne
Browse files
snakefile for evaluation of paths
parent
26206cc7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Snakefile_d2
View file @
68945d74
...
...
@@ -39,6 +39,8 @@ rule d2_simplification:
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}"
...
...
@@ -49,6 +51,8 @@ rule d2_generation:
output:
d2_file=f"{WORKDIR}/{{file}}_d2_raw_{{method}}.gexf"
threads: workflow.cores
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}}")
...
...
Snakefile_d2_eval
View file @
68945d74
include: "Snakefile_data_simu"
include: "Snakefile_d2"
include: "Snakefile_d2_path"
WORKDIR = "snake_experiments" if "workdir" not in config else config["workdir"]
N = [1000]
...
...
@@ -13,7 +14,8 @@ rule generate_compare:
rule comparable_tsv:
input:
expand(f"{WORKDIR}/simu_0_bar_n{{n}}_d{{d}}_m{{m}}-dev{{dev}}_d2_simplified_maxclq_eval.txt", m=M, d=D, n=N, dev=DEV)
d2_evals = expand(f"{WORKDIR}/simu_0_bar_n{{n}}_d{{d}}_m{{m}}-dev{{dev}}_d2_simplified_maxclq_eval_d2.txt", m=M, d=D, n=N, dev=DEV),
path_evals = expand(f"{WORKDIR}/simu_0_bar_n{{n}}_d{{d}}_m{{m}}-dev{{dev}}_d2_simplified_maxclq_eval_path.txt", m=M, d=D, n=N, dev=DEV)
output:
f"{WORKDIR}/eval_compare.tsv"
run:
...
...
@@ -22,14 +24,27 @@ rule comparable_tsv:
for d in D:
for m in M:
for dev in DEV:
with open(f"{WORKDIR}/simu_0_bar_n{n}_d{d}_m{m}-dev{dev}_d2_simplified_maxclq_eval.txt") as f:
longest_path = f.readlines()[8].strip().split(': ')[-1]
print(f"{n}\t{m}\t{dev}\t{longest_path}", file=out)
with open(f"{WORKDIR}/simu_0_bar_n{n}_d{d}_m{m}-dev{dev}_d2_simplified_maxclq_eval_d2.txt") as f_d2,\
open(f"{WORKDIR}/simu_0_bar_n{n}_d{d}_m{m}-dev{dev}_d2_simplified_maxclq_eval_path.txt") as d_path:
longest_path_d2 = f_d2.readlines()[8].strip().split(': ')[-1]
path_eval_lines = d_path.readlines()
greedy_path = path_eval_lines[-1].strip().split(' ')[-1]
splits = "/".join(path_eval_lines[-2].strip().split(': ')[-1].split(' - '))
print(f"{n}\t{m}\t{dev}\t{longest_path_d2}\t{greedy_path}\t{splits}", file=out)
rule eval:
rule eval
_d2
:
input:
"{file}_d2_simplified_maxclq.gexf"
output:
"{file}_d2_simplified_maxclq_eval.txt"
"{file}_d2_simplified_maxclq_eval
_d2
.txt"
shell:
"python3 deconvolution/main/evaluate.py -t d2 {input} > {output}"
rule eval_path:
input:
barcode="{barcode_file}.gexf",
path="{barcode_file}_d2_simplified_maxclq_path.gexf"
output:
"{barcode_file}_d2_simplified_maxclq_eval_path.txt"
shell:
"python3 deconvolution/main/evaluate.py --type path {input.path} -l -b {input.barcode} > {output}"
Snakefile_d2_path
0 → 100644
View file @
68945d74
number_try = 10
threshold = 0.5
rule d2_path_generation:
input:
barcode="{path}.gexf",
d2="{path}_d2_{type}_{method}.gexf"
output:
"{path}_d2_{type}_{method}_path.gexf"
run:
for _ in range(number_try):
shell("python3 deconvolution/main/d2_to_path.py {input.barcode} {input.d2} > tmp_{output}.out")
score = 0
with open("tmp_{output}.out") as out:
score_line = out.readlines()[-2].strip()
score = float(score_line.split(' ')[-1])
print(score)
if score > threshold:
print("Score sufficient: quitting...")
break
shell("rm tmp_{output}.out")
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment