-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnf-GATK_Exome_Preprocess.nf
665 lines (506 loc) · 21 KB
/
nf-GATK_Exome_Preprocess.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
#!/usr/bin/env nextflow
//############################################################################################################################
//
// Josh Campbell
// 7/20/2016
// Peforms alignment and preprocessing of paired-end exome sequencing data.
// For all samples derived from the same individual, an indel co-cleaning step will be performed on all bams jointly
//
// GATK tutorials this pipeline is based on:
// Mapping: http://gatkforums.broadinstitute.org/gatk/discussion/6483/how-to-map-and-clean-up-short-read-sequence-data-efficiently
// Marking Duplicates: http://gatkforums.broadinstitute.org/gatk/discussion/6747/how-to-mark-duplicates-with-markduplicates-or-markduplicateswithmatecigar
// Realignment around indels: http://gatkforums.broadinstitute.org/gatk/discussion/2800/howto-perform-local-realignment-around-indels
// Base Quality Score Recalibration: http://gatkforums.broadinstitute.org/gatk/discussion/2801/howto-recalibrate-base-quality-scores-run-bqsr
//
//############################################################################################################################
// Set up global variables for requried parameters:
inputFile = file(params.infile)
inputFileHeader = params.infile_header
// Set up global variables for parameters with preset defaults:
REF = file(params.ref)
GATK = file(params.gatk_jar)
PICARD = file(params.picard_jar)
GOLD1 = file(params.gold_indels1)
GOLD2 = file(params.gold_indels2)
TARGETS = file(params.targets)
BAITS = file(params.baits)
OUTDIR = file(params.output_dir)
DBSNP = file(params.dbsnp)
logParams(params, "nextflow_parameters.txt")
VERSION = "1.2"
// Header log info
log.info "========================================="
log.info "GATK Best Practices for Exome-Seq Preprocessing v${VERSION}"
log.info "Nextflow Version: $workflow.nextflow.version"
log.info "Command Line: $workflow.commandLine"
log.info "========================================="
//#############################################################################################################
//#############################################################################################################
//
// Main
//
//#############################################################################################################
//#############################################################################################################
// ------------------------------------------------------------------------------------------------------------
//
// Send FASTQ files to two processes from input file: FastQC and FastqToSam
//
// ------------------------------------------------------------------------------------------------------------
Channel.from(inputFile)
.splitCsv(sep: '\t', header: inputFileHeader)
.into { readPairsFastQC; readPairsFastqToSam }
// ------------------------------------------------------------------------------------------------------------
//
// Preprocess reads
// 1) Convert to BAM
// 2) Mark Adapters
//
// ------------------------------------------------------------------------------------------------------------
process runFastqToSam {
tag "${indivID}|${sampleID}|${libraryID}|${rgID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Libraries/${libraryID}/${rgID}/FastqToSam/"
input:
set indivID, sampleID, libraryID, rgID, platform_unit, platform, platform_model, run_date, center, fastqR1, fastqR2 from readPairsFastqToSam
output:
set indivID, sampleID, libraryID, rgID, file(outfile) into runFastqToSamOutput
script:
outfile = sampleID + "_" + libraryID + "_" + rgID + ".unaligned.bam"
"""
java -Xmx5G -XX:ParallelGCThreads=1 -jar ${PICARD} FastqToSam \
FASTQ=${fastqR1} \
FASTQ2=${fastqR2} \
OUTPUT=${outfile} \
READ_GROUP_NAME=${rgID} \
SAMPLE_NAME=${sampleID} \
LIBRARY_NAME=${libraryID} \
PLATFORM_UNIT=${platform_unit} \
PLATFORM=${platform} \
PLATFORM_MODEL=${platform_model} \
SEQUENCING_CENTER=${center} \
RUN_DATE=${run_date} \
TMP_DIR=tmp
"""
}
process runMarkIlluminaAdapters {
tag "${indivID}|${sampleID}|${libraryID}|${rgID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Libraries/${libraryID}/${rgID}/MarkIlluminaAdapters/"
input:
set indivID, sampleID, libraryID, rgID, ubam from runFastqToSamOutput
output:
set indivID, sampleID, libraryID, rgID, ubam, file(outfile_bam), file(outfile_metrics) into runMarkIlluminaAdaptersOutput
script:
outfile_bam = sampleID + "_" + libraryID + "_" + rgID + ".adapters_marked.bam"
outfile_metrics = sampleID + "_" + libraryID + "_" + rgID + "_adapters_metrics.txt"
"""
java -Xmx5G -XX:ParallelGCThreads=1 -jar ${PICARD} MarkIlluminaAdapters \
I=${ubam} \
O=${outfile_bam} \
M=${outfile_metrics} \
TMP_DIR=tmp
"""
}
// ------------------------------------------------------------------------------------------------------------
//
// Run BWA to align reads to genome
//
// ------------------------------------------------------------------------------------------------------------
process runBWA {
tag "${indivID}|${sampleID}|${libraryID}|${rgID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Libraries/${libraryID}/${rgID}/BWA/"
input:
set indivID, sampleID, libraryID, rgID, ubam, ubamxt, metrics from runMarkIlluminaAdaptersOutput
output:
set indivID, sampleID, file(outfile_bam) into runBWAOutput
script:
outfile_bam = sampleID + "_" + libraryID + "_" + rgID + ".aligned.bam"
"""
set -o pipefail
java -Dsamjdk.buffer_size=131072 -Dsamjdk.compression_level=1 -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -XX:ParallelGCThreads=1 -Xmx5G -jar ${PICARD} SamToFastq \
I=${ubamxt} \
FASTQ=/dev/stdout \
CLIPPING_ATTRIBUTE=XT CLIPPING_ACTION=2 INTERLEAVE=true NON_PF=true \
TMP_DIR=tmp | \
bwa mem -M -t 14 -p ${REF} /dev/stdin | \
java -XX:ParallelGCThreads=1 -Xmx5G -jar ${PICARD} MergeBamAlignment \
ALIGNED_BAM=/dev/stdin \
UNMAPPED_BAM=${ubamxt} \
OUTPUT=${outfile_bam} \
R=${REF} CREATE_INDEX=true ADD_MATE_CIGAR=true \
CLIP_ADAPTERS=false \
CLIP_OVERLAPPING_READS=true \
INCLUDE_SECONDARY_ALIGNMENTS=true \
MAX_INSERTIONS_OR_DELETIONS=-1 \
PRIMARY_ALIGNMENT_STRATEGY=MostDistant \
ATTRIBUTES_TO_RETAIN=XS \
TMP_DIR=tmp
rm -rf tmp
"""
}
// ------------------------------------------------------------------------------------------------------------
//
// Combined libraries from the same Individual/Sample to send to MarkDuplicates
//
// ------------------------------------------------------------------------------------------------------------
runBWAOutput_grouped_by_sample = runBWAOutput.groupTuple(by: [0,1])
// ------------------------------------------------------------------------------------------------------------
//
// Run Picard MarkDuplicates
// This is used to merge different libraries from the same sample or the same library run on different lanes
// Requires a lot of memory
// Need to set "ParallelGCThreads" otherwise it will "grab" extra available threads without asking (and potentially be terminated by SGE)
//
// ------------------------------------------------------------------------------------------------------------
process runMarkDuplicates {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/MarkDuplicates"
input:
set indivID, sampleID, aligned_bam_list from runBWAOutput_grouped_by_sample
output:
set indivID, sampleID, file(outfile_bam), file(outfile_bai) into runMarkDuplicatesOutput
set indivID, file(outfile_metrics) into runMarkDuplicatesOutput_QC
script:
outfile_bam = sampleID + ".dedup.bam"
outfile_bai = sampleID + ".dedup.bai"
outfile_metrics = sampleID + "_duplicate_metrics.txt"
"""
java -Xmx30g -XX:ParallelGCThreads=5 -Djava.io.tmpdir=tmp/ -jar ${PICARD} MarkDuplicates \
INPUT=${aligned_bam_list.join(" INPUT=")} \
OUTPUT=${outfile_bam} \
METRICS_FILE=${outfile_metrics} \
CREATE_INDEX=true \
TMP_DIR=tmp
"""
}
// ------------------------------------------------------------------------------------------------------------
//
// Combine samples from the same Individual (e.g. tumor/normal pair) to send to runRealignerTargetCreator
//
// ------------------------------------------------------------------------------------------------------------
runMarkDuplicatesOutput_grouped_by_sample = runMarkDuplicatesOutput.groupTuple(by: [0])
// ------------------------------------------------------------------------------------------------------------
//
// Perform realignment around indels
// 1) Identify regions for realignement
// 2) Perform realignment
//
// ------------------------------------------------------------------------------------------------------------
process runRealignerTargetCreator {
tag "${indivID}"
publishDir "${OUTDIR}/${indivID}/Processing/RealignerTargetCreator/"
input:
set indivID, sampleID, dedup_bam_list from runMarkDuplicatesOutput_grouped_by_sample
output:
set indivID, dedup_bam_list, file(target_file) into runRealignerTargetCreatorOutput
script:
target_file = indivID + "_target_intervals.list"
"""
java -Xmx25G -XX:ParallelGCThreads=2 -Djava.io.tmpdir=tmp/ -jar ${GATK} \
-T RealignerTargetCreator \
-R ${REF} \
-I ${dedup_bam_list.join(" -I ")} \
-known ${GOLD1} \
-known ${GOLD2} \
-o ${target_file}
"""
}
process runIndelRealigner {
tag "${indivID}"
publishDir "${OUTDIR}/${indivID}/Processing/IndelRealigner/"
input:
set indivID, dedup_bam_list, target_file from runRealignerTargetCreatorOutput
output:
set indivID, file('*.realign.bam') into runIndelRealignerOutput mode flatten
set indivID, file('*.realign.bai') into runIndelRealignerBAIOutput
script:
"""
java -Xmx25G -XX:ParallelGCThreads=2 -Djava.io.tmpdir=tmp/ -jar ${GATK} \
-T IndelRealigner \
-R ${REF} \
-I ${dedup_bam_list.join(" -I ")} \
-targetIntervals ${target_file} \
-known ${GOLD1} \
-known ${GOLD2} \
-maxReads 500000 \
--maxReadsInMemory 500000 \
-nWayOut ".realign.bam"
"""
}
// ------------------------------------------------------------------------------------------------------------
//
// Perform base quality score recalibration (BQSR) including
// 1) Generate a recalibration table
// 2) Generate a new table after applying recalibration
// 3) Compare differences between recalibration tables
// 4) Apply recalibration
//
// ------------------------------------------------------------------------------------------------------------
// First we need to recapture the SampleID from the filename
runIndelRealignerOutput_split = runIndelRealignerOutput.map { indivID, file -> tuple(indivID, file.baseName.replaceAll(".dedup.realign", ""), file) }
process runBaseRecalibrator {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/BaseRecalibrator/"
input:
set indivID, sampleID, realign_bam from runIndelRealignerOutput_split
output:
set indivID, sampleID, realign_bam, file(recal_table) into runBaseRecalibratorOutput
script:
recal_table = sampleID + "_recal_table.txt"
"""
java -XX:ParallelGCThreads=2 -Xmx30g -Djava.io.tmpdir=tmp/ -jar ${GATK} \
-T BaseRecalibrator \
-R ${REF} \
-I ${realign_bam} \
-knownSites ${GOLD1} \
-knownSites ${GOLD2} \
-knownSites ${DBSNP} \
-o ${recal_table}
"""
}
process runPrintReads {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/"
input:
set indivID, sampleID, realign_bam, recal_table from runBaseRecalibratorOutput
output:
set indivID, sampleID, file(outfile_bam), file(outfile_bai), file(outfile_bai2) into runPrintReadsOutput_for_DepthOfCoverage, runPrintReadsOutput_for_HC_Metrics, runPrintReadsOutput_for_Multiple_Metrics, runPrintReadsOutput_for_OxoG_Metrics
set indivID, sampleID, realign_bam, recal_table into runPrintReadsOutput_for_PostRecal
script:
outfile_bam = sampleID + ".clean.bam"
outfile_bai = sampleID + ".clean.bai"
outfile_bai2 = sampleID + ".clean.bam.bai"
"""
java -XX:ParallelGCThreads=2 -Xmx25g -Djava.io.tmpdir=tmp/ -jar ${GATK} \
-T PrintReads \
-R ${REF} \
-I ${realign_bam} \
-BQSR ${recal_table} \
-o ${outfile_bam}
samtools index ${outfile_bam}
"""
}
process runBaseRecalibratorPostRecal {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/BaseRecalibratorPostRecal/"
input:
set indivID, sampleID, realign_bam, recal_table from runPrintReadsOutput_for_PostRecal
output:
set indivID, sampleID, recal_table, file(post_recal_table) into runBaseRecalibratorPostRecalOutput_Analyze
script:
post_recal_table = sampleID + "_post_recal_table.txt"
"""
java -XX:ParallelGCThreads=2 -Xmx5g -Djava.io.tmpdir=tmp/ -jar ${GATK} \
-T BaseRecalibrator \
-R ${REF} \
-I ${realign_bam} \
-knownSites ${GOLD1} \
-knownSites ${GOLD2} \
-knownSites ${DBSNP} \
-BQSR ${recal_table} \
-o ${post_recal_table}
"""
}
process runAnalyzeCovariates {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/AnalyzeCovariates/"
input:
set indivID, sampleID, recal_table, post_recal_table from runBaseRecalibratorPostRecalOutput_Analyze
output:
set indivID, sampleID, recal_plots into runAnalyzeCovariatesOutput
script:
recal_plots = sampleID + "_recal_plots.pdf"
"""
java -XX:ParallelGCThreads=2 -Xmx5g -Djava.io.tmpdir=tmp/ -jar ${GATK} \
-T AnalyzeCovariates \
-R ${REF} \
-before ${recal_table} \
-after ${post_recal_table} \
-plots ${recal_plots}
"""
}
// ------------------------------------------------------------------------------------------------------------
//
// Perform a several tasks to assess QC:
// 1) Depth of coverage over targets
// 2) Generate alignment stats, insert size stats, quality score distribution
// 3) Generate hybrid capture stats
// 4) Run FASTQC to assess read quality
//
// ------------------------------------------------------------------------------------------------------------
process runDepthOfCoverage {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/DepthOfCoverage"
input:
set indivID, sampleID, bam, bai, bai2 from runPrintReadsOutput_for_DepthOfCoverage
output:
file("${prefix}*") into DepthOfCoverageOutput
script:
prefix = sampleID + "."
"""
java -XX:ParallelGCThreads=2 -Djava.io.tmpdir=tmp/ -Xmx5g -jar ${GATK} \
-R ${REF} \
-T DepthOfCoverage \
-I ${bam} \
--omitDepthOutputAtEachBase \
-L ${TARGETS} \
-ct 10 -ct 20 -ct 50 -ct 100 \
-o ${sampleID}
"""
}
process runCollectMultipleMetrics {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Picard_Metrics"
input:
set indivID, sampleID, bam, bai, bai2 from runPrintReadsOutput_for_Multiple_Metrics
output:
set indivID, file("${prefix}*") into CollectMultipleMetricsOutput mode flatten
script:
prefix = sampleID + "."
"""
java -XX:ParallelGCThreads=2 -Xmx5g -Djava.io.tmpdir=tmp/ -jar $PICARD CollectMultipleMetrics \
PROGRAM=MeanQualityByCycle \
PROGRAM=QualityScoreDistribution \
PROGRAM=CollectAlignmentSummaryMetrics \
PROGRAM=CollectInsertSizeMetrics\
PROGRAM=CollectGcBiasMetrics \
PROGRAM=CollectSequencingArtifactMetrics \
PROGRAM=CollectBaseDistributionByCycle \
PROGRAM=CollectQualityYieldMetrics \
INPUT=${bam} \
REFERENCE_SEQUENCE=${REF} \
DB_SNP=${DBSNP} \
INTERVALS=${BAITS} \
ASSUME_SORTED=true \
OUTPUT=${prefix} \
TMP_DIR=tmp
"""
}
process runHybridCaptureMetrics {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Picard_Metrics"
input:
set indivID, sampleID, bam, bai, bai2 from runPrintReadsOutput_for_HC_Metrics
output:
set indivID, file(outfile) into HybridCaptureMetricsOutput mode flatten
script:
outfile = sampleID + ".hybrid_selection_metrics.txt"
target_coverage = sampleID + ".target_coverage.txt"
"""
java -XX:ParallelGCThreads=2 -Xmx5g -Djava.io.tmpdir=tmp/ -jar $PICARD CollectHsMetrics \
INPUT=${bam} \
OUTPUT=${outfile} \
TARGET_INTERVALS=${TARGETS} \
BAIT_INTERVALS=${BAITS} \
REFERENCE_SEQUENCE=${REF} \
PER_TARGET_COVERAGE=${target_coverage} \
TMP_DIR=tmp
"""
}
process runOxoGMetrics {
tag "${indivID}|${sampleID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Picard_Metrics"
input:
set indivID, sampleID, bam, bai, bai2 from runPrintReadsOutput_for_OxoG_Metrics
output:
set indivID, file(outfile) into runOxoGMetricsOutput mode flatten
script:
outfile = sampleID + ".OxoG_metrics.txt"
"""
java -XX:ParallelGCThreads=2 -Xmx5g -Djava.io.tmpdir=tmp/ -jar $PICARD CollectOxoGMetrics \
INPUT=${bam} \
OUTPUT=${outfile} \
DB_SNP=${DBSNP} \
INTERVALS=${BAITS} \
REFERENCE_SEQUENCE=${REF} \
TMP_DIR=tmp
"""
}
process runFastQC {
tag "${indivID}|${sampleID}|${libraryID}|${rgID}"
publishDir "${OUTDIR}/${indivID}/${sampleID}/Processing/Libraries/${libraryID}/${rgID}/FastQC/"
input:
set indivID, sampleID, libraryID, rgID, platform_unit, platform, platform_model, run_date, center, fastqR1, fastqR2 from readPairsFastQC
output:
set indivID, file("*.zip") into FastQCOutput mode flatten
file("*.html") into FastQCOutput2
script:
"""
fastqc -t 1 -o . ${fastqR1} ${fastqR2}
"""
}
// ------------------------------------------------------------------------------------------------------------
//
// Plot results with multiqc
//
// ------------------------------------------------------------------------------------------------------------
FastQCOutput_grouped_by_indiv = FastQCOutput.groupTuple(by: [0])
process runMultiQCFastq {
tag "${indivID}"
publishDir "${OUTDIR}/${indivID}/QC/Fastq"
input:
set indivID, zip_files from FastQCOutput_grouped_by_indiv
output:
set file("multiqc_fastq_file_list.txt"), file("fastq_multiqc*") into runMultiQCFastqOutput
script:
"""
echo -e "${zip_files.flatten().join('\n')}" > multiqc_fastq_file_list.txt
multiqc -n fastq_multiqc --file-list multiqc_fastq_file_list.txt
"""
}
runMarkDuplicatesOutput_QC_grouped_by_indiv = runMarkDuplicatesOutput_QC.groupTuple(by: [0])
process runMultiQCLibrary {
tag "${indivID}"
publishDir "${OUTDIR}/${indivID}/QC/Library"
input:
set indivID, files from runMarkDuplicatesOutput_QC_grouped_by_indiv
output:
set file("multiqc_library_file_list.txt"), file("library_multiqc*") into runMultiQCLibraryOutput
script:
"""
echo -e "${files.flatten().join('\n')}" > multiqc_library_file_list.txt
multiqc -n library_multiqc --file-list multiqc_library_file_list.txt
"""
}
CollectMultipleMetricsOutput_grouped_by_indiv = CollectMultipleMetricsOutput.groupTuple(by: [0])
HybridCaptureMetricsOutput_grouped_by_indiv = HybridCaptureMetricsOutput.groupTuple(by: [0])
runOxoGMetricsOutput_grouped_by_indiv = runOxoGMetricsOutput.groupTuple(by: [0])
process runMultiQCSample {
tag "${indivID}"
publishDir "${OUTDIR}/${indivID}/QC/Sample"
input:
set indivID, metrics_files from CollectMultipleMetricsOutput_grouped_by_indiv
set indivID, hybrid_files from HybridCaptureMetricsOutput_grouped_by_indiv
set indivID, oxog_files from runOxoGMetricsOutput_grouped_by_indiv
output:
set file("sample_multiqc*"), file("multiqc_sample_file_list.txt") into runMultiQCSampleOutput
script:
"""
echo -e "${metrics_files.flatten().join('\n')}" > multiqc_sample_file_list.txt
echo -e "${hybrid_files.flatten().join('\n')}" >> multiqc_sample_file_list.txt
echo -e "${oxog_files.flatten().join('\n')}" >> multiqc_sample_file_list.txt
multiqc -n sample_multiqc --file-list multiqc_sample_file_list.txt
"""
}
workflow.onComplete {
log.info "========================================="
log.info "Duration: $workflow.duration"
log.info "========================================="
}
//#############################################################################################################
//#############################################################################################################
//
// FUNCTIONS
//
//#############################################################################################################
//#############################################################################################################
// ------------------------------------------------------------------------------------------------------------
//
// Read input file and save it into list of lists
//
// ------------------------------------------------------------------------------------------------------------
def logParams(p, n) {
File file = new File(n)
file.write "Parameter:\tValue\n"
for(s in p) {
file << "${s.key}:\t${s.value}\n"
}
}