Editing the CAT/CAT module to handle single files (#1196)

* Removed if-statement to only run on more than 1 file, now it will run on single files as well.

* Added a test for running the cat_cat module on a single file.

* Created a new test.yml with nf-core modules create-test-yml -t cat/cat

* Edited test.yml to not include paths and md5sums for versions.yml, and also removed sometimes variable md5sums
This commit is contained in:
emnilsson 2022-01-06 17:41:36 +01:00 committed by GitHub
parent 2d4b0f7787
commit c4549c0ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 23 deletions

View file

@ -18,30 +18,28 @@ process CAT_CAT {
def args = task.ext.args ?: '' def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: '' def args2 = task.ext.args2 ?: ''
def file_list = files_in.collect { it.toString() } def file_list = files_in.collect { it.toString() }
if (file_list.size > 1) {
// | input | output | command1 | command2 | // | input | output | command1 | command2 |
// |-----------|------------|----------|----------| // |-----------|------------|----------|----------|
// | gzipped | gzipped | cat | | // | gzipped | gzipped | cat | |
// | ungzipped | ungzipped | cat | | // | ungzipped | ungzipped | cat | |
// | gzipped | ungzipped | zcat | | // | gzipped | ungzipped | zcat | |
// | ungzipped | gzipped | cat | pigz | // | ungzipped | gzipped | cat | pigz |
def in_zip = file_list[0].endsWith('.gz') def in_zip = file_list[0].endsWith('.gz')
def out_zip = file_out.endsWith('.gz') def out_zip = file_out.endsWith('.gz')
def command1 = (in_zip && !out_zip) ? 'zcat' : 'cat' def command1 = (in_zip && !out_zip) ? 'zcat' : 'cat'
def command2 = (!in_zip && out_zip) ? "| pigz -c -p $task.cpus $args2" : '' def command2 = (!in_zip && out_zip) ? "| pigz -c -p $task.cpus $args2" : ''
""" """
$command1 \\ $command1 \\
$args \\ $args \\
${file_list.join(' ')} \\ ${file_list.join(' ')} \\
$command2 \\ $command2 \\
> $file_out > $file_out
cat <<-END_VERSIONS > versions.yml cat <<-END_VERSIONS > versions.yml
"${task.process}": "${task.process}":
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS END_VERSIONS
""" """
}
} }

View file

@ -43,3 +43,12 @@ workflow test_cat_unzipped_zipped {
CAT_CAT ( input, 'cat.txt.gz' ) 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' )
}

View file

@ -31,3 +31,11 @@
- cat/cat - cat/cat
files: files:
- path: output/cat/cat.txt.gz - 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