Skip to content

Commit

Permalink
Use -1 as default for *_fix_cpus int params
Browse files Browse the repository at this point in the history
  • Loading branch information
skrakau committed Mar 23, 2021
1 parent e76c2fe commit 303a3c2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ if (params.coassemble_group && params.binning_map_mode == 'own')
exit 1, "Invalid combination of parameter '--binning_map_mode own' and parameter '--coassemble_group'. Select either 'all' or 'group' mapping mode when performing group-wise co-assembly."

// Check if specified cpus for SPAdes are available
if ( params.spades_fix_cpus && params.spades_fix_cpus > params.max_cpus )
if ( params.spades_fix_cpus > params.max_cpus )
exit 1, "Invalid parameter '--spades_fix_cpus ${params.spades_fix_cpus}', max cpus are '${params.max_cpus}'."
if ( params.spadeshybrid_fix_cpus && params.spadeshybrid_fix_cpus > params.max_cpus )
if ( params.spadeshybrid_fix_cpus > params.max_cpus )
exit 1, "Invalid parameter '--spadeshybrid_fix_cpus ${params.spadeshybrid_fix_cpus}', max cpus are '${params.max_cpus}'."
// Check if settings concerning reproducibility of used tools are consistent and print warning if not
if (params.megahit_fix_cpu_1 || params.spades_fix_cpus || params.spadeshybrid_fix_cpus){
if (!params.skip_spades && !params.spades_fix_cpus)
if (params.megahit_fix_cpu_1 || params.spades_fix_cpus != -1 || params.spadeshybrid_fix_cpus != -1){
if (!params.skip_spades && params.spades_fix_cpus == -1)
log.warn "At least one assembly process is run with a parameter to ensure reproducible results, but SPAdes not. Consider using the parameter '--spades_fix_cpus'."
if (hybrid && !params.skip_spadeshybrid && !params.spadeshybrid_fix_cpus)
if (hybrid && params.skip_spadeshybrid && params.spadeshybrid_fix_cpus == -1)
log.warn "At least one assembly process is run with a parameter to ensure reproducible results, but SPAdes hybrid not. Consider using the parameter '--spadeshybrid_fix_cpus'."
if (!params.skip_megahit && !params.megahit_fix_cpu_1)
log.warn "At least one assembly process is run with a parameter to ensure reproducible results, but MEGAHIT not. Consider using the parameter '--megahit_fix_cpu_1'."
Expand Down
2 changes: 1 addition & 1 deletion modules/local/spades.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ process SPADES {
script:
def software = getSoftwareName(task.process)
maxmem = task.memory.toGiga()
if ( !params.spades_fix_cpus || task.cpus == params.spades_fix_cpus )
if ( params.spades_fix_cpus == -1 || task.cpus == params.spades_fix_cpus )
"""
metaspades.py \
${params.spades_options} \
Expand Down
2 changes: 1 addition & 1 deletion modules/local/spadeshybrid.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ process SPADESHYBRID {
script:
def software = getSoftwareName(task.process)
maxmem = task.memory.toGiga()
if ( !params.spadeshybrid_fix_cpus || task.cpus == params.spadeshybrid_fix_cpus )
if ( params.spadeshybrid_fix_cpus == -1 || task.cpus == params.spadeshybrid_fix_cpus )
"""
metaspades.py \
${params.spades_options} \
Expand Down
8 changes: 4 additions & 4 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ params {

// Reproducibility options
megahit_fix_cpu_1 = false
spades_fix_cpus = false
spadeshybrid_fix_cpus = false
spades_fix_cpus = -1
spadeshybrid_fix_cpus = -1
metabat_rng_seed = 1

// References
Expand Down Expand Up @@ -226,10 +226,10 @@ def check_megahit_cpus (x, attempt ) {
else return check_max (x * attempt, 'cpus' )
}
def check_spades_cpus (x, attempt ) {
if (params.spades_fix_cpus) return check_max (params.spades_fix_cpus, 'cpus' )
if (params.spades_fix_cpus != -1) return check_max (params.spades_fix_cpus, 'cpus' )
else return check_max (x * attempt, 'cpus' )
}
def check_spadeshybrid_cpus (x, attempt ) {
if (params.spadeshybrid_fix_cpus) return check_max (params.spadeshybrid_fix_cpus, 'cpus' )
if (params.spadeshybrid_fix_cpus != -1) return check_max (params.spadeshybrid_fix_cpus, 'cpus' )
else return check_max (x * attempt, 'cpus' )
}
6 changes: 4 additions & 2 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@
},
"spades_fix_cpus": {
"type": "integer",
"default": -1,
"description": "Fix number of CPUs used by SPAdes. Not increased with retries.",
"help_text": "SPAdes is designed to be deterministic for a given number of threads. To generate reproducible results fix the number of CPUs using this parameter.\n\nWhen using this parameter do not change the number of CPUs for the `spades` process with a custom config file. This would result in an error.\n\nDefault: The number of CPUs is specified in the `base.config` file, and increased with each retry."
"help_text": "SPAdes is designed to be deterministic for a given number of threads. To generate reproducible results fix the number of CPUs using this parameter.\n\nWhen using this parameter do not change the number of CPUs for the `spades` process with a custom config file. This would result in an error.\n\nDefault: -1 (the number of CPUs is specified in the `base.config` or in a custom config file, and increased with each retry)."
},
"spadeshybrid_fix_cpus": {
"type": "integer",
"default": -1,
"description": "Fix number of CPUs used by SPAdes hybrid. Not increased with retries.",
"help_text": "SPAdes is designed to be deterministic for a given number of threads. To generate reproducible results fix the number of CPUs using this parameter.\n\nWhen using this parameter do not change the number of CPUs for the `spadeshybrid` process with a custom config file. This would result in an error.\n\nDefault: The number of CPUs is specified in the `base.config` file, and increased with each retry."
"help_text": "SPAdes is designed to be deterministic for a given number of threads. To generate reproducible results fix the number of CPUs using this parameter.\n\nWhen using this parameter do not change the number of CPUs for the `spadeshybrid` process with a custom config file. This would result in an error.\n\nDefault: -1 (the number of CPUs is specified in the `base.config` or in a custom config file, and increased with each retry)."
},
"metabat_rng_seed": {
"type": "integer",
Expand Down

0 comments on commit 303a3c2

Please sign in to comment.