-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snakefile
155 lines (141 loc) · 4.2 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
fc = config["Flowcell_id"]
guppy_bin = config["bin"]["guppy_bin"]
guppyduplex_bin = config["bin"]["guppy_duplex_bin"]
duplextools_bin = config["bin"]["duplex_tool"]
fastq_merge_bin = config["bin"]["fastq_merge_bin"]
MinIONQC = config["bin"]["minionqc"]
rule all:
input:
"{fc}_FastqMerge/MinIONQC_Q7".format(fc=fc),
"{fc}_FastqMerge/sequencing_summary.txt".format(fc=fc),
"{fc}_DuplexTool/pair_ids_filtered.txt".format(fc=fc),
"{fc}_SecondBasecall/sequencing_summary.txt".format(fc=fc)
rule FirstBasecaller:
input:
config["RawData"]
output:
outdir = directory("{fc}_FirstBasecall"),
seqsum = "{fc}_FirstBasecall/sequencing_summary.txt"
threads: 10
params:
model_path=config["modelPath"],
model=config["modelFile"],
gpu_runners=config["firstCall"]["gpu_runners"],
device=config["cuda"],
log:
"{fc}_FirstBasecaller.log",
shell:
"""
mkdir -p {output.outdir}
{guppy_bin}/guppy_basecaller \
-r --fast5_out \
--device {params.device} \
-i {input} \
-s {output.outdir} \
-d {params.model_path} \
-c {params.model} \
--num_callers 20 \
--gpu_runners_per_device {params.gpu_runners} \
2> {log}
"""
rule DuplexPair:
input:
"{fc}_FirstBasecall/sequencing_summary.txt",
output:
outdir = directory("{fc}_DuplexTool"),
pairids="{fc}_DuplexTool/pair_ids.txt"
conda:
"env/duplextool.yaml"
log:
"{fc}_DuplexPair.log",
shell:
"""
mkdir -p {output.outdir}
{duplextools_bin}/duplex_tools pairs_from_summary \
{input} {output.outdir}/. 2> {log}
"""
rule DuplexFilter:
input:
"{fc}_DuplexTool/pair_ids.txt",
output:
pair_filtered="{fc}_DuplexTool/pair_ids_filtered.txt"
params:
FirstBasecall="{fc}_FirstBasecall",
conda:
"env/duplextool.yaml"
log:
"{fc}_DuplexFilter.log",
shell:
"""
{duplextools_bin}/duplex_tools filter_pairs \
{input} \
{params.FirstBasecall} 2>{log}
"""
rule GuppyDuplex:
input:
rawData=config["RawData"],
pair_filtered="{fc}_DuplexTool/pair_ids_filtered.txt"
output:
outdir = directory("{fc}_SecondBasecall"),
seqsum = "{fc}_SecondBasecall/sequencing_summary.txt"
params:
model_path=config["modelPath"],
model=config["modelFile"],
gpu_runners=config["secondCall"]["gpu_runners"],
device=config["cuda"],
log:
"{fc}_GuppyDuplex.log",
threads: 10
shell:
"""
mkdir -p {output.outdir}
{guppyduplex_bin}/guppy_basecaller_duplex \
--compress_fastq \
-r \
-i {input.rawData} \
-s {output.outdir} \
-d {params.model_path} \
-c {params.model} \
--duplex_pairing_mode from_pair_list \
--duplex_pairing_file {input.pair_filtered} \
-x {params.device} \
--chunk_size 1000 \
--chunks_per_runner 20 \
--read_batch_size 1000 \
--gpu_runners_per_device {params.gpu_runners} \
2>{log}
"""
rule fastqMerge:
input:
FirstBasecall="{fc}_FirstBasecall",
SecondBasecall="{fc}_SecondBasecall",
output:
fastq="{fc}_FastqMerge/{fc}_merged.fastq.gz",
report="{fc}_FastqMerge/{fc}_merged.report.log",
seqsum="{fc}_FastqMerge/sequencing_summary.txt",
#conda:
# "env/fastqmerged.yaml"
log:
"{fc}_fastqMerge.log",
shell:
"""
mkdir -p {fc}_FastqMerge
{fastq_merge_bin}/fastq_merge -r {output.report} \
-S {output.seqsum} \
{input.SecondBasecall} \
{input.FirstBasecall} \
| gzip -c > {output.fastq} 2>{log}
"""
rule minIONQC:
input:
"{fc}_FastqMerge/sequencing_summary.txt",
output:
directory("{fc}_FastqMerge/MinIONQC_Q7"),
threads: 10
conda:
"env/minionqc.yaml"
shell:
"""
mkdir -p {output}
Rscript {MinIONQC}/MinIONQC.R -p {threads} -i {input} -o {output}
"""