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

View file

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

View file

@ -15,8 +15,18 @@ workflow test_samtools_view {
workflow test_samtools_view_cram { workflow test_samtools_view_cram {
input = [ [ id: 'test' ], // meta map 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_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_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) fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)

View file

@ -2,4 +2,8 @@ process {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } 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,8 +1,8 @@
- name: samtools view test_samtools_view - 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: tags:
- samtools/view
- samtools - samtools
- samtools/view
files: files:
- path: output/samtools/test.bam - path: output/samtools/test.bam
md5sum: 8fb1e82f76416e9e30fc6b2357e2cf13 md5sum: 8fb1e82f76416e9e30fc6b2357e2cf13
@ -10,15 +10,26 @@
- name: samtools view test_samtools_view_cram - 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: tags:
- samtools/view
- samtools - samtools
- samtools/view
files: files:
- path: output/samtools/test.cram - path: output/samtools/test.cram
md5sum: 792399d4d7afc9e58ffeedc1073291b9
- name: samtools view test_samtools_view_stubs - name: samtools view test_samtools_view_convert
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 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: tags:
- samtools/view
- samtools - samtools
- samtools/view
files: files:
- path: output/samtools/test.bam - 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