Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pbelmann committed Aug 1, 2022
1 parent 9e34019 commit ac800a8
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 16 deletions.
27 changes: 21 additions & 6 deletions docs/developer_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ Given a version number MAJOR.MINOR.PATCH, increment the:

## Process

1. Process names should start `p`.
Process names should start `p`. The in- and output of processes should contain a sample and/or a bin and contig id.
Custom error strategies that do not follow the strategy defined in nextflow.config, should be documented (see Megahit example).

2. The input and output of processes should contain a sample and/or bin and contig id.
### Processes should publish process specific files

3. Pocesses should publish `.command.sh`, `.command.out`, `.command.log` and `.command.err` files but never `.command.run`.
Processes should publish `.command.sh`, `.command.out`, `.command.log` and `.command.err` files but never `.command.run`.
In cases where processes process different data but publish it to the same folder these files would be overwritten on every run.
For example when Prokka publishes log files of every genome to the same sample directory.
For that reason these files need to be renamed, so that their names include a unique id (e.g. bin id).
Expand All @@ -95,11 +96,11 @@ tuple env(FILE_ID), val("${output}"), val(params.LOG_LEVELS.INFO), file(".comman

Examples can be viewed in the Checkm and Prokka process.

## Logs
#### Logs

Log files should be stored in the user provided `logDir` directory.

### Log Level
##### Log Level

Every configuration file must have a `logLevel` attribute that can have the following values:

Expand All @@ -124,7 +125,19 @@ tuple env(FILE_ID), val("${output}"), val(params.LOG_LEVELS.INFO), file(".comman
file(".command.out"), file(".command.err"), file(".command.log"), emit: logs
```

4. Custom error strategies that do not follow the strategy defined in nextflow.config, should be documented (see Megahit example).
### Time Limit

Every process must define a time limit which will never be reached on "normal" execution. This limit is only useful for errors in the execution environment
which could lead to an endless execution of the process.

You can use the setTimeLimit helper method to add a user configurable time limit.

Example:

```
time Utils.setTimeLimit(params.steps.qc.fastp, params.modules.qc.process.fastp.defaults, params.mediumDefault)
```


## Databases

Expand All @@ -145,8 +158,10 @@ steps:
parameter: 42
processName:
additionalParams: " --super-flag "
timeLimit: "AUTO"
```
Please check the process chapter regarding possible values for the time limit attribute.
Additional params can have a string value (like the example above) that is provided to the tool:
```JAVA
Expand Down
2 changes: 1 addition & 1 deletion example_params/fullPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ steps:
fastp:
# Example params: " --cut_front --cut_tail --detect_adapter_for_pe "
additionalParams: " "
timeLimit: "AUTO"
nonpareil:
additionalParams: " -v 10 -r 1234 "
jellyfish:
additionalParams:
count: " -m 21 -s 100M "
histo: " "

assembly:
megahit:
additionalParams: " --min-contig-len 200 "
Expand Down
1 change: 1 addition & 0 deletions example_params/fullPipelineQC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ steps:
download:
s5cmdParams: " --retry-count 30 --no-verify-ssl --no-sign-request --endpoint-url https://openstack.cebitec.uni-bielefeld.de:8080 "
additionalParams: " "
timeLimit: "AUTO"
resources:
large:
cpus: 28
Expand Down
1 change: 1 addition & 0 deletions example_params/fullPipelineSRAQC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ steps:
download:
s5cmdParams: " --retry-count 30 --no-verify-ssl --no-sign-request --endpoint-url https://openstack.cebitec.uni-bielefeld.de:8080 "
additionalParams: " "
timeLimit: "AUTO"

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
fastp:
# Example params: " --cut_front --cut_tail --detect_adapter_for_pe "
additionalParams: " "
timeLimit: "AUTO"
assembly:
megahit:
additionalParams: " --min-contig-len 200 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
fastp:
# Example params: " --cut_front --cut_tail --detect_adapter_for_pe "
additionalParams: " "
timeLimit: "AUTO"
assembly:
megahit:
additionalParams: " --min-contig-len 200 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
fastp:
# Example params: " --cut_front --cut_tail --detect_adapter_for_pe "
additionalParams: " "
timeLimit: "AUTO"
assembly:
megahit:
fastg: false
Expand Down
30 changes: 30 additions & 0 deletions lib/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,34 @@ class Utils {
module.version.patch
}

/*
* This function sets a time limit based on a user provided mode and the resource defaults
* that are usually consumed by the process.
*
* Input:
* process: Defines the user provided timeLimit mode.
* processDefaults: Defines default resource values (cpus, RAM, etc.).
* flavor: Defines the user provided flavor for the process.
*/
static String setTimeLimit(process, processDefaults, flavor){
def timeUnit = "h"
switch(process.timeLimit){
case "DISABLED":
return "";
case "AUTO":
def defaultCPUs = processDefaults.flavor.cpus
if(defaultCPUs > flavor.cpus){
def timeLimit = defaultCPUs/flavor.cpus * processDefaults.time;
return timeLimit + timeUnit;
} else {
return processDefaults.time + timeUnit;
}
default:
if(process.timeLimit instanceof Number){
return process.timeLimit + timeUnit;
} else {
System.out.println("WARNING: unknown time limit parameter specified!");
}
}
}
}
9 changes: 7 additions & 2 deletions modules/qualityControl/module.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ def getOutput(SAMPLE, RUNID, TOOL, filename){
'/' + TOOL + '/' + filename
}


process pFastpSplit {

label 'medium'

tag "$sample"
tag "Sample: $sample"

publishDir params.output, saveAs: { filename -> getOutput("${sample}", params.runid, "fastp", filename) }

when params?.steps?.qc.containsKey("fastp")

container "${params.fastp_image}"

time Utils.setTimeLimit(params.steps.qc.fastp, params.modules.qc.process.fastp.defaults, params.resources.medium)

input:
tuple val(sample), path(read1, stageAs: "read1.fq.gz"), path(read2, stageAs: "read2.fq.gz")

Expand Down Expand Up @@ -97,10 +100,12 @@ process pFastpSplitDownload {

label 'medium'

tag "$sample"
tag "Sample: $sample"

publishDir params.output, saveAs: { filename -> getOutput("${sample}", params.runid, "fastp", filename) }

time Utils.setTimeLimit(params.steps.qc.fastp, params.modules.qc.process.fastpDownload.defaults, params.resources.medium)

when params?.steps?.qc.containsKey("fastp")

container "${params.fastp_image}"
Expand Down
25 changes: 18 additions & 7 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ defaultResources {
}



params {
polished {
databases = checkParamsKey(params, "databases", { path -> path.endsWith("/") ? path : path + "/" })
Expand Down Expand Up @@ -73,14 +72,12 @@ params {
PlasClass_image = "quay.io/biocontainers/plasclass:0.1.1--pyhdfd78af_0"
rgi_image = "quay.io/biocontainers/rgi:5.2.1--pyhdfd78af_1"
sans_image = "metagenomics/toolkit-sans:0.1.0"


resources = defaultResources


resources = defaultResources

LOG_LEVELS {
ALL = 0
INFO = 1
ALL = 0
INFO = 1
}

modules {
Expand All @@ -107,6 +104,20 @@ params {
minor = 3
patch = 0
}
process {
fastp {
defaults {
time = 6
flavor = defaultResources.medium
}
}
fastpDownload {
defaults {
time = 12
flavor = defaultResources.medium
}
}
}
}
assembly {
name = "assembly"
Expand Down

0 comments on commit ac800a8

Please sign in to comment.