Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ nf-core/sarek:

nextflow.preview.dsl = 2

// Print help message if required

if (params.help) {
def command = "nextflow run nf-core/sarek -profile docker --input sample.tsv"
log.info Schema.params_help("$baseDir/nextflow_schema.json", command)
exit 0
}

/*
================================================================================
INCLUDE SAREK FUNCTIONS
Expand Down Expand Up @@ -244,16 +252,6 @@ workflow_summary = Channel.value(workflow_summary)
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"
if (params.sentieon) log.warn "[nf-core/sarek] Sentieon will be used, only works if Sentieon is available where nf-core/sarek is run"

// Print help message if required

if (params.help) {
def command = "nextflow run nf-core/sarek --input sample.tsv -profile docker"
log.info Headers.nf_core(workflow, params.monochrome_logs)
log.info Schema.params_help("$baseDir/nextflow_schema.json", command)
exit 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it back to the top, and just removed the Headers part from it, I think it's useless in the help context

}


/*
================================================================================
INCLUDE LOCAL PIPELINE MODULES
Expand Down Expand Up @@ -336,15 +334,14 @@ workflow {
pon,
step)

bwa = params.bwa ? Channel.value(file(params.bwa)) : BUILD_INDICES.out.bwa_built
dict = params.dict ? Channel.value(file(params.dict)) : BUILD_INDICES.out.dictBuilt
fai = params.fasta_fai ? Channel.value(file(params.fasta_fai)) : BUILD_INDICES.out.fai_built
dbsnp_tbi = params.dbsnp ? params.dbsnp_index ? Channel.value(file(params.dbsnp_index)) : BUILD_INDICES.out.dbsnp_tbi : "null"
germline_resource_tbi = params.germline_resource ? params.germline_resource_index ? Channel.value(file(params.germline_resource_index)) : BUILD_INDICES.out.germline_resource_tbi : "null"
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"
pon_tbi = params.pon ? params.pon_index ? Channel.value(file(params.pon_index)) : BUILD_INDICES.out.pon_tbi : "null"
intervals = params.no_intervals ? "null" : params.intervals && !('annotate' in step) ? Channel.value(file(params.intervals)) : BUILD_INDICES.out.intervalBuilt
intervals.dump(tag: 'intervals')
bwa = params.bwa ?: BUILD_INDICES.out.bwa
dbsnp_tbi = params.dbsnp ? params.dbsnp_index ?: BUILD_INDICES.out.dbsnp_tbi : Channel.empty()
dict = params.dict ?: BUILD_INDICES.out.dict
fai = params.fasta_fai ? params.fasta_fai : BUILD_INDICES.out.fai
germline_resource_tbi = params.germline_resource ? params.germline_resource_index ?: BUILD_INDICES.out.germline_resource_tbi : Channel.empty()
intervals = params.no_intervals ? Channel.empty() : params.intervals && !('annotate' in step) ? params.intervals : BUILD_INDICES.out.intervals
known_indels_tbi = params.known_indels ? params.known_indels_index ?: BUILD_INDICES.out.known_indels_tbi.collect() : Channel.empty()
pon_tbi = params.pon ? params.pon_index ?: BUILD_INDICES.out.pon_tbi : Channel.empty()

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

//if(!('fastqc' in skipQC))
// if(!('fastqc' in skipQC))
FASTQC(input_sample)

if(params.trim_fastq) {
if (params.trim_fastq) {
TRIM_GALORE(input_sample)
result_trim_galore = TRIM_GALORE.out.report
BWAMEM2_MEM(TRIM_GALORE.out.trimmed_reads, bwa, fasta, fai)
}
else {
result_trim_galore = Channel.empty()
BWAMEM2_MEM(input_sample, bwa, fasta, fai)
}

Expand All @@ -397,7 +396,7 @@ workflow {
multiqc_config,
multiqc_custom_config.ifEmpty([]),
GET_SOFTWARE_VERSIONS.out.yml,
TRIM_GALORE.out.report.ifEmpty([]),
result_trim_galore.ifEmpty([]),
workflow_summary)
}

Expand Down
2 changes: 0 additions & 2 deletions modules/nf-core/samtools_faidx.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ process SAMTOOLS_FAIDX {
output:
path "${fasta}.fai"

//when: !(params.fasta_fai) && params.fasta && !('annotate' in step)

script:
"""
samtools faidx ${fasta}
Expand Down
73 changes: 44 additions & 29 deletions modules/subworkflows/build_indices.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,74 @@
// And then initialize channels based on params or indexes that were just built

include { BUILD_INTERVALS } from '../local/build_intervals.nf'
include { BWAMEM2_INDEX as BWAMEM2_INDEX } from '../nf-core/bwamem2_index.nf'
include { GATK_CREATE_SEQUENCE_DICTIONARY as GATK_CREATE_SEQUENCE_DICTIONARY } from '../local/gatk_dict.nf'
include { BWAMEM2_INDEX } from '../nf-core/bwamem2_index.nf'
include { GATK_CREATE_SEQUENCE_DICTIONARY } from '../local/gatk_dict.nf'
include {
HTSLIB_TABIX as HTSLIB_TABIX_DBSNP;
HTSLIB_TABIX as HTSLIB_TABIX_GERMLINE_RESOURCE;
HTSLIB_TABIX as HTSLIB_TABIX_KNOWN_INDELS;
HTSLIB_TABIX as HTSLIB_TABIX_PON;
} from '../nf-core/htslib_tabix'
include { SAMTOOLS_FAIDX as SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'
include { SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'

workflow BUILD_INDICES{
take:
ch_dbsnp
ch_fasta
ch_germline_resource
ch_known_indels
ch_pon
dbsnp
fasta
germline_resource
known_indels
pon
step

main:

if (!(params.bwa) && params.fasta && 'mapping' in step)
BWAMEM2_INDEX(ch_fasta)
if (!(params.bwa) && params.fasta && 'mapping' in step)
result_bwa = BWAMEM2_INDEX(fasta)
else
result_bwa = Channel.empty()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad it works like this, but unhappy with the optics

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll improve it at some point


if (!(params.dict) && params.fasta && !('annotate' in step) && !('controlfreec' in step))
GATK_CREATE_SEQUENCE_DICTIONARY(ch_fasta)
result_dict = GATK_CREATE_SEQUENCE_DICTIONARY(fasta)
else
result_dict = Channel.empty()

if (!(params.fasta_fai) && params.fasta && !('annotate' in step))
SAMTOOLS_FAIDX(ch_fasta)
result_fai = SAMTOOLS_FAIDX(fasta)
else
result_fai = Channel.empty()

if (!(params.dbsnp_index) && params.dbsnp && ('mapping' in step || 'preparerecalibration' in step || 'controlfreec' in tools || 'haplotypecaller' in tools || 'mutect2' in tools || 'tnscope' in tools))
HTSLIB_TABIX_DBSNP(ch_dbsnp)

result_dbsnp_tbi = HTSLIB_TABIX_DBSNP(dbsnp)
else
result_dbsnp_tbi = Channel.empty()

if (!(params.germline_resource_index) && params.germline_resource && 'mutect2' in tools)
HTSLIB_TABIX_GERMLINE_RESOURCE(ch_germline_resource)

result_germline_resource_tbi = HTSLIB_TABIX_GERMLINE_RESOURCE(germline_resource)
else
result_germline_resource_tbi = Channel.empty()

if (!(params.known_indels_index) && params.known_indels && ('mapping' in step || 'preparerecalibration' in step))
HTSLIB_TABIX_KNOWN_INDELS(ch_known_indels)
result_known_indels_tbi = HTSLIB_TABIX_KNOWN_INDELS(known_indels)
else
result_known_indels_tbi = Channel.empty()

if (!(params.pon_index) && params.pon && ('tnscope' in tools || 'mutect2' in tools))
HTSLIB_TABIX_PON(ch_pon)
result_pon_tbi = HTSLIB_TABIX_PON(pon)
else
result_pon_tbi = Channel.empty()

if (!(params.intervals) && !('annotate' in step) && !('controlfreec' in step)) {
BUILD_INTERVALS(SAMTOOLS_FAIDX.out)
}
if (!(params.intervals) && !('annotate' in step) && !('controlfreec' in step))
result_intervals = BUILD_INTERVALS(SAMTOOLS_FAIDX.out)
else
result_intervals = Channel.empty()

emit:
bwa_built = BWAMEM2_INDEX.out
dbsnp_tbi = HTSLIB_TABIX_DBSNP.out
dictBuilt = GATK_CREATE_SEQUENCE_DICTIONARY.out
fai_built = SAMTOOLS_FAIDX.out
germline_resource_tbi = HTSLIB_TABIX_GERMLINE_RESOURCE.out
intervalBuilt = BUILD_INTERVALS.out
known_indels_tbi = HTSLIB_TABIX_KNOWN_INDELS.out
pon_tbi = HTSLIB_TABIX_PON.out
bwa = result_bwa
dbsnp_tbi = result_dbsnp_tbi
dict = result_dict
fai = result_fai
germline_resource_tbi = result_germline_resource_tbi
intervals = result_intervals
known_indels_tbi = result_known_indels_tbi
pon_tbi = result_pon_tbi
}