-
Notifications
You must be signed in to change notification settings - Fork 0
/
snakefile
173 lines (156 loc) · 5.4 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
import sys
import os
shell.executable('/bin/bash')
t = config['threads']
IDS, = glob_wildcards('reads/{sample}_R1.fastq.bz2')
rule all:
input:
expand('results/{sample}/{sample}_proteome.gbk', sample=IDS),
expand('results/{sample}/{sample}_proteome.faa', sample=IDS),
expand('results/{sample}/{sample}_genome.fasta', sample=IDS),
expand('results/{sample}/{sample}_genome.gfa', sample=IDS),
expand('results/{sample}/{sample}_assembly_QC.pdf', sample=IDS),
expand('results/{sample}/assembly/proteome_{sample}', sample=IDS),
expand('results/{sample}/{sample}_Plasmid_abricate.csv', sample=IDS),
expand('results/{sample}/{sample}_AMR_abricate.csv', sample=IDS),
expand('results/{sample}/{sample}_QC.html', sample=IDS),
expand('results/{sample}/{sample}_QC.json', sample=IDS),
expand('results/{sample}/{sample}_species.html', sample=IDS),
expand('reads/QC_reads/{sample}_QC_R2.fastq.gz', sample=IDS),
expand('reads/QC_reads/{sample}_QC_R1.fastq.gz', sample=IDS),
expand('reads/{sample}_R2.fastq.gz', sample=IDS),
expand('reads/{sample}_R1.fastq.gz', sample=IDS),
rule bz_2_gz_R1:
input: 'reads/{sample}_R1.fastq.bz2',
output:
temp('reads/{sample}_R1.fastq.gz'),
threads: t
shell: "lbunzip2 {input} -dc | pigz -4 -c -p {threads} > {output}"
rule bz_2_gz_R2:
input: 'reads/{sample}_R2.fastq.bz2',
output:
temp('reads/{sample}_R2.fastq.gz'),
threads: t
shell: "lbunzip2 {input} -dc | pigz -4 -c -p {threads} > {output}"
rule fastp:
input:
s1 = 'reads/{sample}_R1.fastq.gz',
s2 = 'reads/{sample}_R2.fastq.gz',
output:
s1 = 'reads/QC_reads/{sample}_QC_R1.fastq.gz',
s2 = 'reads/QC_reads/{sample}_QC_R2.fastq.gz',
s3 = 'results/{sample}/{sample}_QC.html',
s4 = 'results/{sample}/{sample}_QC.json',
threads: t
shell:
'''
fastp -i {input.s1} -I {input.s2} -o {output.s1} -O {output.s2} -h {output.s3} -j {output.s4} --detect_adapter_for_pe --thread {threads}
'''
rule kraken2:
input:
s1 = 'reads/QC_reads/{sample}_QC_R1.fastq.gz',
s2 = 'reads/QC_reads/{sample}_QC_R2.fastq.gz',
output:
temp('scripts/kraken2/{sample}_kraken2.txt'),
threads: t
params:
db = config['db1']
shell:
'''
kraken2 --quick --threads {threads} --db {params.db} --gzip-compressed --paired {input.s1} {input.s2} --output {output}
'''
rule kraken_plot:
input: 'scripts/kraken2/{sample}_kraken2.txt',
output: 'results/{sample}/{sample}_species.html',
shell: 'ktImportTaxonomy -q 2 -t 3 {input} -o {output}'
rule unicycler:
input:
s1 = 'reads/QC_reads/{sample}_QC_R1.fastq.gz',
s2 = 'reads/QC_reads/{sample}_QC_R2.fastq.gz',
output:
directory('results/{sample}/assembly/{sample}_genome_unicycler'),
threads: t
params:
md = config['md']
shell:
'''
unicycler -1 {input.s1} -2 {input.s2} -o {output} --mode {params.md} --no_correct --threads {threads} --keep 0 --verbosity 1
'''
rule abricate_AMR:
input:
'results/{sample}/assembly/{sample}_genome_unicycler',
output:
'results/{sample}/{sample}_AMR_abricate.csv',
threads: t
shell:
'''
abricate --db card --csv --threads {threads} {input}/assembly.fasta > {output}
'''
rule abricate_Plasmid:
input:
'results/{sample}/assembly/{sample}_genome_unicycler',
output:
'results/{sample}/{sample}_Plasmid_abricate.csv',
threads: t
shell:
'''
abricate --db plasmidfinder --csv --threads {threads} {input}/assembly.fasta > {output}
'''
rule prokka:
input:
'results/{sample}/assembly/{sample}_genome_unicycler',
output:
directory('results/{sample}/assembly/proteome_{sample}'),
threads: t
shell:
'''
prokka {input}/assembly.fasta -prefix proteome --addgenes --compliant --outdir {output} --cpu {threads}
'''
rule ideel_1:
input:
'results/{sample}/assembly/{sample}_genome_unicycler',
output:
temp('scripts/proteins/{sample}.faa'),
shell:
'''
prodigal -a {output} -q -i {input}/assembly.fasta
'''
rule ideel_2:
input:
'scripts/proteins/{sample}.faa',
output:
temp('scripts/lengths/{sample}.data'),
threads: t
params:
db = config['db2'],
of = '6 qlen slen',
shell:
'''
diamond blastp --threads {threads} --max-target-seqs 1 --db {params.db} --query {input} --outfmt {params.of} --out {output}
'''
rule ideel_3:
input: 'scripts/lengths/{sample}.data',
output: 'results/{sample}/{sample}_assembly_QC.pdf',
script: 'scripts/hist.R'
rule unicycler_rename:
input:
'results/{sample}/assembly/{sample}_genome_unicycler',
output:
s1 = 'results/{sample}/{sample}_genome.fasta',
s2 = 'results/{sample}/{sample}_genome.gfa',
shell:
'''
cp '{input}/assembly.fasta' '{output.s1}'
cp '{input}/assembly.gfa' '{output.s2}'
'''
rule prokka_rename:
input:
'results/{sample}/assembly/proteome_{sample}',
output:
s1 = 'results/{sample}/{sample}_proteome.faa',
s2 = 'results/{sample}/{sample}_proteome.gbk',
shell:
'''
cp '{input}/proteome.faa' '{output.s1}'
cp '{input}/proteome.gbk' '{output.s2}'
'''