-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.nf
More file actions
185 lines (163 loc) · 5.88 KB
/
main.nf
File metadata and controls
185 lines (163 loc) · 5.88 KB
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
#!/usr/bin/env nextflow
// Developer notes
//
// This template workflow provides a basic structure to copy in order
// to create a new workflow. Current recommended practices are:
// i) create a simple command-line interface.
// ii) include an abstract workflow scope named "pipeline" to be used
// in a module fashion
// iii) a second concrete, but anonymous, workflow scope to be used
// as an entry point when using this workflow in isolation.
import groovy.json.JsonBuilder
nextflow.enable.dsl = 2
OPTIONAL_FILE = file("$projectDir/data/OPTIONAL_FILE")
process getVersions {
label "wfqc"
cpus 1
output:
path "versions.txt"
script:
"""
toulligqc --version | sed 's/^/toulligQC,/' >> versions.txt
"""
}
process getParams {
label "wfqc"
cpus 1
output:
path "params.json"
script:
String paramsJSON = new JsonBuilder(params).toPrettyString()
"""
# Output nextflow params object to JSON
echo '$paramsJSON' > params.json
"""
}
process makeReport {
label "wfqc"
input:
path plots_dir
path "QC-repport/report.data"
path "versions/*"
path "params.json"
output:
path "wf-toulligqc-*.html"
script:
String report_name = "wf-toulligqc-report.html"
"""
workflow-glue report $report_name \
--versions versions \
--params params.json \
--metadata QC-repport/report.data \
--qc ${plots_dir}
"""
}
process toulligqc {
//debug true
label "wfqc"
input:
path seq_summary
path summary_pass
path summary_fail
path seq_telemetry
path fast5
path bam
path fastq
val report_name
val barcodes
val barcoding
output:
path "$report_name/report.data", emit: report_data
path "$report_name/images/*.html", emit: plots_html
path "$report_name/images/plotly.min.js", emit: plotly_js
path "$report_name/images", emit: plots_dir
script:
def seq_summary_arg = seq_summary.name != 'no_seq_summary' ? "--sequencing-summary-source $seq_summary" : ""
def summary_pass_arg = summary_pass.name != 'no_barcoding_pass' ? "--sequencing-summary-source $summary_pass" : ""
def summary_fail_arg = summary_fail.name != 'no_barcoding_fail' ? "--sequencing-summary-source $summary_fail" : ""
def telemetry_arg = seq_telemetry.name != 'no_telemetry' ? "--telemetry-source $seq_telemetry" : ""
def fast5_arg = fast5.name != 'no_fast5' ? "--fast5-source $fast5" : ""
def bam_arg = bam.name != 'no_bam' ? "--bam $bam" : ""
def fastq_arg = fastq.name != 'no_fastq' ? "--fastq $fastq" : ""
def barcodes_list = barcodes != 'no_barcodes' ? "--barcodes $barcodes" : ""
def barcoding_arg = barcoding != 'no_barcoding' ? "--barcoding" : ""
"""
toulligqc $seq_summary_arg \
$summary_pass_arg $summary_fail_arg \
$telemetry_arg \
$fast5_arg $fastq_arg $bam_arg\
$barcoding_arg $barcodes_list \
-n $report_name \
--force
"""
}
process output {
label "wfqc"
publishDir (
params.out_dir,
mode: "copy",
saveAs: { dirname ? "$dirname/$fname" : fname }
)
input:
tuple path(fname), val(dirname)
output:
path fname
"""
"""
}
workflow pipeline {
take:
seq_summary
summary_pass
summary_fail
seq_telemetry
fast5
bam
fastq
report_name
barcodes
barcoding
main:
software_versions = getVersions()
workflow_params = getParams()
toulligqc(seq_summary, summary_pass, summary_fail, seq_telemetry, fast5, fastq, bam, report_name, barcodes, barcoding)
plotly_js = toulligqc.out.plotly_js
plots_dir = toulligqc.out.plots_dir
report = makeReport(
plots_dir, toulligqc.out.report_data, software_versions.collect(), workflow_params
)
emit:
plotly_js
report
workflow_params
telemetry = workflow_params
}
// entrypoint workflow
WorkflowMain.initialise(workflow, params, log)
workflow {
if (params.disable_ping == false) {
Pinguscript.ping_post(workflow, "start", "none", params.out_dir, params)
}
seq_summary = params.sequencing_summary_source != null ? file(params.sequencing_summary_source, type: "file") : file("no_sequencing_summary", type: "file")
summary_pass = params.barcoding_summary_pass != null ? file(params.barcoding_summary_pass, type: "file") : file("no_barcoding_pass", type: "file")
summary_fail = params.barcoding_summary_fail != null ? file(params.barcoding_summary_fail, type: "file") : file("no_barcoding_fail", type: "file")
seq_telemetry = params.telemetry_source != null ? file(params.telemetry_source, type: "file") : file("no_telemetry", type: "file")
fast5 = params.fast5_source != null ? file(params.fast5_source, type: "file") : file("no_fast5", type: "file")
fastq = params.fastq_source != null ? file(params.fastq_source, type: "file") : file("no_fastq", type: "file")
bam = params.bam_source != null ? file(params.bam_source, type: "file") : file("no_bam", type: "file")
barcodes = params.barcodes != null ? params.barcodes : "no_barcodes"
barcoding = params.barcoding != false ? params.barcoding : "no_barcoding"
report_name = params.report_name
pipeline(seq_summary, summary_pass, summary_fail, seq_telemetry, fast5, fastq, bam, report_name, barcodes, barcoding)
pipeline.out.report.concat(pipeline.out.workflow_params).concat(pipeline.out.plotly_js)
| map { [it, null] }
| output
}
if (params.disable_ping == false) {
workflow.onComplete {
Pinguscript.ping_post(workflow, "end", "none", params.out_dir, params)
}
workflow.onError {
Pinguscript.ping_post(workflow, "error", "$workflow.errorMessage", params.out_dir, params)
}
}