From 1abe23e1592f7cf6a3724589061827df0d8a0252 Mon Sep 17 00:00:00 2001 From: "Maxime U. Garcia" Date: Wed, 10 Nov 2021 10:30:48 +0100 Subject: [PATCH] Add CRAM to samtools/index (#1049) * feat: update samtools/index * feat: add test * fix: lint * fix: output file + md5 --- modules/samtools/index/main.nf | 11 ++++++----- modules/samtools/index/meta.yml | 5 +++++ tests/modules/samtools/index/main.nf | 13 +++++++++++-- tests/modules/samtools/index/test.yml | 9 +++++++++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/modules/samtools/index/main.nf b/modules/samtools/index/main.nf index febbc11c..62254bc8 100644 --- a/modules/samtools/index/main.nf +++ b/modules/samtools/index/main.nf @@ -19,16 +19,17 @@ process SAMTOOLS_INDEX { } input: - tuple val(meta), path(bam) + tuple val(meta), path(input) output: - tuple val(meta), path("*.bai"), optional:true, emit: bai - tuple val(meta), path("*.csi"), optional:true, emit: csi - path "versions.yml" , emit: versions + tuple val(meta), path("*.bai") , optional:true, emit: bai + tuple val(meta), path("*.crai"), optional:true, emit: crai + tuple val(meta), path("*.csi") , optional:true, emit: csi + path "versions.yml" , emit: versions script: """ - samtools index $options.args $bam + samtools index $options.args $input cat <<-END_VERSIONS > versions.yml ${getProcessName(task.process)}: ${getSoftwareName(task.process)}: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') diff --git a/modules/samtools/index/meta.yml b/modules/samtools/index/meta.yml index 988e8f53..0905b3cd 100644 --- a/modules/samtools/index/meta.yml +++ b/modules/samtools/index/meta.yml @@ -35,6 +35,10 @@ output: type: file description: BAM/CRAM/SAM index file pattern: "*.{bai,crai,sai}" + - crai: + type: file + description: BAM/CRAM/SAM index file + pattern: "*.{bai,crai,sai}" - csi: type: file description: CSI index file @@ -46,3 +50,4 @@ output: authors: - "@drpatelh" - "@ewels" + - "@maxulysse" diff --git a/tests/modules/samtools/index/main.nf b/tests/modules/samtools/index/main.nf index be9014e0..737936fb 100644 --- a/tests/modules/samtools/index/main.nf +++ b/tests/modules/samtools/index/main.nf @@ -2,8 +2,9 @@ nextflow.enable.dsl = 2 -include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_BAI } from '../../../../modules/samtools/index/main.nf' addParams( options: [:] ) -include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_CSI } from '../../../../modules/samtools/index/main.nf' addParams( options: [args:'-c'] ) +include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_BAI } from '../../../../modules/samtools/index/main.nf' addParams( options: [:] ) +include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_CRAI } from '../../../../modules/samtools/index/main.nf' addParams( options: [:] ) +include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_CSI } from '../../../../modules/samtools/index/main.nf' addParams( options: [args:'-c'] ) workflow test_samtools_index_bai { input = [ [ id:'test', single_end:false ], // meta map @@ -13,6 +14,14 @@ workflow test_samtools_index_bai { SAMTOOLS_INDEX_BAI ( input ) } +workflow test_samtools_index_crai { + input = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_recalibrated_sorted_cram'], checkIfExists: true) + ] + + SAMTOOLS_INDEX_CRAI ( input ) +} + workflow test_samtools_index_csi { input = [ [ id:'test', single_end:false ], // meta map file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) diff --git a/tests/modules/samtools/index/test.yml b/tests/modules/samtools/index/test.yml index 31941dd6..66ab8211 100644 --- a/tests/modules/samtools/index/test.yml +++ b/tests/modules/samtools/index/test.yml @@ -7,6 +7,15 @@ - path: output/samtools/test.paired_end.sorted.bam.bai md5sum: 704c10dd1326482448ca3073fdebc2f4 +- name: samtools index crai + command: nextflow run tests/modules/samtools/index -entry test_samtools_index_crai -c tests/config/nextflow.config + tags: + - samtools + - samtools/index + files: + - path: output/samtools/test.paired_end.recalibrated.sorted.cram.crai + md5sum: 537e3d8c937bcc4e34e1cf47cd71d484 + - name: samtools index csi command: nextflow run tests/modules/samtools/index -entry test_samtools_index_csi -c tests/config/nextflow.config tags: