Update samtools view (#2096)

* samtools view update

* remove csi output

* prettier

* update meta
This commit is contained in:
Priyanka Surana 2022-09-23 13:03:59 +01:00 committed by GitHub
parent 0857e6c60f
commit 402631fdaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 22 deletions

View file

@ -14,7 +14,7 @@ process SAMTOOLS_VIEW {
output:
tuple val(meta), path("*.bam") , emit: bam , optional: true
tuple val(meta), path("*.cram"), emit: cram, optional: true
tuple val(meta), path("*.csi") , emit: csi, optional: true
tuple val(meta), path("*.sam") , emit: sam , optional: true
path "versions.yml" , emit: versions
when:
@ -22,10 +22,12 @@ process SAMTOOLS_VIEW {
script:
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def reference = fasta ? "--reference ${fasta} -C" : ""
def file_type = input.getExtension()
def reference = fasta ? "--reference ${fasta}" : ""
def file_type = args.contains("--output-fmt sam") ? "sam" :
args.contains("--output-fmt bam") ? "bam" :
args.contains("--output-fmt cram") ? "cram" :
input.getExtension()
if ("$input" == "${prefix}.${file_type}") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
"""
samtools \\
@ -34,7 +36,6 @@ process SAMTOOLS_VIEW {
${reference} \\
$args \\
$input \\
$args2 \\
> ${prefix}.${file_type}
cat <<-END_VERSIONS > versions.yml

View file

@ -41,21 +41,22 @@ output:
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: filtered/converted BAM/SAM file
pattern: "*.{bam,sam}"
description: optional filtered/converted BAM file
pattern: "*.{bam}"
- cram:
type: file
description: filtered/converted CRAM file
pattern: "*.cram"
description: optional filtered/converted CRAM file
pattern: "*.{cram}"
- sam:
type: file
description: optional filtered/converted SAM file
pattern: "*.{sam}"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- csi:
type: file
description: BAM index file (optional)
pattern: "*.csi"
authors:
- "@drpatelh"
- "@joseespinosa"
- "@FriederikeHanssen"
- "@priyanka-surana"

View file

@ -15,14 +15,24 @@ workflow test_samtools_view {
workflow test_samtools_view_cram {
input = [ [ id: 'test' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_cram_crai'], checkIfExists: true)
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true)
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
SAMTOOLS_VIEW ( input, fasta )
}
workflow test_samtools_view_convert {
input = [ [ id: 'test' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
[]
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
SAMTOOLS_VIEW ( input, fasta )
}
workflow test_samtools_view_stubs {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true),

View file

@ -2,4 +2,8 @@ process {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
withName: 'test_samtools_view_convert:SAMTOOLS_VIEW' {
ext.args = "--output-fmt bam"
}
}

View file

@ -1,24 +1,35 @@
- name: samtools view test_samtools_view
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config
tags:
- samtools/view
- samtools
- samtools/view
files:
- path: output/samtools/test.bam
md5sum: 8fb1e82f76416e9e30fc6b2357e2cf13
- name: samtools view test_samtools_view_cram
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view_cram -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view_cram -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config
tags:
- samtools/view
- samtools
- samtools/view
files:
- path: output/samtools/test.cram
md5sum: 792399d4d7afc9e58ffeedc1073291b9
- name: samtools view test_samtools_view_stubs
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view_stubs -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config -stub-run
- name: samtools view test_samtools_view_convert
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view_convert -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config
tags:
- samtools/view
- samtools
- samtools/view
files:
- path: output/samtools/test.bam
md5sum: 3877632410d032e91a91b054c906a310
- name: samtools view test_samtools_view_stubs
command: nextflow run ./tests/modules/samtools/view -entry test_samtools_view_stubs -c ./tests/config/nextflow.config -c ./tests/modules/samtools/view/nextflow.config
tags:
- samtools
- samtools/view
files:
- path: output/samtools/test.bam
md5sum: 8fb1e82f76416e9e30fc6b2357e2cf13