bugfix: when there is a single input file, stageAs("?/*) returns the path directly, not in a list (#2114)

* bugfix: when there is a single input file, stageAs("?/*) returns the path directly, not in a list

* Added a test

* Added a test

* Added MD5 checksum

Co-authored-by: nvnieuwk <101190534+nvnieuwk@users.noreply.github.com>
This commit is contained in:
Matthieu Muffato 2022-09-28 13:28:52 +01:00 committed by GitHub
parent 83b05a8dc0
commit e9bc33485e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 4 deletions

View file

@ -20,7 +20,7 @@ process CAT_FASTQ {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def readList = reads.collect{ it.toString() }
def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()]
if (meta.single_end) {
if (readList.size >= 1) {
"""
@ -51,7 +51,7 @@ process CAT_FASTQ {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def readList = reads.collect{ it.toString() }
def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()]
if (meta.single_end) {
if (readList.size > 1) {
"""

View file

@ -25,7 +25,7 @@ process SAMTOOLS_MERGE {
script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def file_type = input_files[0].getExtension()
def file_type = input_files instanceof List ? input_files[0].getExtension() : input_files.getExtension()
def reference = fasta ? "--reference ${fasta}" : ""
"""
samtools \\
@ -44,7 +44,7 @@ process SAMTOOLS_MERGE {
stub:
prefix = task.ext.suffix ? "${meta.id}${task.ext.suffix}" : "${meta.id}"
def file_type = input_files[0].getExtension()
def file_type = input_files instanceof List ? input_files[0].getExtension() : input_files.getExtension()
"""
touch ${prefix}.${file_type}

View file

@ -47,3 +47,12 @@ workflow test_cat_fastq_paired_end_same_name {
CAT_FASTQ ( input )
}
workflow test_cat_fastq_single_end_single_file {
input = [
[ id:'test', single_end:true ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)]
]
CAT_FASTQ ( input )
}

View file

@ -38,6 +38,15 @@
- path: ./output/cat/test_2.merged.fastq.gz
md5sum: fe9f266f43a6fc3dcab690a18419a56e
- name: cat fastq single-end-single-file
command: nextflow run ./tests/modules/cat/fastq -entry test_cat_fastq_single_end_single_file -c ./tests/config/nextflow.config -c ./tests/modules/cat/fastq/nextflow.config
tags:
- cat
- cat/fastq
files:
- path: ./output/cat/test.merged.fastq.gz
md5sum: e325ef7deb4023447a1f074e285761af
- name: cat fastq single-end stub
command: nextflow run ./tests/modules/cat/fastq -entry test_cat_fastq_single_end -c ./tests/config/nextflow.config -c ./tests/modules/cat/fastq/nextflow.config -stub-run
tags:

View file

@ -27,3 +27,13 @@ workflow test_samtools_merge_cram {
fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
SAMTOOLS_MERGE ( input, fasta, fai )
}
workflow test_samtools_merge_single_file {
input = [ [ id: 'test' ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'], checkIfExists: true),
]
]
SAMTOOLS_MERGE ( input, [], [] )
}

View file

@ -13,3 +13,12 @@
- samtools/merge
files:
- path: output/samtools/test.cram
- name: samtools merge test_samtools_merge_single_file
command: nextflow run ./tests/modules/samtools/merge -entry test_samtools_merge_single_file -c ./tests/config/nextflow.config -c ./tests/modules/samtools/merge/nextflow.config
tags:
- samtools
- samtools/merge
files:
- path: output/samtools/test.bam
md5sum: 6e38ae132fadae4cb4915814d6f872b2