2020-09-10 15:45:11 +00:00
|
|
|
// Import generic module functions
|
2021-09-27 08:41:24 +00:00
|
|
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
2020-09-10 15:45:11 +00:00
|
|
|
|
2020-10-14 17:29:50 +00:00
|
|
|
params.options = [:]
|
2021-03-15 12:16:43 +00:00
|
|
|
options = initOptions(params.options)
|
2020-10-14 17:29:50 +00:00
|
|
|
|
2020-09-10 15:45:11 +00:00
|
|
|
process TRIMGALORE {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
publishDir "${params.outdir}",
|
|
|
|
mode: params.publish_dir_mode,
|
2021-04-09 16:23:56 +00:00
|
|
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
|
2020-09-10 15:45:11 +00:00
|
|
|
|
2021-07-28 08:10:44 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::trim-galore=0.6.7' : null)
|
2020-12-13 23:41:53 +00:00
|
|
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
2021-07-28 08:10:44 +00:00
|
|
|
container "https://depot.galaxyproject.org/singularity/trim-galore:0.6.7--hdfd78af_0"
|
2020-12-13 23:41:53 +00:00
|
|
|
} else {
|
2021-07-28 08:10:44 +00:00
|
|
|
container "quay.io/biocontainers/trim-galore:0.6.7--hdfd78af_0"
|
2020-12-13 23:41:53 +00:00
|
|
|
}
|
2020-09-10 15:45:11 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.fq.gz") , emit: reads
|
|
|
|
tuple val(meta), path("*report.txt"), emit: log
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2020-09-10 15:45:11 +00:00
|
|
|
|
|
|
|
tuple val(meta), path("*.html"), emit: html optional true
|
|
|
|
tuple val(meta), path("*.zip") , emit: zip optional true
|
|
|
|
|
|
|
|
script:
|
|
|
|
// Calculate number of --cores for TrimGalore based on value of task.cpus
|
|
|
|
// See: https://github.com/FelixKrueger/TrimGalore/blob/master/Changelog.md#version-060-release-on-1-mar-2019
|
|
|
|
// See: https://github.com/nf-core/atacseq/pull/65
|
|
|
|
def cores = 1
|
|
|
|
if (task.cpus) {
|
|
|
|
cores = (task.cpus as int) - 4
|
|
|
|
if (meta.single_end) cores = (task.cpus as int) - 3
|
|
|
|
if (cores < 1) cores = 1
|
|
|
|
if (cores > 4) cores = 4
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clipping presets have to be evaluated in the context of SE/PE
|
|
|
|
def c_r1 = params.clip_r1 > 0 ? "--clip_r1 ${params.clip_r1}" : ''
|
|
|
|
def c_r2 = params.clip_r2 > 0 ? "--clip_r2 ${params.clip_r2}" : ''
|
|
|
|
def tpc_r1 = params.three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${params.three_prime_clip_r1}" : ''
|
|
|
|
def tpc_r2 = params.three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${params.three_prime_clip_r2}" : ''
|
|
|
|
|
|
|
|
// Added soft-links to original fastqs for consistent naming in MultiQC
|
2020-10-14 17:29:50 +00:00
|
|
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
2020-09-10 15:45:11 +00:00
|
|
|
if (meta.single_end) {
|
|
|
|
"""
|
|
|
|
[ ! -f ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz
|
|
|
|
trim_galore \\
|
2020-10-14 17:29:50 +00:00
|
|
|
$options.args \\
|
2020-09-10 15:45:11 +00:00
|
|
|
--cores $cores \\
|
|
|
|
--gzip \\
|
|
|
|
$c_r1 \\
|
|
|
|
$tpc_r1 \\
|
|
|
|
${prefix}.fastq.gz
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
2021-09-27 21:10:37 +00:00
|
|
|
${getSoftwareName(task.process)}: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
|
|
|
|
cutadapt: \$(cutadapt --version)
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2020-09-10 15:45:11 +00:00
|
|
|
"""
|
|
|
|
} else {
|
|
|
|
"""
|
|
|
|
[ ! -f ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz
|
|
|
|
[ ! -f ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz
|
|
|
|
trim_galore \\
|
2020-10-14 17:29:50 +00:00
|
|
|
$options.args \\
|
2020-09-10 15:45:11 +00:00
|
|
|
--cores $cores \\
|
|
|
|
--paired \\
|
|
|
|
--gzip \\
|
|
|
|
$c_r1 \\
|
|
|
|
$c_r2 \\
|
|
|
|
$tpc_r1 \\
|
|
|
|
$tpc_r2 \\
|
|
|
|
${prefix}_1.fastq.gz \\
|
|
|
|
${prefix}_2.fastq.gz
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
2021-09-27 21:10:37 +00:00
|
|
|
${getSoftwareName(task.process)}: \$(echo \$(trim_galore --version 2>&1) | sed 's/^.*version //; s/Last.*\$//')
|
|
|
|
cutadapt: \$(cutadapt --version)
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2020-09-10 15:45:11 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|