1
0
Fork 0
mirror of https://github.com/MillironX/taxprofiler.git synced 2024-11-15 13:03:09 +00:00
taxprofiler/modules/nf-core/bowtie2/align/main.nf

72 lines
2.5 KiB
Text
Raw Normal View History

2022-04-03 05:58:40 +00:00
process BOWTIE2_ALIGN {
tag "$meta.id"
2022-09-08 06:08:36 +00:00
label "process_high"
2022-04-03 05:58:40 +00:00
conda "bioconda::bowtie2=2.4.4 bioconda::samtools=1.16.1 conda-forge::pigz=2.6"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-ac74a7f02cebcfcc07d8e8d1d750af9c83b4d45a:a0ffedb52808e102887f6ce600d092675bf3528a-0' :
'quay.io/biocontainers/mulled-v2-ac74a7f02cebcfcc07d8e8d1d750af9c83b4d45a:a0ffedb52808e102887f6ce600d092675bf3528a-0' }"
2022-04-03 05:58:40 +00:00
input:
tuple val(meta) , path(reads)
tuple val(meta2), path(index)
2022-04-03 05:58:40 +00:00
val save_unaligned
2022-09-08 06:08:36 +00:00
val sort_bam
2022-04-03 05:58:40 +00:00
output:
2022-09-08 06:08:36 +00:00
tuple val(meta), path("*.bam") , emit: bam
tuple val(meta), path("*.log") , emit: log
tuple val(meta), path("*fastq.gz"), emit: fastq, optional:true
2022-04-03 05:58:40 +00:00
path "versions.yml" , emit: versions
when:
task.ext.when == null || task.ext.when
script:
2022-09-08 06:08:36 +00:00
def args = task.ext.args ?: ""
def args2 = task.ext.args2 ?: ""
2022-04-03 05:58:40 +00:00
def prefix = task.ext.prefix ?: "${meta.id}"
2022-09-08 06:08:36 +00:00
def unaligned = ""
def reads_args = ""
if (meta.single_end) {
unaligned = save_unaligned ? "--un-gz ${prefix}.unmapped.fastq.gz" : ""
reads_args = "-U ${reads}"
2022-04-03 05:58:40 +00:00
} else {
2022-09-08 06:08:36 +00:00
unaligned = save_unaligned ? "--un-conc-gz ${prefix}.unmapped.fastq.gz" : ""
reads_args = "-1 ${reads[0]} -2 ${reads[1]}"
}
2022-04-03 05:58:40 +00:00
2022-09-08 06:08:36 +00:00
def samtools_command = sort_bam ? 'sort' : 'view'
2022-04-03 05:58:40 +00:00
2022-09-08 06:08:36 +00:00
"""
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/\\.rev.1.bt2\$//"`
[ -z "\$INDEX" ] && INDEX=`find -L ./ -name "*.rev.1.bt2l" | sed "s/\\.rev.1.bt2l\$//"`
2022-09-08 06:08:36 +00:00
[ -z "\$INDEX" ] && echo "Bowtie2 index files not found" 1>&2 && exit 1
bowtie2 \\
-x \$INDEX \\
$reads_args \\
--threads $task.cpus \\
$unaligned \\
$args \\
2> ${prefix}.bowtie2.log \\
| samtools $samtools_command $args2 --threads $task.cpus -o ${prefix}.bam -
if [ -f ${prefix}.unmapped.fastq.1.gz ]; then
mv ${prefix}.unmapped.fastq.1.gz ${prefix}.unmapped_1.fastq.gz
fi
if [ -f ${prefix}.unmapped.fastq.2.gz ]; then
mv ${prefix}.unmapped.fastq.2.gz ${prefix}.unmapped_2.fastq.gz
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
2022-04-03 05:58:40 +00:00
}