Newer
Older
include { index_fasta } from "./../samtools/main.nf"
params.sample_fastq = ""
params.sample_fastq_coverage = "1.0"
params.sample_fastq_size = ""
params.sample_fastq_out = ""
workflow sample_fastq {
take:
fastq
fasta
main:
index_fasta(fasta)
sub_sample_fastq(fastq, index_fasta.out.index)
emit:
fastq = sub_sample_fastq.out.fastq
}
process sub_sample_fastq {
container = "${container_url}"
label "small_mem_multi_cpus"
tag "$file_id"
if (params.index_fasta_out != "") {
publishDir "results/${params.sample_fastq_out}", mode: 'copy'
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
}
input:
tuple val(file_id), path(fastq)
tuple val(file_id), path(idx)
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
"""
}