Skip to content

Commit e8273d4

Browse files
authored
Merge pull request #493 from jfy133/let-me-commit
Adds some improve input validation
2 parents e23fc6f + 470ea41 commit e8273d4

2 files changed

Lines changed: 26 additions & 18 deletions

File tree

conf/base.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ process {
8585
errorStrategy = { task.exitStatus in [141] ? 'ignore' : 'retry' }
8686
}
8787

88+
// Add 1 retry for certain java tools as not enough heap space java errors gives exit code 1
89+
withName: dedup {
90+
errorStrategy = { task.exitStatus in [1] ? 'retry' : 'finish' }
91+
}
92+
8893
// Add 1 retry as not enough heapspace java error gives exit code 1
8994
withName: malt {
9095
errorStrategy = { task.exitStatus in [1] ? 'retry' : 'finish' }

main.nf

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ if (params.genomes && params.genome && !params.genomes.containsKey(params.genome
298298
exit 1, "[nf-core/eager] error: the provided genome '${params.genome}' is not available in the iGenomes file. Currently the available genomes are ${params.genomes.keySet().join(", ")}."
299299
}
300300

301-
// Mapper sanity checking
301+
// Mapper validation
302302
if (params.mapper != 'bwaaln' && !params.mapper == 'circularmapper' && !params.mapper == 'bwamem' && !params.mapper == "bowtie2"){
303303
exit 1, "[nf-core/eager] error: invalid mapper option. Options are: 'bwaaln', 'bwamem', 'circularmapper', 'bowtie2'. Default: 'bwaaln'. You gave: --mapper '${params.mapper}'."
304304
}
@@ -353,7 +353,7 @@ if (!has_extension(params.input, "tsv") && params.skip_collapse && params.singl
353353
exit 1, "[nf-core/eager] error: --skip_collapse can only be set for paired_end samples."
354354
}
355355

356-
// Strip mode sanity checking
356+
// Strip mode validation
357357
if (params.strip_input_fastq){
358358
if (!(['strip','replace'].contains(params.strip_mode))) {
359359
exit 1, "[nf-core/eager] error: --strip_mode can only be set to strip or replace."
@@ -364,12 +364,12 @@ if (params.bam_discard_unmapped && params.bam_unmapped_type == '') {
364364
exit 1, "[nf-core/eager] error: please specify valid unmapped read output format. Options: 'discard', 'bam', 'fastq', 'both'. You gave --bam_unmapped_type '${params.bam_unmapped_type}'."
365365
}
366366

367-
// Bedtools sanity checking
367+
// Bedtools validation
368368
if(params.run_bedtools_coverage && params.anno_file == ''){
369369
exit 1, "[nf-core/eager] error: you have turned on bedtools coverage, but not specified a BED or GFF file with --anno_file. Please validate your parameters."
370370
}
371371

372-
// BAM filtering sanity checking
372+
// BAM filtering validation
373373
if (!params.run_bam_filtering && params.bam_mapping_quality_threshold != 0) {
374374
exit 1, "[nf-core/eager] error: please turn on BAM filtering if you want to perform mapping quality filtering! Give --run_bam_filtering."
375375
}
@@ -386,12 +386,12 @@ if (params.run_bam_filtering && !params.bam_discard_unmapped && params.bam_unmap
386386
exit 1, "[nf-core/eager] error: Please turned on unmapped read discarding, if you have specifed a different unmapped type. Give: --bam_discard_unmapped."
387387
}
388388

389-
// Deduplication sanity checking
389+
// Deduplication validation
390390
if (params.dedupper != 'dedup' && params.dedupper != 'markduplicates') {
391391
exit 1, "[nf-core/eager] error: Selected deduplication tool is not recognised. Options: 'dedup' or 'markduplicates'. You gave: --dedupper '${params.dedupper}'."
392392
}
393393

394-
// Genotyping sanity checking
394+
// Genotyping validation
395395
if (params.run_genotyping){
396396
if (params.genotyping_tool != 'ug' && params.genotyping_tool != 'hc' && params.genotyping_tool != 'freebayes' && params.genotyping_tool != 'pileupcaller' && params.genotyping_tool != 'angsd' ) {
397397
exit 1, "[nf-core/eager] error: please specify a genotyper. Options: 'ug', 'hc', 'freebayes', 'pileupcaller'. You gave: --genotyping_tool '${params.genotyping_tool}'."
@@ -450,7 +450,7 @@ if (params.run_genotyping){
450450
}
451451
}
452452

453-
// Consensus sequence generation sanity checking
453+
// Consensus sequence generation validation
454454
if (params.run_vcf2genome) {
455455
if (!params.run_genotyping) {
456456
exit 1, "[nf-core/eager] error: consensus sequence generation requires genotyping via UnifiedGenotyper on be turned on with the parameter --run_genotyping and --genotyping_tool 'ug'. Please check your genotyping parameters."
@@ -461,7 +461,7 @@ if (params.run_vcf2genome) {
461461
}
462462
}
463463

464-
// MultiVCFAnalyzer sanity checking
464+
// MultiVCFAnalyzer validation
465465
if (params.run_multivcfanalyzer) {
466466
if (!params.run_genotyping) {
467467
exit 1, "[nf-core/eager] error: MultiVCFAnalyzer requires genotyping to be turned on with the parameter --run_genotyping. Please check your genotyping parameters."
@@ -476,7 +476,7 @@ if (params.run_multivcfanalyzer) {
476476
}
477477
}
478478

479-
// Metagenomic sanity checking
479+
// Metagenomic validation
480480
if (params.run_metagenomic_screening) {
481481
if ( !params.bam_discard_unmapped ) {
482482
exit 1, "[nf-core/eager] error: metagenomic classification can only run on unmapped reads. Please supply --bam_discard_unmapped and --bam_unmapped_type 'fastq'."
@@ -519,7 +519,7 @@ if (params.run_metagenomic_screening) {
519519
}
520520
}
521521

522-
// MaltExtract Sanity checking
522+
// MaltExtract validation
523523
if (params.run_maltextract) {
524524

525525
if (params.run_metagenomic_screening && params.metagenomic_tool != 'malt') {
@@ -548,7 +548,7 @@ if (!(workflow.runName ==~ /[a-z]+_[a-z]+/)) {
548548
}
549549

550550
if (workflow.profile.contains('awsbatch')) {
551-
// AWSBatch sanity checking
551+
// AWSBatch validation
552552
if (!params.awsqueue || !params.awsregion) exit 1, "Specify correct --awsqueue and --awsregion parameters on AWSBatch."
553553
// Check outdir paths to be S3 buckets if running on AWSBatch
554554
// related: https://github.com/nextflow-io/nextflow/issues/813
@@ -1802,7 +1802,7 @@ process dedup{
18021802
mv ${bam} ${libraryid}.bam
18031803
fi
18041804
1805-
dedup -i ${libraryid}.bam $treat_merged -o . -u
1805+
dedup -Xmx${task.memory.toGiga()}g -i ${libraryid}.bam $treat_merged -o . -u
18061806
mv *.log dedup.log
18071807
samtools sort -@ ${task.cpus} "${libraryid}"_rmdup.bam -o "${libraryid}"_rmdup.bam
18081808
samtools index "${size}" "${libraryid}"_rmdup.bam
@@ -1814,7 +1814,7 @@ process dedup{
18141814
mv ${bam} ${libraryid}.bam
18151815
fi
18161816
1817-
dedup -i ${libraryid}.bam $treat_merged -o . -u
1817+
dedup -Xmx${task.memory.toGiga()}g -i ${libraryid}.bam $treat_merged -o . -u
18181818
mv *.log dedup.log
18191819
samtools sort -@ ${task.cpus} "${libraryid}"_rmdup.bam -o "${libraryid}"_rmdup.bam
18201820
samtools index "${size}" "${libraryid}"_rmdup.bam
@@ -3058,11 +3058,11 @@ workflow.onComplete {
30583058
log.info "[nf-core/eager] Sent summary e-mail to $email_address (sendmail)"
30593059
} catch (all) {
30603060
// Catch failures and try with plaintext
3061-
if ( mqc_report.size() <= params.max_multiqc_email_size.toBytes() ) {
3062-
[ 'mail', '-s', subject, email_address, '-A', mqc_report ].execute() << email_txt
3063-
} else {
3064-
[ 'mail', '-s', subject, email_address ].execute() << email_txt
3061+
def mail_cmd = [ 'mail', '-s', subject, '--content-type=text', email_address ]
3062+
if ( mqc_report.size() <= params.max_multiqc_email_size.toBytes() ) {
3063+
mail_cmd += [ '-A', mqc_report ]
30653064
}
3065+
mail_cmd.execute() << email_txt
30663066
log.info "[nf-core/eager] Sent summary e-mail to $email_address (mail)"
30673067
}
30683068
}
@@ -3163,6 +3163,9 @@ def extract_data(tsvFile) {
31633163
def r2 = row.R2.matches('NA') ? 'NA' : return_file(row.R2)
31643164
def bam = row.BAM.matches('NA') ? 'NA' : return_file(row.BAM)
31653165

3166+
// check no empty metadata fields
3167+
if (samplename == '' || libraryid == '' || lane == '' || colour == '' || seqtype == '' || seqtype == '' || udg == '' || r1 == '' || r2 == '') exit 1, "[nf-core/eager] error: a field does not contain any information. Ensure all cells are filled or contain 'NA' for optional fields. Check row:\n ${row}"
3168+
31663169
// Check no 'empty' rows
31673170
if (r1.matches('NA') && r2.matches('NA') && bam.matches('NA') && bai.matches('NA')) exit 1, "[nf-core/eager] error: A row in your TSV appears to have all files defined as NA. See --help or documentation under 'running the pipeline' for more information. Check row for: ${samplename}"
31683171

@@ -3239,7 +3242,7 @@ def retrieve_input_paths(input, colour_chem, pe_se, ds_ss, udg_treat, bam_in) {
32393242
Channel
32403243
.fromFilePairs( input )
32413244
.filter { it =~/.*.fastq.gz|.*.fq.gz|.*.fastq|.*.fq/ }
3242-
.ifEmpty { exit 1, "[nf-core/eager] error: Your specified FASTQ read files did not end in: '.fastq.gz', '.fq.gz', '.fastq', or '.fq' " }
3245+
.ifEmpty { exit 1, "[nf-core/eager] error: Files could not be found. Do the specified FASTQ read files end in: '.fastq.gz', '.fq.gz', '.fastq', or '.fq'? Did you forget --single_end?" }
32433246
.map { row -> [ row[0], [ row[1][0], row[1][1] ] ] }
32443247
.ifEmpty { exit 1, "[nf-core/eager] error: --input was empty - no input files supplied!" }
32453248
.into { ch_reads_for_faketsv; ch_reads_for_validate }

0 commit comments

Comments
 (0)