-
Notifications
You must be signed in to change notification settings - Fork 0
/
MutationCall_DNA_MakingReferenceSNPdb.nf
executable file
·222 lines (159 loc) · 5.89 KB
/
MutationCall_DNA_MakingReferenceSNPdb.nf
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
#!/usr/bin/env nextflow
params.bam = ''
params.ref = ''
sequences = Channel.fromPath( params.bam ).map { file -> tuple(file.baseName, file) }
sequencesintomutationalcalling = Channel.fromPath( params.bam ).map { file -> tuple(file.baseName, file) } // You cannot use the same input twice in a channel, therefore we are copying it in twice
ref_index = file(params.ref)
//params.workingDir = '.'
//params.outdir = '/jumbo/WorkingDir/B19-057/Data/Meta/Alignment/Epidermidis/testNextflow'
params.outdir = ''
//Something is of with the transfer of the files
//----------------------Samtools-------------------------------
process run_samtools {
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
module 'samtools/1.9'
input:
set file_ID, file(bamfile) from sequences
output:
set file_ID, "${file_ID}.*" into samtools_out
script:
"""
samtools index ${bamfile}
samtools flagstat ${bamfile} > ${file_ID}.flagstat
samtools idxstats ${bamfile} > ${file_ID}.idxstat
"""
}
//----------------------AddReadsGroups-------------------------------
process run_addingReadsGroups {
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(bamfile) from sequencesintomutationalcalling
output:
set file_ID, "${file_ID}.With_RG.bam", "${file_ID}.With_RG.bai" into rg_out
script:
"""
java -jar /apps/bio/apps/picard/2.1.0/picard.jar AddOrReplaceReadGroups I=${bamfile} O=${file_ID}.With_RG.bam SORT_ORDER=coordinate RGID=${file_ID} RGLB=${file_ID} RGPL=illumina RGPU=${file_ID} RGSM=${file_ID} CREATE_INDEX=True
"""
}
//----------------------RemovePCRduplicates-------------------------------
process runRemovePCRdup {
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(rgbam), file(rgbai) from rg_out
output:
set file_ID, "${file_ID}.rmdup.bam","${file_ID}.rmdup.bai" into rmdup_out1, rmdup_out2
script:
"""
java -Xmx4g -jar /apps/bio/apps/picard/2.1.0/picard.jar MarkDuplicates I=${rgbam} O=${file_ID}.rmdup.bam CREATE_INDEX=True M=${file_ID}.marked_dup_metrics.txt
"""
}
//----------------------RealignTargetCreator-------------------------------
process run_realignTargetCreator {
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 4'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(rdupbam), file(rdupbai) from rmdup_out1
output:
set file_ID, "${file_ID}.intervals" into intervals
script:
"""
java -jar /apps/bio/apps/gatk/3.5/GenomeAnalysisTK.jar -T RealignerTargetCreator -I ${rdupbam} -o ${file_ID}.intervals -R ${ref_index}
"""
}
//----------------------IndelRealignment-------------------------------
process run_indelrealigner{
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 4'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(interval) from intervals
set file_ID, file(rdupbam), file(rdupbai) from rmdup_out2
output:
set file_ID, "${file_ID}.realigned.bam" into realigned
script:
"""
java -Xmx4g -jar /apps/bio/apps/gatk/3.5/GenomeAnalysisTK.jar -T IndelRealigner -R ${ref_index} --targetIntervals ${interval} -I ${rdupbam} -o ${file_ID}.realigned.bam
"""
}
//----------------------SNPCalling-------------------------------
process run_SNPcalling{
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(realbam) from realigned
output:
set file_ID, "${file_ID}.vcf" into rawsnps
script:
"""
/apps/bio/apps/samtools/1.6/samtools index ${realbam}
java -Xmx4g -jar /apps/bio/apps/gatk/3.5/GenomeAnalysisTK.jar -T HaplotypeCaller -R ${ref_index} -I ${realbam} -o ${file_ID}.vcf
"""
}
//----------------------HardFilter-------------------------------
process run_HardFilter{
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(unfilteredvcf) from rawsnps
output:
set file_ID, "${file_ID}.flag.vcf" into hardfilteredsnps
script:
"""
java -Xmx4g -jar /apps/bio/apps/gatk/3.5/GenomeAnalysisTK.jar -T VariantFiltration -R ${ref_index} --variant ${unfilteredvcf} -o ${file_ID}.flag.vcf --filterExpression "DP < 50" --filterName "LowDP" --filterExpression "QD < 2.0" --filterName "QD" --filterExpression "MQ < 40.0" --filterName "MQ"
"""
}
//----------------------PassedHardFilter-------------------------------
process run_greppassed{
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(filteredvcf) from hardfilteredsnps
output:
set file_ID, "${file_ID}.Passed.vcf" into passedfilteredsnps
script:
"""
grep -E '^#|PASS' ${filteredvcf} > ${file_ID}.Passed.vcf
"""
}
//----------------------SortingVCF-------------------------------
process run_sortVCF{
publishDir params.outdir, mode: 'copy', overwrite: true
//errorStrategy 'ignore'
clusterOptions='-pe mpi 1'
executor 'sge'
queue '[email protected]'
input:
set file_ID, file(passedvcf) from passedfilteredsnps
output:
set file_ID, "${file_ID}.Sorted.vcf" into sortedvcf
script:
"""
java -jar /apps/bio/apps/picard/2.1.0/picard.jar SortVcf I=${passedvcf} O=${file_ID}.Sorted.vcf
"""
}