kkonganti@1
|
1 process FASTP {
|
kkonganti@1
|
2 tag "$meta.id"
|
kkonganti@1
|
3 label 'process_low'
|
kkonganti@1
|
4
|
kkonganti@1
|
5 module (params.enable_module ? "${params.swmodulepath}${params.fs}fastp${params.fs}0.23.2" : null)
|
kkonganti@1
|
6 conda (params.enable_conda ? "bioconda::fastp=0.23.2 conda-forge::isa-l" : null)
|
kkonganti@1
|
7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
kkonganti@1
|
8 'https://depot.galaxyproject.org/singularity/fastp:0.23.2--h79da9fb_0' :
|
kkonganti@1
|
9 'quay.io/biocontainers/fastp:0.23.2--h79da9fb_0' }"
|
kkonganti@1
|
10
|
kkonganti@1
|
11 input:
|
kkonganti@1
|
12 tuple val(meta), path(reads)
|
kkonganti@1
|
13
|
kkonganti@1
|
14 output:
|
kkonganti@1
|
15 tuple val(meta), path('*.fastp.fastq.gz') , emit: passed_reads, optional: true
|
kkonganti@1
|
16 tuple val(meta), path('*.fail.fastq.gz') , emit: failed_reads, optional: true
|
kkonganti@1
|
17 tuple val(meta), path('*.merged.fastq.gz'), emit: merged_reads, optional: true
|
kkonganti@1
|
18 tuple val(meta), path('*.json') , emit: json
|
kkonganti@1
|
19 tuple val(meta), path('*.html') , emit: html
|
kkonganti@1
|
20 tuple val(meta), path('*.log') , emit: log
|
kkonganti@1
|
21 path "versions.yml" , emit: versions
|
kkonganti@1
|
22
|
kkonganti@1
|
23 when:
|
kkonganti@1
|
24 task.ext.when == null || task.ext.when
|
kkonganti@1
|
25
|
kkonganti@1
|
26 script:
|
kkonganti@1
|
27 def args = task.ext.args ?: ''
|
kkonganti@1
|
28 def prefix = task.ext.prefix ?: "${meta.id}"
|
kkonganti@1
|
29 def fail_fastq = params.fastp_failed_out && meta.single_end ? "--failed_out ${prefix}.fail.fastq.gz" : params.fastp_failed_out && !meta.single_end ? "--unpaired1 ${prefix}_1.fail.fastq.gz --unpaired2 ${prefix}_2.fail.fastq.gz" : ''
|
kkonganti@1
|
30 // Added soft-links to original fastqs for consistent naming in MultiQC
|
kkonganti@1
|
31 // Use single ended for interleaved. Add --interleaved_in in config.
|
kkonganti@1
|
32 if ( task.ext.args?.contains('--interleaved_in') ) {
|
kkonganti@1
|
33 """
|
kkonganti@1
|
34 [ ! -f ${prefix}.fastq.gz ] && ln -sf $reads ${prefix}.fastq.gz
|
kkonganti@1
|
35
|
kkonganti@1
|
36 fastp \\
|
kkonganti@1
|
37 --stdout \\
|
kkonganti@1
|
38 --in1 ${prefix}.fastq.gz \\
|
kkonganti@1
|
39 --thread $task.cpus \\
|
kkonganti@1
|
40 --json ${prefix}.fastp.json \\
|
kkonganti@1
|
41 --html ${prefix}.fastp.html \\
|
kkonganti@1
|
42 $fail_fastq \\
|
kkonganti@1
|
43 $args \\
|
kkonganti@1
|
44 2> ${prefix}.fastp.log \\
|
kkonganti@1
|
45 | gzip -c > ${prefix}.fastp.fastq.gz
|
kkonganti@1
|
46
|
kkonganti@1
|
47 cat <<-END_VERSIONS > versions.yml
|
kkonganti@1
|
48 "${task.process}":
|
kkonganti@1
|
49 fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
|
kkonganti@1
|
50 END_VERSIONS
|
kkonganti@1
|
51 """
|
kkonganti@1
|
52 } else if (meta.single_end) {
|
kkonganti@1
|
53 """
|
kkonganti@1
|
54 [ ! -f ${prefix}.fastq.gz ] && ln -sf $reads ${prefix}.fastq.gz
|
kkonganti@1
|
55
|
kkonganti@1
|
56 fastp \\
|
kkonganti@1
|
57 --in1 ${prefix}.fastq.gz \\
|
kkonganti@1
|
58 --out1 ${prefix}.fastp.fastq.gz \\
|
kkonganti@1
|
59 --thread $task.cpus \\
|
kkonganti@1
|
60 --json ${prefix}.fastp.json \\
|
kkonganti@1
|
61 --html ${prefix}.fastp.html \\
|
kkonganti@1
|
62 $fail_fastq \\
|
kkonganti@1
|
63 $args \\
|
kkonganti@1
|
64 2> ${prefix}.fastp.log
|
kkonganti@1
|
65
|
kkonganti@1
|
66 cat <<-END_VERSIONS > versions.yml
|
kkonganti@1
|
67 "${task.process}":
|
kkonganti@1
|
68 fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
|
kkonganti@1
|
69 END_VERSIONS
|
kkonganti@1
|
70 """
|
kkonganti@1
|
71 } else {
|
kkonganti@1
|
72 def merge_fastq = params.fastp_merged_out ? "-m --merged_out ${prefix}.merged.fastq.gz" : ''
|
kkonganti@1
|
73 """
|
kkonganti@1
|
74 [ ! -f ${prefix}_1.fastq.gz ] && ln -sf ${reads[0]} ${prefix}_1.fastq.gz
|
kkonganti@1
|
75 [ ! -f ${prefix}_2.fastq.gz ] && ln -sf ${reads[1]} ${prefix}_2.fastq.gz
|
kkonganti@1
|
76 fastp \\
|
kkonganti@1
|
77 --in1 ${prefix}_1.fastq.gz \\
|
kkonganti@1
|
78 --in2 ${prefix}_2.fastq.gz \\
|
kkonganti@1
|
79 --out1 ${prefix}_1.fastp.fastq.gz \\
|
kkonganti@1
|
80 --out2 ${prefix}_2.fastp.fastq.gz \\
|
kkonganti@1
|
81 --json ${prefix}.fastp.json \\
|
kkonganti@1
|
82 --html ${prefix}.fastp.html \\
|
kkonganti@1
|
83 $fail_fastq \\
|
kkonganti@1
|
84 $merge_fastq \\
|
kkonganti@1
|
85 --thread $task.cpus \\
|
kkonganti@1
|
86 --detect_adapter_for_pe \\
|
kkonganti@1
|
87 $args \\
|
kkonganti@1
|
88 2> ${prefix}.fastp.log
|
kkonganti@1
|
89
|
kkonganti@1
|
90 cat <<-END_VERSIONS > versions.yml
|
kkonganti@1
|
91 "${task.process}":
|
kkonganti@1
|
92 fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
|
kkonganti@1
|
93 END_VERSIONS
|
kkonganti@1
|
94 """
|
kkonganti@1
|
95 }
|
kkonganti@1
|
96 } |