Skip to content

Commit

Permalink
Merge pull request nf-core#114 from nf-core/input_params_patch
Browse files Browse the repository at this point in the history
Check conflicting input parameters for stats and eval
  • Loading branch information
luisas authored Mar 20, 2024
2 parents 83de935 + 6521ea2 commit 2e87c59
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 475 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Initial release of nf-core/multiplesequencealign, created with the [nf-core](htt
[#100](https://github.com/nf-core/multiplesequencealign/pull/100) - Add support for optional stats and evals. Clean tests.
[#110](https://github.com/nf-core/multiplesequencealign/issues/110) - Add Readme documentation. Add nf-test for the pipeline.
[#76](https://github.com/nf-core/multiplesequencealign/issues/76) - Add reading of trace files for shiny app.
[#99](https://github.com/nf-core/multiplesequencealign/issues/99) - Add check for conflicting input parameters for stats and eval.

### `Fixed`

Expand Down
440 changes: 0 additions & 440 deletions conf/igenomes.config

This file was deleted.

11 changes: 0 additions & 11 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ include { MULTIPLESEQUENCEALIGN } from './workflows/multiplesequencealign'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_multiplesequencealign_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_multiplesequencealign_pipeline'

include { getGenomeAttribute } from './subworkflows/local/utils_nfcore_multiplesequencealign_pipeline'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GENOME PARAMETER VALUES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

// This is an example of how to use getGenomeAttribute() to fetch parameters
// from igenomes.config using `--genome`

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NAMED WORKFLOWS FOR PIPELINE
Expand Down
6 changes: 3 additions & 3 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ params {
// Evaluation
skip_eval = false
calc_sp = true
calc_tc = true
calc_irmsd = true
calc_tc = false
calc_irmsd = false

skip_compress = false

Expand Down Expand Up @@ -71,7 +71,7 @@ params {
// Schema validation default options
validationFailUnrecognisedParams = false
validationLenientMode = false
validationSchemaIgnoreParams = 'genomes,igenomes_base'
validationSchemaIgnoreParams = ''
validationShowHiddenParams = false
validate_params = true

Expand Down
2 changes: 1 addition & 1 deletion subworkflows/local/evaluate.nf
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ workflow EVALUATE {
tc = tc_csv.map{ meta, csv -> csv }
irmsd = irmsd_csv.map{ meta, csv -> csv }

def number_of_evals = [params.calc_sp, params.calc_tc, params.calc_irmsd].count{ it == true }
def number_of_evals = [params.calc_sp, params.calc_tc, params.calc_irmsd].count(true)
csvs_stats = sp.mix(tc).mix(irmsd).collect().map{ csvs -> [[id:"summary_eval"], csvs] }
if(number_of_evals >= 2){
MERGE_EVAL(csvs_stats)
Expand Down
3 changes: 2 additions & 1 deletion subworkflows/local/stats.nf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ workflow STATS {
ch_versions = Channel.empty()
sim_csv = Channel.empty()
seqstats_csv = Channel.empty()
stats_summary = Channel.empty()

// // -------------------------------------------
// // SEQUENCE SIMILARITY
Expand Down Expand Up @@ -67,7 +68,7 @@ workflow STATS {
seqstats = seqstats_csv.map{ meta, csv -> csv }

csvs_stats = sim.mix(seqstats).collect().map{ csvs -> [[id:"summary_stats"], csvs] }
def number_of_stats = [params.calc_sim, params.calc_seq_stats].count{ it == true }
def number_of_stats = [params.calc_sim, params.calc_seq_stats].count(true)
if(number_of_stats >= 2){
MERGE_STATS(csvs_stats)
ch_versions = ch_versions.mix(MERGE_STATS.out.versions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ workflow PIPELINE_COMPLETION {
// Check and validate pipeline parameters
//
def validateInputParameters() {
genomeExistsError()
statsParamsWarning()
evalParamsWarning()
}

//
Expand All @@ -178,29 +179,54 @@ def validateInputSamplesheet(input) {

return [ metas[0], fastqs ]
}

//
// Get attribute from genome config file e.g. fasta
// Warning if incorrect combination of stats parameters are used
//
def getGenomeAttribute(attribute) {
if (params.genomes && params.genome && params.genomes.containsKey(params.genome)) {
if (params.genomes[ params.genome ].containsKey(attribute)) {
return params.genomes[ params.genome ][ attribute ]
def statsParamsWarning() {
if (params.skip_stats){
if(params.calc_sim || params.calc_seq_stats) {
def warning_string = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" WARNING: The param skip_stats is set to '${params.skip_stats}'.\n" +
" The following params have values calc_sim: ${params.calc_sim} and calc_seq_stats: ${params.calc_seq_stats} \n" +
" As skip_stats is set to true, the params.calc_sim and params.calc_seq_stats will be set by default to false. \n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
println(warning_string)
}
}
return null
if (!params.skip_stats && !params.calc_sim && !params.calc_seq_stats){
params.skip_stats = true
def warning_string = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" WARNING: The param skip_stats has been changed from false to true'.\n" +
" None of the modules withing the stats subworkflow was activated. \n" +
" To activate them you can use param.calc_sim, params.calc_seq_stats. \n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
println(warning_string)
}
}

//
// Exit pipeline if incorrect --genome key provided
// Warning if incorrect combination of eval parameters are used
//
def genomeExistsError() {
if (params.genomes && params.genome && !params.genomes.containsKey(params.genome)) {
def error_string = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" Genome '${params.genome}' not found in any config files provided to the pipeline.\n" +
" Currently, the available genome keys are:\n" +
" ${params.genomes.keySet().join(", ")}\n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
error(error_string)
def evalParamsWarning() {
if (params.skip_eval){
if(params.calc_sp || params.calc_tc || params.calc_irmsd) {
def warning_string = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" WARNING: The param skip_eval is set to '${params.skip_eval}'.\n" +
" The following params have values params.calc_sp: ${params.calc_sp}, params.calc_tc: ${params.calc_tc} and params.calc_irms: ${params.calc_irmsd} \n" +
" As skip_eval is set to true, the params.calc_sp, params.calc_tc and params.calc_irmsd are set by default to false. \n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
println(warning_string)
}
}
if (!params.skip_eval && !params.calc_sp && !params.calc_tc && !params.calc_irmsd ){
params.skip_eval = true
def warning_string = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" WARNING: The param skip_eval has been changed from false to true'.\n" +
" None of the modules withing the stats subworkflow was activated. \n" +
" To activate them you can use param.calc_sp, params.calc_tc, params.calc_irmsd. \n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
println(warning_string)
}
}

Expand Down
10 changes: 7 additions & 3 deletions workflows/multiplesequencealign.nf
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@ workflow MULTIPLESEQUENCEALIGN {
.set { stats_and_evaluation }

if( !params.skip_stats && !params.skip_eval ){
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)
def number_of_stats = [params.calc_sim, params.calc_seq_stats].count(true)
def number_of_evals = [params.calc_sp, params.calc_tc, params.calc_irmsd].count(true)
if (number_of_evals > 0 && number_of_stats > 0 ){
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)
}
}else{
stats_and_evaluation_summary = stats_and_evaluation
}
Expand Down

0 comments on commit 2e87c59

Please sign in to comment.