2021-01-29 18:29:32 +00:00
|
|
|
process BOWTIE2_ALIGN {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
|
2022-01-13 11:59:33 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::bowtie2=2.4.4 bioconda::samtools=1.14 conda-forge::pigz=2.6' : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-01-13 11:59:33 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/mulled-v2-ac74a7f02cebcfcc07d8e8d1d750af9c83b4d45a:4d235f41348a00533f18e47c9669f1ecb327f629-0' :
|
|
|
|
'quay.io/biocontainers/mulled-v2-ac74a7f02cebcfcc07d8e8d1d750af9c83b4d45a:4d235f41348a00533f18e47c9669f1ecb327f629-0' }"
|
2021-01-29 18:29:32 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
path index
|
2022-01-07 17:52:39 +00:00
|
|
|
val save_unaligned
|
2021-01-29 18:29:32 +00:00
|
|
|
|
|
|
|
output:
|
2022-01-13 11:59:33 +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
|
|
|
|
path "versions.yml" , emit: versions
|
2021-01-29 18:29:32 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-01-29 18:29:32 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
|
|
|
def args2 = task.ext.args2 ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-01-29 18:29:32 +00:00
|
|
|
if (meta.single_end) {
|
2022-01-07 17:52:39 +00:00
|
|
|
def unaligned = save_unaligned ? "--un-gz ${prefix}.unmapped.fastq.gz" : ''
|
2021-01-29 18:29:32 +00:00
|
|
|
"""
|
|
|
|
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed 's/.rev.1.bt2//'`
|
|
|
|
bowtie2 \\
|
|
|
|
-x \$INDEX \\
|
|
|
|
-U $reads \\
|
2021-09-30 08:26:52 +00:00
|
|
|
--threads $task.cpus \\
|
2021-01-29 18:29:32 +00:00
|
|
|
$unaligned \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-01-29 18:29:32 +00:00
|
|
|
2> ${prefix}.bowtie2.log \\
|
2021-11-26 07:58:40 +00:00
|
|
|
| samtools view -@ $task.cpus $args2 -bhS -o ${prefix}.bam -
|
2021-01-29 18:29:32 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
|
2021-09-28 13:37:47 +00:00
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
|
|
|
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-01-29 18:29:32 +00:00
|
|
|
"""
|
|
|
|
} else {
|
2022-01-07 17:52:39 +00:00
|
|
|
def unaligned = save_unaligned ? "--un-conc-gz ${prefix}.unmapped.fastq.gz" : ''
|
2021-01-29 18:29:32 +00:00
|
|
|
"""
|
|
|
|
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed 's/.rev.1.bt2//'`
|
|
|
|
bowtie2 \\
|
|
|
|
-x \$INDEX \\
|
|
|
|
-1 ${reads[0]} \\
|
|
|
|
-2 ${reads[1]} \\
|
2021-09-30 08:26:52 +00:00
|
|
|
--threads $task.cpus \\
|
2021-01-29 18:29:32 +00:00
|
|
|
$unaligned \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-01-29 18:29:32 +00:00
|
|
|
2> ${prefix}.bowtie2.log \\
|
2021-11-26 07:58:40 +00:00
|
|
|
| samtools view -@ $task.cpus $args2 -bhS -o ${prefix}.bam -
|
2021-01-29 18:29:32 +00:00
|
|
|
|
|
|
|
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
|
2021-09-28 13:37:47 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
|
2021-09-28 13:37:47 +00:00
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
|
|
|
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-01-29 18:29:32 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|