From 70c316139317729180aaf02c2089054c4b77bfa0 Mon Sep 17 00:00:00 2001 From: Akazhiel Date: Thu, 1 Jun 2023 19:14:49 +0200 Subject: [PATCH] Replaced samtools view and bam2fq to extract fastq to map to hla reference with samtools collate and samtools fastq. Now outputs gzipped fastq files and doesn't remove the intermediate files. --- modules/local/yaramap.nf | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/local/yaramap.nf b/modules/local/yaramap.nf index 48ce830..df566d8 100644 --- a/modules/local/yaramap.nf +++ b/modules/local/yaramap.nf @@ -25,25 +25,16 @@ process YARA_MAPPER { def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" """ - samtools view -@ ${split_cpus} -h -f 0x40 $bam > output_1.bam - samtools view -@ ${split_cpus} -h -f 0x80 $bam > output_2.bam - samtools bam2fq output_1.bam > output_1.fastq - samtools bam2fq output_2.bam > output_2.fastq + samtools collate -u -O -@ ${task.cpus} ${bam} | samtools fastq -@ ${task.cpus} -1 output_1.fastq.gz -2 output_2.fastq.gz -0 /dev/null yara_mapper \\ $options.args \\ -t ${task.cpus} \\ -f bam \\ ${index}/yara \\ - output_1.fastq \\ - output_2.fastq > output.bam + output_1.fastq.gz \\ + output_2.fastq.gz > output.bam samtools view -@ ${split_cpus} -hF 4 -f 0x40 -b output.bam > ${prefix}_1.mapped.bam samtools view -@ ${split_cpus} -hF 4 -f 0x80 -b output.bam > ${prefix}_2.mapped.bam - - rm output_2.bam - rm output_1.bam - rm output_1.fastq - rm output_2.fastq - rm output.bam echo \$(yara_mapper --version) | sed "s/^.*yara_mapper version: //; s/ .*\$//" > ${software}.version.txt """