forked from Sydney-Informatics-Hub/Germline-StructuralV-nf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
192 lines (132 loc) · 5.72 KB
/
main.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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// Import subworkflows to be run in the workflow
include { checkInputs } from './modules/check_cohort'
include { smoove } from './modules/smoove'
include { rehead_smoove } from './modules/smoove'
include { manta } from './modules/manta'
include { rehead_manta } from './modules/manta'
include { tiddit_sv } from './modules/tiddit_sv'
include { rehead_tiddit } from './modules/tiddit_sv'
include { tiddit_cov } from './modules/tiddit_cov'
include { survivor_merge } from './modules/survivor_merge'
include { survivor_summary } from './modules/survivor_summary'
include { annotsv } from './modules/annotsv'
// Print the header to screen when running the pipeline
log.info """\
===================================================================
G E R M L I N E S T R U C T U R A L V - N F
===================================================================
Created by the Sydney Informatics Hub, University of Sydney
Documentation @ https://github.com/Sydney-Informatics-Hub/Germline-StructuralV-nf
Cite @ TODO:INSERT DOI
Log issues @ https://github.com/Sydney-Informatics-Hub/Germline-StructuralV-nf/issues
===================================================================
Workflow run parameters
===================================================================
version : ${params.version}
input : ${params.input}
reference : ${params.ref}
manta intervals : ${params.intervals}
max merge dist : ${params.survivorMaxDist}
caller consensus : ${params.survivorConsensus}
type agreement : ${params.survivorType}
strand agreement : ${params.survivorStrand}
minMerge size : ${params.survivorSize}
annotsvDir : ${params.annotsvDir}
annotsvMode : ${params.annotsvMode}
outDir : ${params.outDir}
workDir : ${workflow.workDir}
===================================================================
Extra flags
===================================================================
manta flags : ${params.extraMantaFlags}
smoove flags : ${params.extraSmooveFlags}
tiddit cov flags : ${params.extraTidditCovFlags}
tiddit SV flags : ${params.extraTidditSvFlags}
annotSV flags : ${params.extraAnnotsvFlags}
===================================================================
"""
// Help function
// TODO: once finalised, add all optional and required flags in
def helpMessage() {
log.info"""
Usage: nextflow run main.nf --input samplesheet.tsv --ref reference.fasta
Required Arguments:
--input Full path and name of sample input file (tsv format).
--ref Full path and name of reference genome (fasta format).
Optional Arguments:
--outDir Full path and name of results directory.
--intervals Full path and name of the intervals file for Manta
(bed format).
--survivorMaxDist Maximum distance between SVs to merge (default: 1000bp)
--survivorConsensus Number of supportive callers require to report event
(default: 1).
--survivorType Requirement for callers to agree on event type before
merging calls (default: yes[1])
--survivorStrand Requirement for callers to identify event on same
strand before merging calls (default: yes[1])
--survivorSize Minimum size (bp) event to report (default 40bp)
--annotsvDir Full path to the directory housing the prepared
Annotations_human directory for AnnotSV.
--annotsvMode Specify full, split, or both for AnnotSV output
mode (default: both).
--extraMantaFlags Additionally specify any valid Manta flags.
--extraSmooveFlags Additionally specify any valid Smoove flags.
--extraTidditSvFlags Additionally specify any valid Tiddit SV flags.
--extraTidditCovFlags Additionally specify any valid Tiddit Cov flags.
--extraAnnotsvFlags Additionally specify any valid AnnotSV flags.
""".stripIndent()
}
workflow {
if ( params.help == true || params.ref == false || params.input == false ){
// Invoke the help function above and exit
helpMessage()
exit 1
} else {
// Check inputs file exists
checkInputs(Channel.fromPath(params.input, checkIfExists: true))
// Split cohort file to collect info for each sample
input = checkInputs.out
.splitCsv(header: true, sep:"\t")
.map { row -> tuple(row.sampleID, file(row.bam), file(row.bai))}
// Call SVs with Manta
manta(input, params.ref, params.ref+'.fai')
// Rehead manta vcf for merging
rehead_manta(manta.out.manta_diploid_convert, manta.out.manta_diploid_convert_tbi)
// Call SVs with Smoove
smoove(input, params.ref, params.ref+'.fai')
// Rehead smoove vcf for merging
rehead_smoove(smoove.out.smoove_geno)
// Run TIDDIT sv
tiddit_sv(input, params.ref, params.ref+'.fai')
// Rehead TIDDIT vcf for merging
rehead_tiddit(tiddit_sv.out.tiddit_vcf)
// Run TIDDIT cov
tiddit_cov(input, params.ref, params.ref+'.fai')
// Collect VCFs for merging
mergeFile = rehead_tiddit.out.tiddit_VCF
.concat(rehead_smoove.out.smoove_VCF, rehead_manta.out.manta_VCF)
.groupTuple()
// Run SURVIVOR merge
survivor_merge(mergeFile)
// Run SURVIVOR summary
survivor_summary(survivor_merge.out.mergedVCF)
// Run AnnotSV (optional)
if (params.annotsvDir) {
annotsv(survivor_merge.out.mergedVCF, params.annotsvDir, params.annotsvMode)}
}}
workflow.onComplete {
summary = """
===================================================================
Workflow execution summary
===================================================================
Duration : ${workflow.duration}
Success : ${workflow.success}
workDir : ${workflow.workDir}
Exit status : ${workflow.exitStatus}
outDir : ${params.outDir}
===================================================================
"""
println summary
}