diff --git a/src/nf_modules/samtools/main.nf b/src/nf_modules/samtools/main.nf index 94a2b6d7b2eed8cd05de2bfcc266d526e8889ca3..0b48cd511948cf0319496c7088dc2473fd7d40b2 100755 --- a/src/nf_modules/samtools/main.nf +++ b/src/nf_modules/samtools/main.nf @@ -14,7 +14,7 @@ process sort_bam { path(bam) output: - path("*sorted.bam*"), emit: sorted_bam + path("*sorted.bam"), emit: sorted_bam script: """ @@ -29,7 +29,7 @@ process start_position_counts { publishDir "results/${params.start_position_counts_out}", mode: 'copy' input: - path(bam) + tuple path(bam), path(index) output: path "*", emit: count @@ -61,4 +61,26 @@ process index_bam { """ samtools index -@ ${task.cpus} ${bam} """ +} + +params.indexed_bam_out ="" +process sort_index_bam { + container = "${container_url}" + label "big_mem_multi_cpus" + tag "sorting" + if (params.indexed_bam_out != "") { + publishDir "results/${params.indexed_bam_out}", mode: 'copy' + } + + input: + path(bam) + + output: + tuple path("*sorted.bam"), path("*.bai"), emit: indexed_bam + + script: +""" +samtools sort -@ ${task.cpus} ${bam} -o ${bam.simpleName}_sorted.bam +samtools index -@ ${task.cpus} ${bam.simpleName}_sorted.bam +""" } \ No newline at end of file