-
Notifications
You must be signed in to change notification settings - Fork 0
/
snakefile
95 lines (77 loc) · 2.94 KB
/
snakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
SAMPLES = ["LS140", "E15", "L86"]
BINARY = ["binary", "binaryError"]
GT16 = ["gt16", "gt16Error"]
wildcard_constraints:
# Global wildcard constraints, in a regex form; a|b means a OR b.
# adapted from https://stackoverflow.com/a/59227356/4868692
sample = '|'.join([x for x in SAMPLES]),
template = '|'.join([x for x in BINARY+GT16])
rule all:
input:
expand("results/{sample}/{template}/done", sample=["E15", "L86"], template=BINARY+GT16),
expand("results/{sample}/{template}/done", sample=["LS140"], template=BINARY)
rule vcf2fasta:
input:
"data/{sample}.vcf",
output:
"results/{sample}/{sample}_{template}.fasta"
params:
encoding = lambda w: "binary" if w.template in BINARY else "nd16"
shell:
"python src/vcf2fasta.py {input} {output} --encoding {params.encoding}"
rule fasta2stats:
input:
"results/{sample}/{sample}_{template}.fasta"
output:
stats = "results/{sample}/{sample}_{template}.stats.txt",
fasta = "results/{sample}/{sample}_{template}.filtered.fasta"
shell:
"Rscript src/fasta2stats.r {input} {output.stats} --filtered {output.fasta}"
rule fasta2xml:
input:
fasta = "results/{sample}/{sample}_{template}.filtered.fasta",
template = "templates/{template}.xml"
output:
"results/{sample}/{template}/{sample}_{template}.xml"
params:
datatype = lambda w: "nucleotideDiploid16" if w.template in GT16 else "standard"
shell:
"Rscript src/fasta2xml.r {input.template} {input.fasta} {output} --datatype {params.datatype}"
rule beast:
input:
"results/{sample}/{template}/{sample}_{template}.xml"
output:
"results/{sample}/{template}/{sample}_{template}.trace",
"results/{sample}/{template}/{sample}_{template}.trees",
"results/{sample}/{template}/{sample}_{template}.log"
params:
beast = os.path.abspath("bin/beast-phylonco.jar"),
input = "{sample}_{template}.xml",
log = "{sample}_{template}.log",
dir = "results/{sample}/{template}"
shell:
"cd {params.dir} && java -jar {params.beast} {params.input} > {params.log}"
rule loganalyser:
input:
"results/{sample}/{template}/{sample}_{template}.trace"
output:
"results/{sample}/{template}/{sample}_{template}.ess.txt"
shell:
"loganalyser -b 20 {input} > {output}"
rule treeannotator:
input:
"results/{sample}/{template}/{sample}_{template}.trees"
output:
"results/{sample}/{template}/{sample}_{template}.tree"
shell:
"treeannotator -b 20 -lowMem {input} {output}"
rule done:
input:
tree = "results/{sample}/{template}/{sample}_{template}.tree",
ess = "results/{sample}/{template}/{sample}_{template}.ess.txt",
log = "results/{sample}/{template}/{sample}_{template}.log"
output:
"results/{sample}/{template}/done"
shell:
"touch {output}"