Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move evaluation subworkflow to an independent workflow #3

Open
wants to merge 1 commit into
base: poc-classes
Choose a base branch
from
Open
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
48 changes: 41 additions & 7 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ nextflow.enable.dsl = 2
*/

include { MULTIPLESEQUENCEALIGN } from './workflows/multiplesequencealign'
include { EVALUATEMSA } from './workflows/evaluatemsa'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_multiplesequencealign_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_multiplesequencealign_pipeline'

Expand Down Expand Up @@ -52,6 +53,29 @@ workflow NFCORE_MULTIPLESEQUENCEALIGN {
multiqc_report = MULTIPLESEQUENCEALIGN.out.multiqc

}

workflow NFCORE_EVALUATEMSA {

take:
msa_alignment // channel: [ meta, /path/to/file.aln ]
ch_refs // channel: [ meta, /path/to/file.aln ]
ch_structures_template // channel: [ meta, /path/to/file.pdb ]
stats_summary // channel: [ meta, /path/to/file.csv ]

main:
ch_versions = Channel.empty()

//
// WORKFLOW: Run evaluation pipelines
//
EVALUATEMSA (
msa_alignment,
ch_refs,
ch_structures_template,
stats_summary,
ch_versions
)
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
Expand All @@ -76,13 +100,23 @@ workflow {
params.tools
)

//
// WORKFLOW: Run main workflow
//
NFCORE_MULTIPLESEQUENCEALIGN (
PIPELINE_INITIALISATION.out.samplesheet,
PIPELINE_INITIALISATION.out.tools
)
if (params.evaluate) {
// WORKFLOW: Run evaluation workflow
NFCORE_EVALUATEMSA (
PIPELINE_INITIALISATION.out.msa_alignment,
PIPELINE_INITIALISATION.out.ch_refs,
PIPELINE_INITIALISATION.out.ch_structures_template,
PIPELINE_INITIALISATION.out.stats_summary
)
} else {
//
// WORKFLOW: Run main workflow
//
NFCORE_MULTIPLESEQUENCEALIGN (
PIPELINE_INITIALISATION.out.samplesheet,
PIPELINE_INITIALISATION.out.tools
)
}

//
// SUBWORKFLOW: Run completion tasks
Expand Down
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ params {
extract_plddt = false

// Evaluation
evaluate = false
skip_eval = false
calc_sp = true
calc_tc = true
Expand Down
111 changes: 111 additions & 0 deletions workflows/evaluatemsa.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT MODULES / SUBWORKFLOWS / FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

// MODULES
include { MULTIQC } from '../modules/local/multiqc'
include { PREPARE_MULTIQC } from '../modules/local/prepare_multiqc'
include { PREPARE_SHINY } from '../modules/local/prepare_shiny'

//SUBWORKFLOWS
include { EVALUATE } from '../subworkflows/local/evaluate'

// FUNCTIONS
include { paramsSummaryMap } from 'plugin/nf-validation'
include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline'
include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline'

workflow EVALUATEMSA {

take:
msa_alignment
ch_refs
ch_structures_template
stats_summary
ch_versions

main:
evaluation_summary = Channel.empty()
stats_and_evaluation_summary = Channel.empty()
ch_multiqc_table = Channel.empty()

//
// Evaluate the quality of the alignment
//
if (!params.skip_eval) {
EVALUATE (msa_alignment, ch_refs, ch_structures_template)
ch_versions = ch_versions.mix(EVALUATE.out.versions)
evaluation_summary = evaluation_summary.mix(EVALUATE.out.eval_summary)
}

//
// Combine stats and evaluation reports into a single CSV
//
if (!params.skip_stats || !params.skip_eval) {
stats_summary_csv = stats_summary.map{ meta, csv -> csv }
eval_summary_csv = evaluation_summary.map{ meta, csv -> csv }
stats_summary_csv.mix(eval_summary_csv)
.collect()
.map {
csvs ->
[ [ id:"summary_stats_eval" ], csvs ]
}
.set { stats_and_evaluation }
MERGE_STATS_EVAL (stats_and_evaluation)
stats_and_evaluation_summary = MERGE_STATS_EVAL.out.csv
ch_versions = ch_versions.mix(MERGE_STATS_EVAL.out.versions)
}

//
// MODULE: Shiny
//
if (!params.skip_shiny) {
shiny_app = Channel.fromPath(params.shiny_app)
PREPARE_SHINY (stats_and_evaluation_summary, shiny_app)
ch_shiny_stats = PREPARE_SHINY.out.data.toList()
ch_versions = ch_versions.mix(PREPARE_SHINY.out.versions)
}

softwareVersionsToYAML(ch_versions)
.collectFile(
storeDir: "${params.outdir}/pipeline_info",
name: 'nf_core_pipeline_software_mqc_versions.yml',
sort: true,
newLine: true
).set { ch_collated_versions }

//
// MODULE: MultiQC
//
multiqc_out = Channel.empty()
if (!params.skip_multiqc && (!params.skip_stats || !params.skip_eval)) {
ch_multiqc_config = Channel.fromPath("$projectDir/assets/multiqc_config.yml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config, checkIfExists: true) : Channel.empty()
ch_multiqc_logo = params.multiqc_logo ? Channel.fromPath(params.multiqc_logo, checkIfExists: true) : Channel.empty()
summary_params = paramsSummaryMap(workflow, parameters_schema: "nextflow_schema.json")
ch_workflow_summary = Channel.value(paramsSummaryMultiqc(summary_params))
ch_multiqc_custom_methods_description = params.multiqc_methods_description ? file(params.multiqc_methods_description, checkIfExists: true) : file("$projectDir/assets/methods_description_template.yml", checkIfExists: true)
ch_methods_description = Channel.value(methodsDescriptionText(ch_multiqc_custom_methods_description))
ch_multiqc_files = ch_multiqc_files.mix(ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
ch_multiqc_files = ch_multiqc_files.mix(ch_collated_versions)
ch_multiqc_files = ch_multiqc_files.mix(ch_methods_description.collectFile(name: 'methods_description_mqc.yaml', sort: false))

PREPARE_MULTIQC (stats_and_evaluation_summary)
ch_multiqc_table = ch_multiqc_table.mix(PREPARE_MULTIQC.out.multiqc_table.collect{it[1]}.ifEmpty([]))

MULTIQC (
ch_multiqc_files.collect(),
ch_multiqc_config.toList(),
ch_multiqc_custom_config.toList(),
ch_multiqc_logo.toList(),
ch_multiqc_table
)
multiqc_out = MULTIQC.out.report.toList()
}

emit:
versions = ch_versions // channel: [ path(versions.yml) ]
multiqc = multiqc_out // channel: [ path(multiqc_report.html) ]
}
52 changes: 1 addition & 51 deletions workflows/multiplesequencealign.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_mult
// SUBWORKFLOW: Local subworkflows
//
include { STATS } from '../subworkflows/local/stats'
include { EVALUATE } from '../subworkflows/local/evaluate'
include { CREATE_TCOFFEETEMPLATE } from '../modules/local/create_tcoffee_template'

//
// MODULE: local modules
//
include { PREPARE_MULTIQC } from '../modules/local/prepare_multiqc'
include { PREPARE_SHINY } from '../modules/local/prepare_shiny'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT NF-CORE MODULES/SUBWORKFLOWS
Expand Down Expand Up @@ -74,10 +67,7 @@ workflow MULTIPLESEQUENCEALIGN {

main:
ch_multiqc_files = Channel.empty()
ch_multiqc_table = Channel.empty()
evaluation_summary = Channel.empty()
stats_summary = Channel.empty()
stats_and_evaluation_summary = Channel.empty()
ch_shiny_stats = Channel.empty()

ch_input
Expand Down Expand Up @@ -210,43 +200,6 @@ workflow MULTIPLESEQUENCEALIGN {
msa_alignment.mix(MSA_ALIGNMENT.out.alignment)
}

//
// Evaluate the quality of the alignment
//
if (!params.skip_eval) {
EVALUATE (msa_alignment, ch_refs, ch_structures_template)
ch_versions = ch_versions.mix(EVALUATE.out.versions)
evaluation_summary = evaluation_summary.mix(EVALUATE.out.eval_summary)
}

//
// Combine stats and evaluation reports into a single CSV
//
if (!params.skip_stats || !params.skip_eval) {
stats_summary_csv = stats_summary.map{ meta, csv -> csv }
eval_summary_csv = evaluation_summary.map{ meta, csv -> csv }
stats_summary_csv.mix(eval_summary_csv)
.collect()
.map {
csvs ->
[ [ id:"summary_stats_eval" ], csvs ]
}
.set { stats_and_evaluation }
MERGE_STATS_EVAL (stats_and_evaluation)
stats_and_evaluation_summary = MERGE_STATS_EVAL.out.csv
ch_versions = ch_versions.mix(MERGE_STATS_EVAL.out.versions)
}

//
// MODULE: Shiny
//
if (!params.skip_shiny) {
shiny_app = Channel.fromPath(params.shiny_app)
PREPARE_SHINY (stats_and_evaluation_summary, shiny_app)
ch_shiny_stats = PREPARE_SHINY.out.data.toList()
ch_versions = ch_versions.mix(PREPARE_SHINY.out.versions)
}

softwareVersionsToYAML(ch_versions)
.collectFile(
storeDir: "${params.outdir}/pipeline_info",
Expand All @@ -272,15 +225,12 @@ workflow MULTIPLESEQUENCEALIGN {
ch_multiqc_files = ch_multiqc_files.mix(ch_collated_versions)
ch_multiqc_files = ch_multiqc_files.mix(ch_methods_description.collectFile(name: 'methods_description_mqc.yaml', sort: false))

PREPARE_MULTIQC (stats_and_evaluation_summary)
ch_multiqc_table = ch_multiqc_table.mix(PREPARE_MULTIQC.out.multiqc_table.collect{it[1]}.ifEmpty([]))

MULTIQC (
ch_multiqc_files.collect(),
ch_multiqc_config.toList(),
ch_multiqc_custom_config.toList(),
ch_multiqc_logo.toList(),
ch_multiqc_table
[]
)
multiqc_out = MULTIQC.out.report.toList()
}
Expand Down