mirror of
https://github.com/MillironX/taxprofiler.git
synced 2024-11-22 08:49:55 +00:00
Add KRONA_CLEANUP process module
This commit is contained in:
parent
a84f693479
commit
87678c127b
1 changed files with 40 additions and 0 deletions
40
modules/local/krona_cleanup.nf
Normal file
40
modules/local/krona_cleanup.nf
Normal file
|
@ -0,0 +1,40 @@
|
|||
process KRONA_CLEANUP {
|
||||
tag "$meta.id"
|
||||
label 'process_low'
|
||||
|
||||
conda (params.enable_conda ? "conda-forge::sed=4.7" : null)
|
||||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
||||
'https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :
|
||||
'biocontainers/biocontainers:v1.2.0_cv1' }"
|
||||
|
||||
input:
|
||||
tuple val(meta), path(krona, stageAs: 'uncleaned.krona.txt')
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.txt"), emit: txt
|
||||
path "versions.yml", emit: versions
|
||||
|
||||
when:
|
||||
task.ext.when == null || task.ext.when
|
||||
|
||||
script:
|
||||
def prefix = task.ext.prefix ?: "${meta.id}"
|
||||
"""
|
||||
# Copy the file to a new name
|
||||
cp ${krona} ${prefix}.txt
|
||||
|
||||
# Remove ugly 'x__' prefixes for each of the taxonomic levels
|
||||
LEVELS=(d k p c o f g s)
|
||||
for L in "\${LEVELS[@]}"; do
|
||||
sed -i "s/\${L}__//g" ${prefix}.txt
|
||||
done
|
||||
|
||||
# Remove underscores that are standing in place of spaces
|
||||
sed -i "s/_/ /g" ${prefix}.txt
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
"${task.process}":
|
||||
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
Loading…
Reference in a new issue