|
1 | 1 | process FASTP {
|
2 |
| - publishDir "${params.outdir}/Processing/FastP", mode: 'copy' |
| 2 | + tag "${meta.sample_id}" |
3 | 3 |
|
4 | 4 | label 'short_parallel'
|
5 | 5 |
|
6 |
| - tag "${meta.sample_id}|${meta.library_id}|${meta.readgroup_id}" |
7 |
| - |
8 | 6 | conda 'bioconda::fastp=0.23.4'
|
9 | 7 | container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
10 | 8 | 'https://depot.galaxyproject.org/singularity/fastp:0.23.4--hadf994f_2' :
|
11 | 9 | 'quay.io/biocontainers/fastp:0.23.4--hadf994f_2' }"
|
12 | 10 |
|
13 | 11 | input:
|
14 |
| - tuple val(meta), path(r1), path(r2) |
| 12 | + tuple val(meta), path(reads) |
15 | 13 |
|
16 | 14 | output:
|
17 |
| - tuple val(meta), path(r1_trim), path(r2_trim), emit: reads |
| 15 | + tuple val(meta), path('*trimmed.fastq.gz'), emit: reads |
18 | 16 | path("*.json"), emit: json
|
19 | 17 | path('versions.yml'), emit: versions
|
20 | 18 |
|
21 | 19 | script:
|
| 20 | + |
| 21 | + def args = task.ext.args ?: '' |
| 22 | + def prefix = task.ext.prefix ?: reads[0].getBaseName() |
| 23 | + |
| 24 | + r1 = reads[0] |
| 25 | + |
22 | 26 | suffix = '_trimmed.fastq.gz'
|
23 |
| - r1_trim = file(r1).getBaseName() + suffix |
24 |
| - r2_trim = file(r2).getBaseName() + suffix |
25 |
| - json = file(r1).getBaseName() + '.fastp.json' |
26 |
| - html = file(r2).getBaseName() + '.fastp.html' |
27 |
| - |
28 |
| - """ |
29 |
| - fastp -c --in1 $r1 --in2 $r2 \ |
30 |
| - --out1 $r1_trim \ |
31 |
| - --out2 $r2_trim \ |
32 |
| - --detect_adapter_for_pe \ |
33 |
| - -w ${task.cpus} \ |
34 |
| - -j $json \ |
35 |
| - -h $html \ |
36 |
| - --length_required 35 |
37 |
| -
|
38 |
| - cat <<-END_VERSIONS > versions.yml |
39 |
| - "${task.process}": |
40 |
| - fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g") |
41 |
| - END_VERSIONS |
42 |
| -
|
43 |
| - """ |
| 27 | + |
| 28 | + json = prefix + '.fastp.json' |
| 29 | + html = prefix + '.fastp.html' |
| 30 | + |
| 31 | + if (meta.single_end) { |
| 32 | + r1_trim = r1.getBaseName() + suffix |
| 33 | + """ |
| 34 | + fastp --in1 ${r1} \ |
| 35 | + --out1 $r1_trim \ |
| 36 | + -w ${task.cpus} \ |
| 37 | + -j $json \ |
| 38 | + -h $html $args |
| 39 | +
|
| 40 | + cat <<-END_VERSIONS > versions.yml |
| 41 | + "${task.process}": |
| 42 | + fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g") |
| 43 | + END_VERSIONS |
| 44 | + """ |
| 45 | + } else { |
| 46 | + r2 = reads[1] |
| 47 | + r1_trim = r1.getBaseName() + suffix |
| 48 | + r2_trim = r2.getBaseName() + suffix |
| 49 | + """ |
| 50 | + fastp --in1 ${r1} --in2 ${r2} \ |
| 51 | + --out1 $r1_trim \ |
| 52 | + --out2 $r2_trim \ |
| 53 | + --detect_adapter_for_pe \ |
| 54 | + -w ${task.cpus} \ |
| 55 | + -j $json \ |
| 56 | + -h $html \ |
| 57 | + $args |
| 58 | +
|
| 59 | + cat <<-END_VERSIONS > versions.yml |
| 60 | + "${task.process}": |
| 61 | + fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g") |
| 62 | + END_VERSIONS |
| 63 | +
|
| 64 | + """ |
| 65 | + } |
44 | 66 | }
|
0 commit comments