-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSnakefile
76 lines (63 loc) · 1.82 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
import os
def get_fast5(wildcards):
return config["fast5"][wildcards.sample]
def get_fastq(wildcards):
return config["fastq"][wildcards.sample]
def get_bam(wildcards):
return config["bam"][wildcards.sample]
def get_region(wildcards):
return config["region"][wildcards.region]
rule all:
input:
expand("methylation_frequency/{region}_{sample}.tsv",
sample=config["fastq"],
region=config["region"])
rule nanopolish_index:
input:
f5 = get_fast5,
fq = get_fastq,
output:
"indices/index_done_{sample}"
threads: 10 # Just to ensure that this is not ran in parallel for too many samples
log:
"logs/nanopolish_index/index_{sample}.log"
shell:
"""
nanopolish index -d {input.f5}/ {input.fq} 2> {log}
touch {output}
"""
rule call_methylation:
input:
idx = "indices/index_done_{sample}",
fq = get_fastq,
bam = get_bam,
genome = config["genome"],
output:
"methylation_calls/{region}_{sample}.tsv"
threads: 8
params:
region = get_region,
log:
"logs/methylation/methcall_{region}_{sample}.log"
shell:
"""
nanopolish call-methylation \
-t {threads} \
-r {input.fq} \
-b {input.bam} \
-g {input.genome} \
-w {params.region} > {output} 2> {log}
"""
rule methylation_frequency:
input:
"methylation_calls/{region}_{sample}.tsv"
output:
"methylation_frequency/{region}_{sample}.tsv"
log:
"logs/methylation/methfreq_{region}_{sample}.log"
params:
script = os.path.join(workflow.basedir, "scripts/calculate_methylation_frequency.py")
shell:
"""
python {params.script} -i {input} > {output} 2> {log}
"""