mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
CAT: Use meta map and supply output file name via modules.config (#1446)
* Use meta map and supply output file name via modules.config * Remove all def declarations to make it work * update tests & remove extra . * fix ze tests * update meta.yml with meta map info * add tag line now that meta is available
This commit is contained in:
parent
e786457fb0
commit
3d31fa4d04
5 changed files with 49 additions and 29 deletions
|
@ -1,4 +1,5 @@
|
|||
process CAT_CAT {
|
||||
tag "$meta.id"
|
||||
label 'process_low'
|
||||
|
||||
conda (params.enable_conda ? "conda-forge::pigz=2.3.4" : null)
|
||||
|
@ -7,12 +8,11 @@ process CAT_CAT {
|
|||
'quay.io/biocontainers/pigz:2.3.4' }"
|
||||
|
||||
input:
|
||||
path files_in
|
||||
val file_out
|
||||
tuple val(meta), path(files_in)
|
||||
|
||||
output:
|
||||
path "${file_out}*" , emit: file_out
|
||||
path "versions.yml" , emit: versions
|
||||
tuple val(meta), path("${prefix}"), emit: file_out
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
when:
|
||||
task.ext.when == null || task.ext.when
|
||||
|
@ -29,16 +29,18 @@ process CAT_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" : ''
|
||||
// Use input file ending as default
|
||||
prefix = task.ext.prefix ?: "${meta.id}${file_list[0].substring(file_list[0].lastIndexOf('.'))}"
|
||||
out_zip = prefix.endsWith('.gz')
|
||||
in_zip = file_list[0].endsWith('.gz')
|
||||
command1 = (in_zip && !out_zip) ? 'zcat' : 'cat'
|
||||
command2 = (!in_zip && out_zip) ? "| pigz -c -p $task.cpus $args2" : ''
|
||||
"""
|
||||
$command1 \\
|
||||
$args \\
|
||||
${file_list.join(' ')} \\
|
||||
$command2 \\
|
||||
> $file_out
|
||||
> ${prefix}
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
"${task.process}":
|
||||
|
|
|
@ -12,13 +12,15 @@ tools:
|
|||
tool_dev_url: None
|
||||
licence: ["GPL-3.0-or-later"]
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- files_in:
|
||||
type: file
|
||||
description: List of compressed / uncompressed files
|
||||
pattern: "*"
|
||||
- file_out:
|
||||
type: value
|
||||
description: Full name of output file with or without .gz extension
|
||||
|
||||
output:
|
||||
- versions:
|
||||
|
@ -32,3 +34,4 @@ output:
|
|||
|
||||
authors:
|
||||
- "@erikrikarddaniel"
|
||||
- "@FriederikeHanssen"
|
||||
|
|
|
@ -2,53 +2,60 @@
|
|||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { CAT_CAT } from '../../../../modules/cat/cat/main.nf'
|
||||
include { CAT_CAT } from '../../../../modules/cat/cat/main.nf'
|
||||
include { CAT_CAT as CAT_UNZIPPED_ZIPPED } from '../../../../modules/cat/cat/main.nf'
|
||||
include { CAT_CAT as CAT_ZIPPED_UNZIPPED } from '../../../../modules/cat/cat/main.nf'
|
||||
|
||||
workflow test_cat_unzipped_unzipped {
|
||||
|
||||
input = [
|
||||
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)
|
||||
[ id:'test', single_end:true ], // meta map
|
||||
[ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true) ]
|
||||
]
|
||||
|
||||
CAT_CAT ( input, 'cat.txt' )
|
||||
CAT_CAT ( input )
|
||||
}
|
||||
|
||||
workflow test_cat_zipped_zipped {
|
||||
|
||||
input = [
|
||||
file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)
|
||||
[ id:'test', single_end:true ], // meta map
|
||||
[file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)]
|
||||
]
|
||||
|
||||
CAT_CAT ( input, 'cat.txt.gz' )
|
||||
CAT_CAT ( input )
|
||||
}
|
||||
|
||||
workflow test_cat_zipped_unzipped {
|
||||
|
||||
input = [
|
||||
file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)
|
||||
[ id:'test', single_end:true ], // meta map
|
||||
[file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)]
|
||||
]
|
||||
|
||||
CAT_CAT ( input, 'cat.txt' )
|
||||
CAT_ZIPPED_UNZIPPED ( input )
|
||||
}
|
||||
|
||||
workflow test_cat_unzipped_zipped {
|
||||
|
||||
input = [
|
||||
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)
|
||||
[ id:'test', single_end:true ], // meta map
|
||||
[file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)]
|
||||
]
|
||||
|
||||
CAT_CAT ( input, 'cat.txt.gz' )
|
||||
CAT_UNZIPPED_ZIPPED ( input )
|
||||
}
|
||||
|
||||
workflow test_cat_one_file_unzipped_zipped {
|
||||
|
||||
input = [
|
||||
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
|
||||
[ id:'test', single_end:true ], // meta map
|
||||
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
|
||||
]
|
||||
|
||||
CAT_CAT ( input, 'cat.txt.gz' )
|
||||
CAT_UNZIPPED_ZIPPED ( input )
|
||||
}
|
||||
|
|
|
@ -2,4 +2,12 @@ process {
|
|||
|
||||
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
|
||||
|
||||
withName: CAT_UNZIPPED_ZIPPED {
|
||||
ext.prefix = 'cat.txt.gz'
|
||||
}
|
||||
|
||||
withName: CAT_ZIPPED_UNZIPPED {
|
||||
ext.prefix = 'cat.txt'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
- cat
|
||||
- cat/cat
|
||||
files:
|
||||
- path: output/cat/cat.txt
|
||||
- path: output/cat/test.fasta
|
||||
md5sum: f44b33a0e441ad58b2d3700270e2dbe2
|
||||
|
||||
- name: cat zipped zipped
|
||||
|
@ -13,7 +13,7 @@
|
|||
- cat
|
||||
- cat/cat
|
||||
files:
|
||||
- path: output/cat/cat.txt.gz
|
||||
- path: output/cat/test.gz
|
||||
|
||||
- name: cat zipped unzipped
|
||||
command: nextflow run ./tests/modules/cat/cat -entry test_cat_zipped_unzipped -c ./tests/config/nextflow.config -c ./tests/modules/cat/cat/nextflow.config
|
||||
|
|
Loading…
Reference in a new issue