Skip to content

Commit

Permalink
Added error message for missing required parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
renewiegandt committed Apr 16, 2019
1 parent 66c11ff commit 3caf997
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions pipeline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -89,41 +89,28 @@ val_missing = false
send_help = false
missing_params = []

//@TODO remove iteration over all parameter
params.each { key, value ->
if (req_params.contains(key)){
if (key == "gtf_annotation" && value == "" && params.gtf_merged == ""){
val_missing = true
missing_params.add("$key or gtf_merged")
} else {
if (value == ""){
val_missing = true
missing_params + key
missing_params.add(key)
}
}
}
if (!(all_params.contains(key))){
println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!")
}
if(int_params.contains(key)) {
if (!("${value}" ==~ /\d+/ )){
println("ERROR: $key needs to be an Integer")
System.exit(2)
}
}
if(file_params.contains(key) || (key == "gtf_merged" && value != "") ) {
if(!file(value).exists()) {
println("ERROR: $key not found. Please check the given path.")
System.exit(2)
}
}
}

if (val_missing){
send_help = true
println("Error: Following required parameters are missing: $missing_params")
}
if (send_help || "${params.help}" != "0") {
log.info """
Usage: nextflow run pipeline.nf --bigwig [BigWig-file] --bed [BED-file] --genome_fasta [FASTA-file] --motif_db [MEME-file] --config [UROPA-config-file]
log.info """
Usage: nextflow run pipeline.nf --bigwig [BigWig-file] --bed [BED-file] --genome_fasta [FASTA-file] --motif_db [MEME-file] --config [UROPA-config-file]
Required arguments:
--bigwig Path to BigWig-file
Expand Down Expand Up @@ -185,8 +172,8 @@ if (send_help || "${params.help}" != "0") {
config
Evaluation:
--max_uropa_runs INT Maximum number UROPA runs running parallelized (Default: 10)
All arguments can be set in the configuration files
"""
All arguments can be set in the configuration files
"""
System.exit(2)
} else {
Channel.fromPath(params.bigwig).map {it -> [it.simpleName, it]}.set {bigwig_input}
Expand All @@ -202,7 +189,23 @@ if (send_help || "${params.help}" != "0") {
}
}


params.each { key, value ->
if (!(all_params.contains(key))){
println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!")
}
if(int_params.contains(key)) {
if (!("${value}" ==~ /\d+/ )){
println("ERROR: $key needs to be an Integer")
System.exit(2)
}
}
if(file_params.contains(key) || (key == "gtf_merged" && value != "") ) {
if(!file(value).exists()) {
println("ERROR: $key not found. Please check the given path.")
System.exit(2)
}
}
}

if (!("${params.identity}" ==~ /^0\.[8-9][[0-9]*]?|^1(\.0)?/ )){
println("ERROR: --identity needs to be float in range 0.8 to 1.0")
Expand Down

0 comments on commit 3caf997

Please sign in to comment.