diff --git a/modules/cat/cat/main.nf b/modules/cat/cat/main.nf index 0c087270..2efe20a5 100644 --- a/modules/cat/cat/main.nf +++ b/modules/cat/cat/main.nf @@ -18,30 +18,28 @@ process CAT_CAT { def args = task.ext.args ?: '' def args2 = task.ext.args2 ?: '' def file_list = files_in.collect { it.toString() } - if (file_list.size > 1) { - // | input | output | command1 | command2 | - // |-----------|------------|----------|----------| - // | gzipped | gzipped | cat | | - // | ungzipped | ungzipped | cat | | - // | gzipped | ungzipped | zcat | | - // | ungzipped | gzipped | cat | pigz | + // | input | output | command1 | command2 | + // |-----------|------------|----------|----------| + // | gzipped | gzipped | cat | | + // | ungzipped | ungzipped | cat | | + // | gzipped | ungzipped | zcat | | + // | ungzipped | gzipped | cat | pigz | - def in_zip = file_list[0].endsWith('.gz') - def out_zip = file_out.endsWith('.gz') - def command1 = (in_zip && !out_zip) ? 'zcat' : 'cat' - def command2 = (!in_zip && out_zip) ? "| pigz -c -p $task.cpus $args2" : '' - """ - $command1 \\ - $args \\ - ${file_list.join(' ')} \\ - $command2 \\ - > $file_out + def in_zip = file_list[0].endsWith('.gz') + def out_zip = file_out.endsWith('.gz') + def command1 = (in_zip && !out_zip) ? 'zcat' : 'cat' + def command2 = (!in_zip && out_zip) ? "| pigz -c -p $task.cpus $args2" : '' + """ + $command1 \\ + $args \\ + ${file_list.join(' ')} \\ + $command2 \\ + > $file_out - cat <<-END_VERSIONS > versions.yml - "${task.process}": - pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) - END_VERSIONS - """ - } + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) + END_VERSIONS + """ } diff --git a/tests/modules/cat/cat/main.nf b/tests/modules/cat/cat/main.nf index 430c71fa..1fd56851 100644 --- a/tests/modules/cat/cat/main.nf +++ b/tests/modules/cat/cat/main.nf @@ -43,3 +43,12 @@ workflow test_cat_unzipped_zipped { CAT_CAT ( input, 'cat.txt.gz' ) } + +workflow test_cat_one_file_unzipped_zipped { + + input = [ + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true), + ] + + CAT_CAT ( input, 'cat.txt.gz' ) +} diff --git a/tests/modules/cat/cat/test.yml b/tests/modules/cat/cat/test.yml index d7973042..1244d8d2 100644 --- a/tests/modules/cat/cat/test.yml +++ b/tests/modules/cat/cat/test.yml @@ -31,3 +31,11 @@ - cat/cat files: - path: output/cat/cat.txt.gz + +- name: cat one file unzipped zipped + command: nextflow run ./tests/modules/cat/cat -entry test_cat_one_file_unzipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/cat/cat/nextflow.config + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt.gz