-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWES_Fingerprint.nf
61 lines (50 loc) · 2.17 KB
/
WES_Fingerprint.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
#!/usr/bin/env nextflow
nextflow.preview.dsl=2
// Utils modules
include extractBamFromDir from './NextflowModules/Utils/bam.nf'
include ExportParams as Workflow_ExportParams from './NextflowModules/Utils/workflow.nf'
// Fingerprint modules
include UnifiedGenotyper as GATK_UnifiedGenotyper from './NextflowModules/GATK/3.8-1-0-gf15c1c3ef/UnifiedGenotyper.nf' params(gatk_path: "$params.gatk_path", genome:"$params.genome", optional: "--intervals $params.dxtracks_path/$params.fingerprint_target --output_mode EMIT_ALL_SITES")
def bam_files = extractBamFromDir(params.bam_path)
def analysis_id = params.outdir.split('/')[-1]
workflow {
GATK_UnifiedGenotyper(bam_files)
// Create log files: Repository versions and Workflow params
VersionLog()
Workflow_ExportParams()
}
// Workflow completion notification
workflow.onComplete {
// HTML Template
def template = new File("$projectDir/assets/workflow_complete.html")
def binding = [
runName: analysis_id,
workflow: workflow
]
def engine = new groovy.text.GStringTemplateEngine()
def email_html = engine.createTemplate(template).make(binding).toString()
// Send email
if (workflow.success) {
def subject = "WES Fingerprint Workflow Successful: ${analysis_id}"
sendMail(to: params.email.trim(), subject: subject, body: email_html)
} else {
def subject = "WES Fingerprint Workflow Failed: ${analysis_id}"
sendMail(to: params.email.trim(), subject: subject, body: email_html)
}
}
process VersionLog {
// Custom process to log repository versions
tag {"VersionLog ${analysis_id}"}
label 'VersionLog'
shell = ['/bin/bash', '-eo', 'pipefail']
cache = false //Disable cache to force a new version log when restarting the workflow.
output:
path('repository_version.log')
script:
"""
echo 'DxNextflowWes' > repository_version.log
git --git-dir=${workflow.projectDir}/.git log --pretty=oneline --decorate -n 2 >> repository_version.log
echo 'Dx_tracks' >> repository_version.log
git --git-dir=${params.dxtracks_path}/.git log --pretty=oneline --decorate -n 2 >> repository_version.log
"""
}