From 3ad4a0cb0b38bc59c58df644c1b36c17bc1828c9 Mon Sep 17 00:00:00 2001 From: cgpu Date: Wed, 4 Dec 2019 01:23:29 +0000 Subject: [PATCH] Addresses https://github.com/cgpu/sarek/issues/3 ; Known issue with bwa | smatools pipe --- main.nf | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.nf b/main.nf index 6cfaf82ebf..a0f912619b 100644 --- a/main.nf +++ b/main.nf @@ -675,9 +675,16 @@ process MapReads { convertToFastq = hasExtension(inputFile1, "bam") ? "gatk --java-options -Xmx${task.memory.toGiga()}g SamToFastq --INPUT=${inputFile1} --FASTQ=/dev/stdout --INTERLEAVE=true --NON_PF=true | \\" : "" input = hasExtension(inputFile1, "bam") ? "-p /dev/stdin - 2> >(tee ${inputFile1}.bwa.stderr.log >&2)" : "${inputFile1} ${inputFile2}" """ - ${convertToFastq} - bwa mem -K 100000000 -R \"${readGroup}\" ${extra} -t ${task.cpus} -M ${fasta} \ - ${input} | samtools sort - > ${idSample}_${idRun}.bam + # map to sam + ${convertToFastq} + bwa mem -K 100000000 -R \"${readGroup}\" ${extra} -t ${task.cpus} -M ${fasta} \ + ${input} > ${idSample}_${idRun}.sam + + # create bam + samtools view -@ ${task.cpus} -b -h -O BAM -o ${idSample}_${idRun}.bwamem.bam ${idSample}_${idRun}.sam + + # sort bam + samtools sort -@ ${task.cpus} -o ${idSample}_${idRun}.bam """ }