Add samtools index to yara_mapper module (#1353)

* Add samtools index to yara_mapper module.

* samtools sort required for index

Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
This commit is contained in:
Michael L Heuer 2022-03-04 09:08:02 -06:00 committed by GitHub
parent 72b96f4e50
commit 251015c8ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View file

@ -13,6 +13,7 @@ process YARA_MAPPER {
output:
tuple val(meta), path("*.mapped.bam"), emit: bam
tuple val(meta), path("*.mapped.bam.bai"), emit: bai
path "versions.yml" , emit: versions
when:
@ -28,7 +29,9 @@ process YARA_MAPPER {
-t $task.cpus \\
-f bam \\
${index}/yara \\
$reads | samtools view -@ $task.cpus -hb -F4 > ${prefix}.mapped.bam
$reads | samtools view -@ $task.cpus -hb -F4 | samtools sort -@ $task.cpus > ${prefix}.mapped.bam
samtools index -@ $task.cpus ${prefix}.mapped.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
@ -46,8 +49,11 @@ process YARA_MAPPER {
${reads[0]} \\
${reads[1]} > output.bam
samtools view -@ $task.cpus -hF 4 -f 0x40 -b output.bam > ${prefix}_1.mapped.bam
samtools view -@ $task.cpus -hF 4 -f 0x80 -b output.bam > ${prefix}_2.mapped.bam
samtools view -@ $task.cpus -hF 4 -f 0x40 -b output.bam | samtools sort -@ $task.cpus > ${prefix}_1.mapped.bam
samtools view -@ $task.cpus -hF 4 -f 0x80 -b output.bam | samtools sort -@ $task.cpus > ${prefix}_2.mapped.bam
samtools index -@ $task.cpus ${prefix}_1.mapped.bam
samtools index -@ $task.cpus ${prefix}_2.mapped.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":

View file

@ -45,6 +45,10 @@ output:
type: file
description: Sorted BAM file
pattern: "*.{bam}"
- bai:
type: file
description: Sorted BAM file index
pattern: "*.{bai}"
authors:
- "@apeltzer"

View file

@ -5,6 +5,7 @@
- yara
files:
- path: output/yara/test.mapped.bam
- path: output/yara/test.mapped.bam.bai
- path: output/yara/yara/yara.txt.size
md5sum: 063987b3c3f747be7d2b8043c9d91000
- path: output/yara/yara/yara.lf.drs
@ -39,7 +40,9 @@
- yara
files:
- path: output/yara/test_2.mapped.bam
- path: output/yara/test_2.mapped.bam.bai
- path: output/yara/test_1.mapped.bam
- path: output/yara/test_1.mapped.bam.bai
- path: output/yara/yara/yara.txt.size
md5sum: 063987b3c3f747be7d2b8043c9d91000
- path: output/yara/yara/yara.lf.drs