Skip to content

Commit

Permalink
feat: Add option to skip kraken2 classification
Browse files Browse the repository at this point in the history
- Also removes unused boilerplate in the assembly subwf
  • Loading branch information
jvfe committed Feb 7, 2023
1 parent 49809da commit 192ab29
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
3 changes: 3 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ params {
reference_genome = null
outgroup_genome = null

// Kraken2
skip_kraken = false

// MultiQC options
multiqc_config = null
multiqc_title = null
Expand Down
18 changes: 17 additions & 1 deletion nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@
}
}
},
"kraken2": {
"title": "Kraken2",
"type": "object",
"description": "Options for the Kraken2 taxonomic classification",
"default": "",
"properties": {
"skip_kraken": {
"type": "boolean",
"default": false,
"description": "Don't run Kraken2 taxonomic classification"
}
},
"fa_icon": "fas fa-align-left"
},
"annotation": {
"title": "Annotation",
"type": "object",
Expand All @@ -91,7 +105,6 @@
"properties": {
"use_full_alignment": {
"type": "boolean",
"default": false,
"description": "Use full alignment"
},
"use_fasttree": {
Expand Down Expand Up @@ -296,6 +309,9 @@
{
"$ref": "#/definitions/reference_genome_options"
},
{
"$ref": "#/definitions/kraken2"
},
{
"$ref": "#/definitions/annotation"
},
Expand Down
50 changes: 16 additions & 34 deletions subworkflows/local/assembly.nf
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
def summary_params = NfcoreSchema.paramsSummaryMap(workflow, params)
/*
========================================================================================
CONFIG FILES
========================================================================================
*/

ch_multiqc_config = file("$projectDir/assets/multiqc_config.yaml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config) : Channel.empty()

def modules = params.modules.clone()

def multiqc_options = modules['multiqc']
multiqc_options.args += params.multiqc_title ? Utils.joinModuleArgs(["--title \"$params.multiqc_title\""]) : ''

//
// MODULE: Installed directly from nf-core/modules
//

include { FASTQC } from '../../modules/nf-core/modules/fastqc/main' addParams( options: modules['fastqc'] )
include { MULTIQC } from '../../modules/nf-core/modules/multiqc/main' addParams( options: multiqc_options )
include { FASTQC as TRIM_FASTQC } from '../../modules/nf-core/modules/fastqc/main' addParams( options: modules['fastqc'] )
include { FASTQC } from '../../modules/nf-core/modules/fastqc/main' addParams( options: [:] )
include { FASTQC as TRIM_FASTQC } from '../../modules/nf-core/modules/fastqc/main' addParams( options: [:] )
include { FASTP } from '../../modules/nf-core/modules/fastp/main' addParams( options: [:] )
include { UNICYCLER } from '../../modules/nf-core/modules/unicycler/main' addParams( options: [:] )
include { KRAKEN2_KRAKEN2 as KRAKEN2_RUN } from '../../modules/nf-core/modules/kraken2/kraken2/main' addParams( options: [:] )
Expand All @@ -33,9 +17,6 @@ include { CHECKM_LINEAGEWF } from '../../modules/nf-core/modules/checkm/lineagew
include { GET_SOFTWARE_VERSIONS } from '../../modules/local/get_software_versions' addParams( options: [publish_files : ['tsv':'']] )
include { KRAKEN2_DB } from '../../modules/local/get_minikraken' addParams( options: [:] )

// Usage pattern from nf-core/rnaseq: Empty dummy file for optional inputs
ch_dummy_input = file("$projectDir/assets/dummy_file.txt", checkIfExists: true)

/*
========================================================================================
RUN MAIN WORKFLOW
Expand All @@ -53,6 +34,7 @@ workflow ASSEMBLE_SHORTREADS{
krakendb_cache

main:
ch_multiqc_files = Channel.empty()
/////////////////// Read Processing /////////////////////////////
/*
* MODULE: Run FastQC
Expand All @@ -76,18 +58,20 @@ workflow ASSEMBLE_SHORTREADS{
///*
// * MODULE: Run Kraken2
// */
if (krakendb_cache){
krakendb_cache.set { ch_kraken_db }
if (!params.skip_kraken) {
if (krakendb_cache){
krakendb_cache.set { ch_kraken_db }
}
else {
KRAKEN2_DB()
KRAKEN2_DB.out.minikraken.set { ch_kraken_db }
}


KRAKEN2_RUN(FASTP.out.reads, ch_kraken_db)
ch_software_versions = ch_software_versions.mix(KRAKEN2_RUN.out.versions.first().ifEmpty(null))
ch_multiqc_files = ch_multiqc_files.mix(KRAKEN2_RUN.out.txt.collect{it[1]}.ifEmpty([]))
}
else {
KRAKEN2_DB()
KRAKEN2_DB.out.minikraken.set { ch_kraken_db }
}


KRAKEN2_RUN(FASTP.out.reads, ch_kraken_db)
ch_software_versions = ch_software_versions.mix(KRAKEN2_RUN.out.versions.first().ifEmpty(null))

/////////////////// ASSEMBLE /////////////////////////////
/*
* MODULE: Assembly
Expand All @@ -112,10 +96,8 @@ workflow ASSEMBLE_SHORTREADS{
QUAST(ch_to_quast, ch_reference_genome, [], use_reference_genome, false)
ch_software_versions = ch_software_versions.mix(QUAST.out.versions.first().ifEmpty(null))

ch_multiqc_files = Channel.empty()
ch_multiqc_files = ch_multiqc_files.mix(FASTQC.out.zip.collect{it[1]}.ifEmpty([]))
ch_multiqc_files = ch_multiqc_files.mix(TRIM_FASTQC.out.zip.collect{it[1]}.ifEmpty([]))
ch_multiqc_files = ch_multiqc_files.mix(KRAKEN2_RUN.out.txt.collect{it[1]}.ifEmpty([]))
ch_multiqc_files = ch_multiqc_files.mix(QUAST.out.tsv.collect())

emit:
Expand Down
22 changes: 12 additions & 10 deletions workflows/arete.nf
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ workflow QUALITYCHECK{
}
ch_software_versions = Channel.empty()
db_cache = params.db_cache ? params.db_cache : false
ch_multiqc_files = Channel.empty()

/*
* SUBWORKFLOW: Read in samplesheet, validate and stage input files
Expand All @@ -422,15 +423,18 @@ workflow QUALITYCHECK{
///*
// * MODULE: Run Kraken2
// */
if(db_cache) {
GET_DB_CACHE(db_cache)
KRAKEN2_RUN(ANNOTATION_INPUT_CHECK.out.genomes, GET_DB_CACHE.out.minikraken)
} else {
KRAKEN2_DB()
KRAKEN2_RUN(ANNOTATION_INPUT_CHECK.out.genomes, KRAKEN2_DB.out.minikraken)
}
if (!params.skip_kraken) {
if(db_cache) {
GET_DB_CACHE(db_cache)
KRAKEN2_RUN(ANNOTATION_INPUT_CHECK.out.genomes, GET_DB_CACHE.out.minikraken)
} else {
KRAKEN2_DB()
KRAKEN2_RUN(ANNOTATION_INPUT_CHECK.out.genomes, KRAKEN2_DB.out.minikraken)
}

ch_software_versions = ch_software_versions.mix(KRAKEN2_RUN.out.versions.first().ifEmpty(null))
ch_software_versions = ch_software_versions.mix(KRAKEN2_RUN.out.versions.first().ifEmpty(null))
ch_multiqc_files = ch_multiqc_files.mix(KRAKEN2_RUN.out.txt.collect{it[1]}.ifEmpty([]))
}
/*
* Module: CheckM Quality Check
*/
Expand All @@ -450,10 +454,8 @@ workflow QUALITYCHECK{
QUAST(ch_to_quast, ch_reference_genome, [], use_reference_genome, false)
ch_software_versions = ch_software_versions.mix(QUAST.out.versions.first().ifEmpty(null))

ch_multiqc_files = Channel.empty()
ch_multiqc_files = ch_multiqc_files.mix(Channel.from(ch_multiqc_config))
ch_multiqc_files = ch_multiqc_files.mix(QUAST.out.tsv.collect())
ch_multiqc_files = ch_multiqc_files.mix(KRAKEN2_RUN.out.txt.collect{it[1]}.ifEmpty([]))
MULTIQC(ch_multiqc_files.collect())
multiqc_report = MULTIQC.out.report.toList()
ch_software_versions = ch_software_versions.mix(MULTIQC.out.version.ifEmpty(null))
Expand Down

0 comments on commit 192ab29

Please sign in to comment.