1
0
Fork 0
mirror of https://github.com/MillironX/taxprofiler.git synced 2024-11-15 10:23:08 +00:00
taxprofiler/modules/nf-core/fastp/main.nf

104 lines
3.8 KiB
Text
Raw Normal View History

process FASTP {
tag "$meta.id"
label 'process_medium'
conda "bioconda::fastp=0.23.2"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/fastp:0.23.2--h79da9fb_0' :
'quay.io/biocontainers/fastp:0.23.2--h79da9fb_0' }"
input:
tuple val(meta), path(reads)
2022-11-02 11:39:34 +00:00
path adapter_fasta
val save_trimmed_fail
val save_merged
output:
2022-09-08 06:08:36 +00:00
tuple val(meta), path('*.fastp.fastq.gz') , optional:true, emit: reads
tuple val(meta), path('*.json') , emit: json
tuple val(meta), path('*.html') , emit: html
tuple val(meta), path('*.log') , emit: log
path "versions.yml" , emit: versions
tuple val(meta), path('*.fail.fastq.gz') , optional:true, emit: reads_fail
tuple val(meta), path('*.merged.fastq.gz'), optional:true, emit: reads_merged
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
2022-11-02 11:39:34 +00:00
def adapter_list = adapter_fasta ? "--adapter_fasta ${adapter_fasta}" : ""
2022-09-09 09:12:47 +00:00
def fail_fastq = save_trimmed_fail && meta.single_end ? "--failed_out ${prefix}.fail.fastq.gz" : save_trimmed_fail && !meta.single_end ? "--unpaired1 ${prefix}_1.fail.fastq.gz --unpaired2 ${prefix}_2.fail.fastq.gz" : ''
// Added soft-links to original fastqs for consistent naming in MultiQC
2022-09-08 06:08:36 +00:00
// Use single ended for interleaved. Add --interleaved_in in config.
2022-09-09 09:12:47 +00:00
if ( task.ext.args?.contains('--interleaved_in') ) {
"""
2022-09-08 06:08:36 +00:00
[ ! -f ${prefix}.fastq.gz ] && ln -sf $reads ${prefix}.fastq.gz
2022-09-09 09:12:47 +00:00
fastp \\
2022-09-08 06:08:36 +00:00
--stdout \\
--in1 ${prefix}.fastq.gz \\
--thread $task.cpus \\
--json ${prefix}.fastp.json \\
--html ${prefix}.fastp.html \\
2022-11-02 11:39:34 +00:00
$adapter_list \\
$fail_fastq \\
$args \\
2022-09-08 06:08:36 +00:00
2> ${prefix}.fastp.log \\
| gzip -c > ${prefix}.fastp.fastq.gz
2022-09-09 09:12:47 +00:00
cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
END_VERSIONS
"""
} else if (meta.single_end) {
"""
[ ! -f ${prefix}.fastq.gz ] && ln -sf $reads ${prefix}.fastq.gz
fastp \\
--stdout \\
--in1 ${prefix}.fastq.gz \\
--out1 ${prefix}.fastp.fastq.gz \\
--thread $task.cpus \\
--json ${prefix}.fastp.json \\
--html ${prefix}.fastp.html \\
2022-11-02 11:39:34 +00:00
$adapter_list \\
2022-09-09 09:12:47 +00:00
$fail_fastq \\
$args \\
2> ${prefix}.fastp.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
END_VERSIONS
"""
} else {
def merge_fastq = save_merged ? "-m --merged_out ${prefix}.merged.fastq.gz" : ''
"""
2022-09-08 06:08:36 +00:00
[ ! -f ${prefix}_1.fastq.gz ] && ln -sf ${reads[0]} ${prefix}_1.fastq.gz
[ ! -f ${prefix}_2.fastq.gz ] && ln -sf ${reads[1]} ${prefix}_2.fastq.gz
fastp \\
--in1 ${prefix}_1.fastq.gz \\
--in2 ${prefix}_2.fastq.gz \\
2022-09-08 06:08:36 +00:00
--out1 ${prefix}_1.fastp.fastq.gz \\
--out2 ${prefix}_2.fastp.fastq.gz \\
--json ${prefix}.fastp.json \\
--html ${prefix}.fastp.html \\
2022-11-02 11:39:34 +00:00
$adapter_list \\
$fail_fastq \\
$merge_fastq \\
--thread $task.cpus \\
--detect_adapter_for_pe \\
$args \\
2> ${prefix}.fastp.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
END_VERSIONS
"""
}
}