Skip to content

Commit f18f71a

Browse files
authored
Merge pull request #244 from MaxUlysse/nextflow.20.06.0-edge
Works with Nextflow.20.06.0 edge and has optional processes
2 parents 216b529 + d492db4 commit f18f71a

File tree

3 files changed

+65
-53
lines changed

3 files changed

+65
-53
lines changed

main.nf

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ nf-core/sarek:
2121

2222
nextflow.preview.dsl = 2
2323

24+
// Print help message if required
25+
26+
if (params.help) {
27+
def command = "nextflow run nf-core/sarek -profile docker --input sample.tsv"
28+
log.info Schema.params_help("$baseDir/nextflow_schema.json", command)
29+
exit 0
30+
}
31+
2432
/*
2533
================================================================================
2634
INCLUDE SAREK FUNCTIONS
@@ -244,16 +252,6 @@ workflow_summary = Channel.value(workflow_summary)
244252
if ('mutect2' in tools && !(params.pon)) log.warn "[nf-core/sarek] Mutect2 was requested, but as no panel of normals were given, results will not be optimal"
245253
if (params.sentieon) log.warn "[nf-core/sarek] Sentieon will be used, only works if Sentieon is available where nf-core/sarek is run"
246254

247-
// Print help message if required
248-
249-
if (params.help) {
250-
def command = "nextflow run nf-core/sarek --input sample.tsv -profile docker"
251-
log.info Headers.nf_core(workflow, params.monochrome_logs)
252-
log.info Schema.params_help("$baseDir/nextflow_schema.json", command)
253-
exit 0
254-
}
255-
256-
257255
/*
258256
================================================================================
259257
INCLUDE LOCAL PIPELINE MODULES
@@ -336,15 +334,14 @@ workflow {
336334
pon,
337335
step)
338336

339-
bwa = params.bwa ? Channel.value(file(params.bwa)) : BUILD_INDICES.out.bwa_built
340-
dict = params.dict ? Channel.value(file(params.dict)) : BUILD_INDICES.out.dictBuilt
341-
fai = params.fasta_fai ? Channel.value(file(params.fasta_fai)) : BUILD_INDICES.out.fai_built
342-
dbsnp_tbi = params.dbsnp ? params.dbsnp_index ? Channel.value(file(params.dbsnp_index)) : BUILD_INDICES.out.dbsnp_tbi : "null"
343-
germline_resource_tbi = params.germline_resource ? params.germline_resource_index ? Channel.value(file(params.germline_resource_index)) : BUILD_INDICES.out.germline_resource_tbi : "null"
344-
known_indels_tbi = params.known_indels ? params.known_indels_index ? Channel.value(file(params.known_indels_index)) : BUILD_INDICES.out.known_indels_tbi.collect() : "null"
345-
pon_tbi = params.pon ? params.pon_index ? Channel.value(file(params.pon_index)) : BUILD_INDICES.out.pon_tbi : "null"
346-
intervals = params.no_intervals ? "null" : params.intervals && !('annotate' in step) ? Channel.value(file(params.intervals)) : BUILD_INDICES.out.intervalBuilt
347-
intervals.dump(tag: 'intervals')
337+
bwa = params.bwa ?: BUILD_INDICES.out.bwa
338+
dbsnp_tbi = params.dbsnp ? params.dbsnp_index ?: BUILD_INDICES.out.dbsnp_tbi : Channel.empty()
339+
dict = params.dict ?: BUILD_INDICES.out.dict
340+
fai = params.fasta_fai ? params.fasta_fai : BUILD_INDICES.out.fai
341+
germline_resource_tbi = params.germline_resource ? params.germline_resource_index ?: BUILD_INDICES.out.germline_resource_tbi : Channel.empty()
342+
intervals = params.no_intervals ? Channel.empty() : params.intervals && !('annotate' in step) ? params.intervals : BUILD_INDICES.out.intervals
343+
known_indels_tbi = params.known_indels ? params.known_indels_index ?: BUILD_INDICES.out.known_indels_tbi.collect() : Channel.empty()
344+
pon_tbi = params.pon ? params.pon_index ?: BUILD_INDICES.out.pon_tbi : Channel.empty()
348345

349346
// PREPROCESSING
350347
if((!params.no_intervals) && step != 'annotate')
@@ -375,14 +372,16 @@ workflow {
375372
ch_bed_intervals = Channel.from(file("${params.outdir}/no_intervals.bed"))
376373
}
377374

378-
//if(!('fastqc' in skipQC))
375+
// if(!('fastqc' in skipQC))
379376
FASTQC(input_sample)
380377

381-
if(params.trim_fastq) {
378+
if (params.trim_fastq) {
382379
TRIM_GALORE(input_sample)
380+
result_trim_galore = TRIM_GALORE.out.report
383381
BWAMEM2_MEM(TRIM_GALORE.out.trimmed_reads, bwa, fasta, fai)
384382
}
385383
else {
384+
result_trim_galore = Channel.empty()
386385
BWAMEM2_MEM(input_sample, bwa, fasta, fai)
387386
}
388387

@@ -397,7 +396,7 @@ workflow {
397396
multiqc_config,
398397
multiqc_custom_config.ifEmpty([]),
399398
GET_SOFTWARE_VERSIONS.out.yml,
400-
TRIM_GALORE.out.report.ifEmpty([]),
399+
result_trim_galore.ifEmpty([]),
401400
workflow_summary)
402401
}
403402

modules/nf-core/samtools_faidx.nf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ process SAMTOOLS_FAIDX {
1010
output:
1111
path "${fasta}.fai"
1212

13-
//when: !(params.fasta_fai) && params.fasta && !('annotate' in step)
14-
1513
script:
1614
"""
1715
samtools faidx ${fasta}

modules/subworkflows/build_indices.nf

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,74 @@
77
// And then initialize channels based on params or indexes that were just built
88

99
include { BUILD_INTERVALS } from '../local/build_intervals.nf'
10-
include { BWAMEM2_INDEX as BWAMEM2_INDEX } from '../nf-core/bwamem2_index.nf'
11-
include { GATK_CREATE_SEQUENCE_DICTIONARY as GATK_CREATE_SEQUENCE_DICTIONARY } from '../local/gatk_dict.nf'
10+
include { BWAMEM2_INDEX } from '../nf-core/bwamem2_index.nf'
11+
include { GATK_CREATE_SEQUENCE_DICTIONARY } from '../local/gatk_dict.nf'
1212
include {
1313
HTSLIB_TABIX as HTSLIB_TABIX_DBSNP;
1414
HTSLIB_TABIX as HTSLIB_TABIX_GERMLINE_RESOURCE;
1515
HTSLIB_TABIX as HTSLIB_TABIX_KNOWN_INDELS;
1616
HTSLIB_TABIX as HTSLIB_TABIX_PON;
1717
} from '../nf-core/htslib_tabix'
18-
include { SAMTOOLS_FAIDX as SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'
18+
include { SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'
1919

2020
workflow BUILD_INDICES{
2121
take:
22-
ch_dbsnp
23-
ch_fasta
24-
ch_germline_resource
25-
ch_known_indels
26-
ch_pon
22+
dbsnp
23+
fasta
24+
germline_resource
25+
known_indels
26+
pon
2727
step
2828

2929
main:
3030

31-
if (!(params.bwa) && params.fasta && 'mapping' in step)
32-
BWAMEM2_INDEX(ch_fasta)
31+
if (!(params.bwa) && params.fasta && 'mapping' in step)
32+
result_bwa = BWAMEM2_INDEX(fasta)
33+
else
34+
result_bwa = Channel.empty()
3335

3436
if (!(params.dict) && params.fasta && !('annotate' in step) && !('controlfreec' in step))
35-
GATK_CREATE_SEQUENCE_DICTIONARY(ch_fasta)
37+
result_dict = GATK_CREATE_SEQUENCE_DICTIONARY(fasta)
38+
else
39+
result_dict = Channel.empty()
3640

3741
if (!(params.fasta_fai) && params.fasta && !('annotate' in step))
38-
SAMTOOLS_FAIDX(ch_fasta)
42+
result_fai = SAMTOOLS_FAIDX(fasta)
43+
else
44+
result_fai = Channel.empty()
3945

4046
if (!(params.dbsnp_index) && params.dbsnp && ('mapping' in step || 'preparerecalibration' in step || 'controlfreec' in tools || 'haplotypecaller' in tools || 'mutect2' in tools || 'tnscope' in tools))
41-
HTSLIB_TABIX_DBSNP(ch_dbsnp)
42-
47+
result_dbsnp_tbi = HTSLIB_TABIX_DBSNP(dbsnp)
48+
else
49+
result_dbsnp_tbi = Channel.empty()
50+
4351
if (!(params.germline_resource_index) && params.germline_resource && 'mutect2' in tools)
44-
HTSLIB_TABIX_GERMLINE_RESOURCE(ch_germline_resource)
45-
52+
result_germline_resource_tbi = HTSLIB_TABIX_GERMLINE_RESOURCE(germline_resource)
53+
else
54+
result_germline_resource_tbi = Channel.empty()
55+
4656
if (!(params.known_indels_index) && params.known_indels && ('mapping' in step || 'preparerecalibration' in step))
47-
HTSLIB_TABIX_KNOWN_INDELS(ch_known_indels)
57+
result_known_indels_tbi = HTSLIB_TABIX_KNOWN_INDELS(known_indels)
58+
else
59+
result_known_indels_tbi = Channel.empty()
4860

4961
if (!(params.pon_index) && params.pon && ('tnscope' in tools || 'mutect2' in tools))
50-
HTSLIB_TABIX_PON(ch_pon)
62+
result_pon_tbi = HTSLIB_TABIX_PON(pon)
63+
else
64+
result_pon_tbi = Channel.empty()
5165

52-
if (!(params.intervals) && !('annotate' in step) && !('controlfreec' in step)) {
53-
BUILD_INTERVALS(SAMTOOLS_FAIDX.out)
54-
}
66+
if (!(params.intervals) && !('annotate' in step) && !('controlfreec' in step))
67+
result_intervals = BUILD_INTERVALS(SAMTOOLS_FAIDX.out)
68+
else
69+
result_intervals = Channel.empty()
5570

5671
emit:
57-
bwa_built = BWAMEM2_INDEX.out
58-
dbsnp_tbi = HTSLIB_TABIX_DBSNP.out
59-
dictBuilt = GATK_CREATE_SEQUENCE_DICTIONARY.out
60-
fai_built = SAMTOOLS_FAIDX.out
61-
germline_resource_tbi = HTSLIB_TABIX_GERMLINE_RESOURCE.out
62-
intervalBuilt = BUILD_INTERVALS.out
63-
known_indels_tbi = HTSLIB_TABIX_KNOWN_INDELS.out
64-
pon_tbi = HTSLIB_TABIX_PON.out
72+
bwa = result_bwa
73+
dbsnp_tbi = result_dbsnp_tbi
74+
dict = result_dict
75+
fai = result_fai
76+
germline_resource_tbi = result_germline_resource_tbi
77+
intervals = result_intervals
78+
known_indels_tbi = result_known_indels_tbi
79+
pon_tbi = result_pon_tbi
6580
}

0 commit comments

Comments
 (0)