Newer
Older
// SPDX-FileCopyrightText: 2022 Laurent Modolo <laurent.modolo@ens-lyon.fr>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
include { index_fasta } from "./../samtools/main.nf"
params.sample_fastq = ""
params.sample_fastq_size = ""
params.sample_fastq_out = ""
workflow sample_fastq {
take:
fastq
fasta
main:
if (params.sample_fastq_coverage == "" && params.sample_fastq_size == ""){
fastq
.set{ final_fastq }
} else {
index_fasta(fasta)
sub_sample_fastq(fastq, index_fasta.out.index)
sub_sample_fastq.out.fastq
.set{ final_fastq }
}
}
process sub_sample_fastq {
container = "${container_url}"
tag "$file_id"
if (params.index_fasta_out != "") {
publishDir "results/${params.sample_fastq_out}", mode: 'copy'
}
input:
tuple val(file_id), path(fastq)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
output:
tuple val(file_id), path("sub_*.fastq.gz"), emit: fastq
script:
switch(file_id) {
case {it instanceof List}:
file_prefix = file_id[0]
break
case {it instanceof Map}:
file_prefix = file_id.values()[0]
break
default:
file_prefix = file_id
break
}
sample_option = "-c " + params.sample_fastq_coverage
if (params.sample_fastq_size != ""){
sample_option = "-b " + params.sample_fastq_size
}
if (fastq.size() == 2)
"""
rasusa \
-i ${fastq[0]} ${fastq[1]} \
-g ${idx} \
${sample_option} \
-o sub_${fastq[0].simpleName}.fastq.gz sub_${fastq[1].simpleName}.fastq.gz
"""
else
"""
rasusa \
-g ${idx} \
${sample_option} \
-o sub_${fastq.simpleName}.fastq.gz
"""
}