2021-02-01 12:54:08 +00:00
|
|
|
process FASTP {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_medium'
|
|
|
|
|
2021-02-16 23:58:23 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::fastp=0.20.1' : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
|
|
|
'https://depot.galaxyproject.org/singularity/fastp:0.20.1--h8b12597_0' :
|
|
|
|
'quay.io/biocontainers/fastp:0.20.1--h8b12597_0' }"
|
2021-02-01 12:54:08 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
2021-07-21 08:00:48 +00:00
|
|
|
val save_trimmed_fail
|
2021-07-23 09:44:00 +00:00
|
|
|
val save_merged
|
2021-02-01 12:54:08 +00:00
|
|
|
|
|
|
|
output:
|
2021-07-23 09:44:00 +00:00
|
|
|
tuple val(meta), path('*.trim.fastq.gz') , emit: reads
|
|
|
|
tuple val(meta), path('*.json') , emit: json
|
|
|
|
tuple val(meta), path('*.html') , emit: html
|
|
|
|
tuple val(meta), path('*.log') , emit: log
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-07-23 09:44:00 +00:00
|
|
|
tuple val(meta), path('*.fail.fastq.gz') , optional:true, emit: reads_fail
|
|
|
|
tuple val(meta), path('*.merged.fastq.gz'), optional:true, emit: reads_merged
|
2021-02-01 12:54:08 +00:00
|
|
|
|
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2021-02-01 12:54:08 +00:00
|
|
|
// Added soft-links to original fastqs for consistent naming in MultiQC
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-02-01 12:54:08 +00:00
|
|
|
if (meta.single_end) {
|
2021-07-21 08:00:48 +00:00
|
|
|
def fail_fastq = save_trimmed_fail ? "--failed_out ${prefix}.fail.fastq.gz" : ''
|
2021-02-01 12:54:08 +00:00
|
|
|
"""
|
|
|
|
[ ! -f ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz
|
|
|
|
fastp \\
|
|
|
|
--in1 ${prefix}.fastq.gz \\
|
|
|
|
--out1 ${prefix}.trim.fastq.gz \\
|
|
|
|
--thread $task.cpus \\
|
|
|
|
--json ${prefix}.fastp.json \\
|
|
|
|
--html ${prefix}.fastp.html \\
|
|
|
|
$fail_fastq \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-02-01 12:54:08 +00:00
|
|
|
2> ${prefix}.fastp.log
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-02-01 12:54:08 +00:00
|
|
|
"""
|
|
|
|
} else {
|
2021-07-23 09:44:00 +00:00
|
|
|
def fail_fastq = save_trimmed_fail ? "--unpaired1 ${prefix}_1.fail.fastq.gz --unpaired2 ${prefix}_2.fail.fastq.gz" : ''
|
|
|
|
def merge_fastq = save_merged ? "-m --merged_out ${prefix}.merged.fastq.gz" : ''
|
2021-02-01 12:54:08 +00:00
|
|
|
"""
|
|
|
|
[ ! -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
|
|
|
|
fastp \\
|
|
|
|
--in1 ${prefix}_1.fastq.gz \\
|
|
|
|
--in2 ${prefix}_2.fastq.gz \\
|
|
|
|
--out1 ${prefix}_1.trim.fastq.gz \\
|
|
|
|
--out2 ${prefix}_2.trim.fastq.gz \\
|
|
|
|
--json ${prefix}.fastp.json \\
|
|
|
|
--html ${prefix}.fastp.html \\
|
|
|
|
$fail_fastq \\
|
2021-07-23 09:44:00 +00:00
|
|
|
$merge_fastq \\
|
2021-02-01 12:54:08 +00:00
|
|
|
--thread $task.cpus \\
|
|
|
|
--detect_adapter_for_pe \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-02-01 12:54:08 +00:00
|
|
|
2> ${prefix}.fastp.log
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-02-01 12:54:08 +00:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|