Skip to content

Commit 2e1e760

Browse files
Merge pull request #982 from FriederikeHanssen/issue_805
Remove exit statements
2 parents 56a8de5 + 4b6689b commit 2e1e760

File tree

5 files changed

+41
-61
lines changed

5 files changed

+41
-61
lines changed

.nf-core.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ lint:
1010
- docs/images/nf-core-sarek_logo_dark.png
1111
- docs/images/nf-core-sarek_logo_light.png
1212
- lib/NfcoreTemplate.groovy
13+
- lib/NfcoreSchema.groovy
1314
template_strings: False

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4747
- [#941](https://github.com/nf-core/sarek/pull/941) - Fix json validation for `tools`, `skip_tools` and `use_gatk_spark` [#892](https://github.com/nf-core/sarek/issues/892)
4848
- [#954](https://github.com/nf-core/sarek/pull/954) - Fix missing annotation keys with snpeff and ensemblvep for `hg19`
4949
- [#957](https://github.com/nf-core/sarek/pull/957) - Add `failOnDuplicate` and `failOnMismatch` options to all `join()` operator where it was possible
50+
- [#982](https://github.com/nf-core/sarek/pull/982) - Remove usage of exit statements, using `Nextflow.error` instead
5051

5152
### Deprecated
5253

lib/NfcoreSchema.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This file holds several functions used to perform JSON parameter validation, help and summary rendering for the nf-core pipeline template.
33
//
44

5+
import nextflow.Nextflow
56
import org.everit.json.schema.Schema
67
import org.everit.json.schema.loader.SchemaLoader
78
import org.everit.json.schema.ValidationException
@@ -177,7 +178,7 @@ class NfcoreSchema {
177178
}
178179

179180
if (has_error) {
180-
System.exit(1)
181+
Nextflow.error('Exiting!')
181182
}
182183
}
183184

lib/WorkflowSarek.groovy

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This file holds several functions specific to the workflow/sarek.nf in the nf-core/sarek pipeline
33
//
44

5+
import nextflow.Nextflow
56
import groovy.text.SimpleTemplateEngine
67

78
class WorkflowSarek {
@@ -14,8 +15,7 @@ class WorkflowSarek {
1415

1516

1617
if (!params.fasta) {
17-
log.error "Genome fasta file not specified with e.g. '--fasta genome.fa' or via a detectable config file."
18-
System.exit(1)
18+
Nextflow.error("Genome fasta file not specified with e.g. '--fasta genome.fa' or via a detectable config file.")
1919
}
2020
}
2121

@@ -66,39 +66,38 @@ class WorkflowSarek {
6666
//
6767
private static void genomeExistsError(params, log) {
6868
if (params.genomes && params.genome && !params.genomes.containsKey(params.genome)) {
69-
log.error "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
69+
def error_string = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
7070
" Genome '${params.genome}' not found in any config files provided to the pipeline.\n" +
7171
" Currently, the available genome keys are:\n" +
7272
" ${params.genomes.keySet().join(", ")}\n" +
7373
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
74-
System.exit(1)
74+
Nextflow.error(error_string)
7575
}
7676
}
7777

7878
public static String retrieveInput(params, log){
7979
if (!params.build_only_index) {
8080
switch (params.step) {
81-
case 'mapping': log.warn "Can't start with step $params.step without samplesheet"
82-
System.exit(1);
81+
case 'mapping': Nextflow.error("Can't start with step $params.step without samplesheet")
8382
break
84-
case 'markduplicates': log.warn "Using file ${params.outdir}/csv/mapped.csv"
83+
case 'markduplicates': log.warn("Using file ${params.outdir}/csv/mapped.csv")
8584
params.putIfAbsent("input","${params.outdir}/csv/mapped.csv");
8685
break
87-
case 'prepare_recalibration': log.warn "Using file ${params.outdir}/csv/markduplicates_no_table.csv"
86+
case 'prepare_recalibration': log.warn("Using file ${params.outdir}/csv/markduplicates_no_table.csv")
8887
params.putIfAbsent("input", "${params.outdir}/csv/markduplicates_no_table.csv");
8988
break
90-
case 'recalibrate': log.warn "Using file ${params.outdir}/csv/markduplicates.csv"
89+
case 'recalibrate': log.warn("Using file ${params.outdir}/csv/markduplicates.csv")
9190
params.putIfAbsent("input", "${params.outdir}/csv/markduplicates.csv");
9291
break
93-
case 'variant_calling': log.warn "Using file ${params.outdir}/csv/recalibrated.csv"
92+
case 'variant_calling': log.warn("Using file ${params.outdir}/csv/recalibrated.csv")
9493
params.putIfAbsent("input", "${params.outdir}/csv/recalibrated.csv");
9594
break
9695
// case 'controlfreec': csv_file = file("${params.outdir}/variant_calling/csv/control-freec_mpileup.csv", checkIfExists: true); break
97-
case 'annotate': log.warn "Using file ${params.outdir}/csv/variantcalled.csv"
96+
case 'annotate': log.warn("Using file ${params.outdir}/csv/variantcalled.csv")
9897
params.putIfAbsent("input","${params.outdir}/csv/variantcalled.csv");
9998
break
100-
default: log.warn "Please provide an input samplesheet to the pipeline e.g. '--input samplesheet.csv'"
101-
exit 1, "Unknown step $params.step"
99+
default: log.warn("Please provide an input samplesheet to the pipeline e.g. '--input samplesheet.csv'")
100+
Nextflow.error("Unknown step $params.step")
102101
}
103102
}
104103
}

0 commit comments

Comments
 (0)