2021-11-26 07:58:40 +00:00
|
|
|
def VERSION = '2.2.0' // Version information not provided by tool on CLI
|
2020-09-10 15:45:11 +00:00
|
|
|
|
|
|
|
process HISAT2_ALIGN {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
|
2022-04-11 12:26:28 +00:00
|
|
|
conda (params.enable_conda ? "bioconda::hisat2=2.2.0 bioconda::samtools=1.15.1" : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-04-11 12:26:28 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/mulled-v2-a97e90b3b802d1da3d6958e0867610c718cb5eb1:0e773bb207600fcb4d38202226eb20a33c7909b6-0' :
|
|
|
|
'quay.io/biocontainers/mulled-v2-a97e90b3b802d1da3d6958e0867610c718cb5eb1:0e773bb207600fcb4d38202226eb20a33c7909b6-0' }"
|
2020-12-17 23:50:24 +00:00
|
|
|
|
2020-09-10 15:45:11 +00:00
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
path index
|
|
|
|
path splicesites
|
2020-12-17 23:50:24 +00:00
|
|
|
|
2020-09-10 15:45:11 +00:00
|
|
|
output:
|
2021-11-26 07:58:40 +00:00
|
|
|
tuple val(meta), path("*.bam") , emit: bam
|
|
|
|
tuple val(meta), path("*.log") , emit: summary
|
2020-09-10 15:45:11 +00:00
|
|
|
tuple val(meta), path("*fastq.gz"), optional:true, emit: fastq
|
2021-11-26 07:58:40 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2020-09-10 15:45:11 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2020-09-10 15:45:11 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2020-09-10 15:45:11 +00:00
|
|
|
|
|
|
|
def strandedness = ''
|
|
|
|
if (meta.strandedness == 'forward') {
|
|
|
|
strandedness = meta.single_end ? '--rna-strandness F' : '--rna-strandness FR'
|
|
|
|
} else if (meta.strandedness == 'reverse') {
|
|
|
|
strandedness = meta.single_end ? '--rna-strandness R' : '--rna-strandness RF'
|
|
|
|
}
|
2020-09-18 09:39:41 +00:00
|
|
|
def seq_center = params.seq_center ? "--rg-id ${prefix} --rg SM:$prefix --rg CN:${params.seq_center.replaceAll('\\s','_')}" : "--rg-id ${prefix} --rg SM:$prefix"
|
2020-09-10 15:45:11 +00:00
|
|
|
if (meta.single_end) {
|
|
|
|
def unaligned = params.save_unaligned ? "--un-gz ${prefix}.unmapped.fastq.gz" : ''
|
|
|
|
"""
|
|
|
|
INDEX=`find -L ./ -name "*.1.ht2" | sed 's/.1.ht2//'`
|
|
|
|
hisat2 \\
|
|
|
|
-x \$INDEX \\
|
|
|
|
-U $reads \\
|
|
|
|
$strandedness \\
|
|
|
|
--known-splicesite-infile $splicesites \\
|
|
|
|
--summary-file ${prefix}.hisat2.summary.log \\
|
|
|
|
--threads $task.cpus \\
|
|
|
|
$seq_center \\
|
|
|
|
$unaligned \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2020-09-10 15:45:11 +00:00
|
|
|
| samtools view -bS -F 4 -F 256 - > ${prefix}.bam
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
hisat2: $VERSION
|
2021-09-28 13:37:47 +00:00
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2020-09-10 15:45:11 +00:00
|
|
|
"""
|
|
|
|
} else {
|
|
|
|
def unaligned = params.save_unaligned ? "--un-conc-gz ${prefix}.unmapped.fastq.gz" : ''
|
|
|
|
"""
|
|
|
|
INDEX=`find -L ./ -name "*.1.ht2" | sed 's/.1.ht2//'`
|
|
|
|
hisat2 \\
|
|
|
|
-x \$INDEX \\
|
|
|
|
-1 ${reads[0]} \\
|
|
|
|
-2 ${reads[1]} \\
|
|
|
|
$strandedness \\
|
|
|
|
--known-splicesite-infile $splicesites \\
|
|
|
|
--summary-file ${prefix}.hisat2.summary.log \\
|
|
|
|
--threads $task.cpus \\
|
|
|
|
$seq_center \\
|
|
|
|
$unaligned \\
|
|
|
|
--no-mixed \\
|
|
|
|
--no-discordant \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2020-09-10 15:45:11 +00:00
|
|
|
| samtools view -bS -F 4 -F 8 -F 256 - > ${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
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
hisat2: $VERSION
|
2021-09-28 13:37:47 +00:00
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2020-09-10 15:45:11 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|