-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile
224 lines (200 loc) · 6.73 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
configfile: "config/config.yml"
threads_small=config["snakemake"]["threads_small"]
mem_small=config["snakemake"]["mem_small"]
threads_big=config["snakemake"]["threads_big"]
mem_big=config["snakemake"]["mem_big"]
wildcard_constraints:
chunk="\d+",
rule all:
input:
expand("results/{sample}/bowtie/{sample}.fastq.gz", sample=config["samples"]),
#expand("results/{sample}/step_02_qc_reads_with_vsearch/{sample}_trimmed_qcd.fasta", sample=config["samples"]),
expand("results/{sample}/step_07_combine_tsv/{sample}_trimmed_qcd_frags_interpro_combined.tsv", sample=config["samples"]),
expand("results/{sample}/bracken/{sample}_profiles.txt", sample=config["samples"]),
"results/killed_interproscan.txt",
bowtie_cmd = 'bowtie2 -x {params.idx} -U {input} --un-gz {output} -p {threads}'
bowtie_output = "results/{base}/bowtie/{base}.fastq.gz"
rule bowtie_fastq:
input:
"data/{base}.fastq"
output:
bowtie_output
params:
idx="data/bowtie_index/human+phiX",
#image="singularity/bowtie.simg /bowtie2/bowtie2-2.4.2/bowtie2",
threads: threads_small
resources:
mem_mb=mem_small
shell:
bowtie_cmd
rule bowtie_fastq_gz:
input:
"data/{base}.fastq.gz"
output:
bowtie_output
params:
idx="data/bowtie_index/human+phiX",
#image="singularity/bowtie.simg /bowtie2/bowtie2-2.4.2/bowtie2",
threads: threads_small
resources:
mem_mb=mem_small
shell:
bowtie_cmd
rule bowtie_fq:
input:
"data/{base}.fq"
output:
bowtie_output
params:
idx="data/bowtie_index/human+phiX",
#image="singularity/bowtie.simg /bowtie2/bowtie2-2.4.2/bowtie2",
threads: threads_small
resources:
mem_mb=mem_small
shell:
bowtie_cmd
rule bowtie_fq_gz:
input:
"data/{base}.fq.gz"
output:
bowtie_output
params:
idx="data/bowtie_index/human+phiX",
#image="singularity/bowtie.simg /bowtie2/bowtie2-2.4.2/bowtie2",
threads: threads_small
resources:
mem_mb=mem_small
shell:
bowtie_cmd
rule start_server:
output:
"results/interproscan.txt"
threads: 1
resources:
mem_mb=4000
shell:
"""
set -u
sh bash/edit_interproscan.sh {output}
"""
rule qc_pipeline:
input:
#fa="results/{base}.{ext}/bowtie/{base}",
fa="results/{base}/bowtie/{base}.fastq.gz",
output:
#fa="results/{base}.{ext}/step_02_qc_reads_with_vsearch/{base}_trimmed_qcd.fasta",
#log="results/{base}.{ext}/step_02_qc_reads_with_vsearch/log",
fa="results/{base}/step_02_qc_reads_with_vsearch/{base}_trimmed_qcd.fasta",
log="results/{base}/step_02_qc_reads_with_vsearch/log"
params:
config="config/config.yml",
#outdir="results/{base}.{ext}/",
outdir="results/{base}/"
threads: threads_small
resources:
mem_mb=mem_small
shell:
"""
set -u
python pipeline/qc_pipeline.py -c {params.config} -i {input.fa} -o {params.outdir} -t {threads}
"""
rule check_qc:
input:
#"results/{base}.{ext}/step_02_qc_reads_with_vsearch/log"
"results/{base}/step_02_qc_reads_with_vsearch/log"
output:
#"results/{base}.{ext}/step_02_qc_reads_with_vsearch/logcheck"
"results/{base}/step_02_qc_reads_with_vsearch/logcheck"
threads: 1
resources:
mem_mb=4000
shell:
"""
set -u
bash bash/check_qc.sh {input} {output}
"""
rule kraken2:
input:
#"results/{base}.{ext}/step_02_qc_reads_with_vsearch/{base}_trimmed_qcd.fasta"
"results/{base}/step_02_qc_reads_with_vsearch/{base}_trimmed_qcd.fasta"
output:
#cf="results/{base}.{ext}/kraken2/{base}_classified.fasta",
#rep="results/{base}.{ext}/kraken2/{base}_report.tsv"
cf="results/{base}/kraken2/{base}_classified.fasta",
rep="results/{base}/kraken2/{base}_report.tsv"
params:
db="tools/k2_pluspf_20230314"
threads: threads_big
resources:
mem_mb=mem_big
shell:
"""
bash -c '
. $HOME/.bashrc
conda activate kraken2
kraken2 --db {params.db} --classified-out {output.cf} --report {output.rep} --threads {threads} {input}
'
"""
rule bracken:
input:
#rep="results/{base}.{ext}/kraken2/{base}_report.tsv",
rep="results/{base}/kraken2/{base}_report.tsv",
output:
#profiles="results/{base}.{ext}/bracken/{base}_profiles.txt",
#rep="results/{base}.{ext}/bracken/{base}_report.txt"
profiles="results/{base}/bracken/{base}_profiles.txt",
rep="results/{base}/bracken/{base}_report.txt"
params:
length=300,
db="tools/k2_pluspf_20230314"
threads: threads_big
resources:
mem_mb=mem_big
shell:
"""
bash -c '
. $HOME/.bashrc
conda activate braken
bracken -d {params.db} -i {input.rep} -o {output.profiles} -w {output.rep} -r {params.length} -l S
'
"""
rule run_pipeline:
input:
#fa="results/{base}.{ext}/step_02_qc_reads_with_vsearch/{base}_trimmed_qcd.fasta",
fa="results/{base}/step_02_qc_reads_with_vsearch/{base}_trimmed_qcd.fasta",
ips="results/interproscan.txt",
#logcheck="results/{base}.{ext}/step_02_qc_reads_with_vsearch/logcheck",
logcheck="results/{base}/step_02_qc_reads_with_vsearch/logcheck",
output:
#"results/{base}.{ext}/step_07_combine_tsv/{base}_trimmed_qcd_frags_interpro_combined.tsv"
"results/{base}/step_07_combine_tsv/{base}_trimmed_qcd_frags_interpro_combined.tsv"
#"results/{base}.{ext}/step_05_chunk_reads/{base}_trimmed_qcd_frags_{chunk}.faa"
#"results/{base}.{ext}/step_04_get_gene_reads/{base}_trimmed_qcd_frags.faa"
params:
#indir="results/{base}.{ext}/step_02_qc_reads_with_vsearch/",
indir="results/{base}/step_02_qc_reads_with_vsearch/",
config="config/config.yml",
#outdir="results/{base}.{ext}",
outdir="results/{base}",
threads: threads_small
resources:
mem_mb=mem_small
shell:
"""
set -u
python pipeline/pipeline.py -c {params.config} -i {params.indir} -o {params.outdir} -t {threads}
"""
rule stop_server:
input:
expand("results/{sample}/step_07_combine_tsv/{sample}_trimmed_qcd_frags_interpro_combined.tsv", sample=config["samples"])
output:
"results/killed_interproscan.txt"
threads: 1
resources:
mem_mb=4000
shell:
"""
JOB=$(squeue -u $USER | grep "lookup" | head -1 | xargs | cut -d" " -f1)
scancel $JOB
touch {output}
"""