This repository has been archived by the owner on Jan 27, 2020. It is now read-only.
forked from nf-core/sarek
-
Notifications
You must be signed in to change notification settings - Fork 7
/
runMultiQC.nf
223 lines (192 loc) · 7.7 KB
/
runMultiQC.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
222
223
#!/usr/bin/env nextflow
/*
kate: syntax groovy; space-indent on; indent-width 2;
================================================================================
= S A R E K =
================================================================================
New Germline (+ Somatic) Analysis Workflow. Started March 2016.
--------------------------------------------------------------------------------
@Authors
Sebastian DiLorenzo <[email protected]> [@Sebastian-D]
Jesper Eisfeldt <[email protected]> [@J35P312]
Phil Ewels <[email protected]> [@ewels]
Maxime Garcia <[email protected]> [@MaxUlysse]
Szilveszter Juhos <[email protected]> [@szilvajuhos]
Max Käller <[email protected]> [@gulfshores]
Malin Larsson <[email protected]> [@malinlarsson]
Marcel Martin <[email protected]> [@marcelm]
Björn Nystedt <[email protected]> [@bjornnystedt]
Pall Olason <[email protected]> [@pallolason]
--------------------------------------------------------------------------------
@Homepage
http://opensource.scilifelab.se/projects/sarek/
--------------------------------------------------------------------------------
@Documentation
https://github.com/SciLifeLab/Sarek/README.md
--------------------------------------------------------------------------------
Processes overview
- GetVersionAll - Get version of tools
- RunMultiQC - Run MultiQC on reports
================================================================================
= C O N F I G U R A T I O N =
================================================================================
*/
if (params.help) exit 0, helpMessage()
if (!SarekUtils.isAllowedParams(params)) exit 1, "params unknown, see --help for more information"
if (!checkUppmaxProject()) exit 1, "No UPPMAX project ID found! Use --project <UPPMAX Project ID>"
if (params.verbose) SarekUtils.verbose()
// Check for awsbatch profile configuration
// make sure queue is defined
if (workflow.profile == 'awsbatch') {
if (!params.awsqueue) exit 1, "Provide the job queue for aws batch!"
}
/*
================================================================================
= P R O C E S S E S =
================================================================================
*/
startMessage()
process GetVersionAll {
publishDir "${params.outDir}/Reports/MultiQC", mode: params.publishDirMode
input:
output:
file ("tool_versions_mqc.yaml") into versionsForMultiQC
when: !params.noReports
script:
"""
bcftools version > v_bcftools.txt 2>&1 || true
bwa &> v_bwa.txt 2>&1 || true
configManta.py --version > v_manta.txt 2>&1 || true
configureStrelkaGermlineWorkflow.py --version > v_strelka.txt 2>&1 || true
echo "${workflow.manifest.version}" &> v_sarek.txt 2>&1 || true
echo "${workflow.nextflow.version}" &> v_nextflow.txt 2>&1 || true
echo "SNPEFF version"\$(snpEff -h 2>&1) > v_snpeff.txt
fastqc -v > v_fastqc.txt 2>&1 || true
freebayes --version > v_freebayes.txt 2>&1 || true
gatk ApplyBQSR --help 2>&1 | grep Version: > v_gatk.txt 2>&1 || true
multiqc --version &> v_multiqc.txt 2>&1 || true
qualimap --version &> v_qualimap.txt 2>&1 || true
samtools --version &> v_samtools.txt 2>&1 || true
vcftools --version &> v_vcftools.txt 2>&1 || true
vep --help &> v_vep.txt 2>&1 || true
alleleCounter --version &> v_allelecount.txt || true
R --version &> v_r.txt || true
cat ${baseDir}/scripts/ascat.R | grep "ASCAT version" &> v_ascat.txt || true
scrape_tool_versions.py &> tool_versions_mqc.yaml
"""
}
versionsForMultiQC = versionsForMultiQC.dump(tag:'Versions')
reportsForMultiQC = Channel.empty()
.mix(
Channel.fromPath("${params.outDir}/Reports/bamQC/*", type: 'dir'),
Channel.fromPath("${params.outDir}/Reports/BCFToolsStats/*"),
Channel.fromPath("${params.outDir}/Reports/FastQC/*/*"),
Channel.fromPath("${params.outDir}/Reports/MarkDuplicates/*"),
Channel.fromPath("${params.outDir}/Reports/SamToolsStats/*"),
Channel.fromPath("${params.outDir}/Annotation/*/snpEff/*.csv"),
Channel.fromPath("${params.outDir}/Reports/VCFTools/*"),
).collect()
process RunMultiQC {
publishDir "${params.outDir}/Reports/MultiQC", mode: params.publishDirMode
input:
file (multiqcConfig) from createMultiQCconfig()
file (reports) from reportsForMultiQC
file (versions) from versionsForMultiQC
output:
set file("*multiqc_report.html"), file("*multiqc_data") into multiQCReport
when: !params.noReports
script:
"""
multiqc -f -v .
"""
}
multiQCReport.dump(tag:'MultiQC')
/*
================================================================================
= F U N C T I O N S =
================================================================================
*/
def checkUppmaxProject() {
// check if UPPMAX project number is specified
return !(workflow.profile == 'slurm' && !params.project)
}
def createMultiQCconfig() {
def file = workDir.resolve('multiqc_config.yaml')
file.text = """
custom_logo: ${baseDir}/docs/images/Sarek_no_Border.png
custom_logo_url: https://sarek.scilifelab.se/
custom_logo_title: 'Sarek'
report_header_info:
- Contact Name: ${params.callName}
- Contact E-mail: ${params.contactMail}
- Genome: ${params.genome}
top_modules:
- 'fastqc'
- 'picard'
- 'samtools'
- 'qualimap'
- 'bcftools'
- 'vcftools'
- 'snpeff'
""".stripIndent()
return file
}
def grabRevision() {
// Return the same string executed from github or not
return workflow.revision ?: workflow.commitId ?: workflow.scriptId.substring(0,10)
}
def helpMessage() {
// Display help message
this.sarekMessage()
log.info " Usage:"
log.info " nextflow run runMultiQC.nf"
log.info " --help"
log.info " you're reading it"
}
def minimalInformationMessage() {
// Minimal information message
log.info "Command Line: " + workflow.commandLine
log.info "Profile : " + workflow.profile
log.info "Project Dir : " + workflow.projectDir
log.info "Launch Dir : " + workflow.launchDir
log.info "Work Dir : " + workflow.workDir
log.info "Out Dir : " + params.outDir
log.info "Genome : " + params.genome
log.info "Genome_base : " + params.genome_base
log.info "Containers"
if (params.repository != "") log.info " Repository : " + params.repository
if (params.containerPath != "") log.info " ContainerPath: " + params.containerPath
log.info " Tag : " + params.tag
}
def nextflowMessage() {
// Nextflow message (version + build)
log.info "N E X T F L O W ~ version ${workflow.nextflow.version} ${workflow.nextflow.build}"
}
def sarekMessage() {
// Display Sarek message
log.info "Sarek - Workflow For Somatic And Germline Variations ~ ${workflow.manifest.version} - " + this.grabRevision() + (workflow.commitId ? " [${workflow.commitId}]" : "")
}
def startMessage() {
// Display start message
SarekUtils.sarek_ascii()
this.sarekMessage()
this.minimalInformationMessage()
}
workflow.onComplete {
// Display complete message
this.nextflowMessage()
this.sarekMessage()
this.minimalInformationMessage()
log.info "Completed at: " + workflow.complete
log.info "Duration : " + workflow.duration
log.info "Success : " + workflow.success
log.info "Exit status : " + workflow.exitStatus
log.info "Error report: " + (workflow.errorReport ?: '-')
}
workflow.onError {
// Display error message
this.nextflowMessage()
this.sarekMessage()
log.info "Workflow execution stopped with the following message:"
log.info " " + workflow.errorMessage
}