luslab-umitools | Combined bam/bai into single channel + clean up

This commit is contained in:
Chris Cheshire 2020-06-26 08:36:11 +01:00
parent cb58bea33f
commit 3e26c218c2
2 changed files with 19 additions and 36 deletions

View file

@ -14,7 +14,7 @@ process umitools_dedup {
container 'luslab/nf-modules-umitools:latest' container 'luslab/nf-modules-umitools:latest'
input: input:
tuple val(sample_id), path(bai), path(bam) tuple val(sample_id), path(bam)
output: output:
tuple val(sample_id), path("*.dedup.bam"), emit: dedupBam tuple val(sample_id), path("*.dedup.bam"), emit: dedupBam
@ -23,25 +23,24 @@ process umitools_dedup {
script: script:
// Init // Init
internal_prog = "umi_tools dedup"
args = "--log=${sample_id}.dedup.log" args = "--log=${sample_id}.dedup.log"
// Check main args string exists and strip whitespace // Check main args string exists and strip whitespace
if(params.umitools_dedup_args) { if(params.umitools_dedup_args) {
ext_args = params.umitools_dedup_args ext_args = params.umitools_dedup_args
internal_args += " " + ext_args.trim() args += " " + ext_args.trim()
} }
// Contruct CL line // Contruct CL line
command = "${internal_prog} ${internal_args} -I $bam -S ${sample_id}.dedup.bam --output-stats=${sample_id}" command = "umi_tools dedup ${args} -I ${bam[0]} -S ${sample_id}.dedup.bam --output-stats=${sample_id}"
// Log // Log
if (params.verbose){ if (params.verbose){
println ("[MODULE] umi_tools/dedup exec: " + internal_cl) println ("[MODULE] umi_tools/dedup exec: " + command)
} }
//SHELL //SHELL
""" """
${internal_cl} ${command}
""" """
} }

View file

@ -4,7 +4,7 @@
nextflow.preview.dsl=2 nextflow.preview.dsl=2
// Log // Log
log.info ("Starting test for umi_tools dedup...") log.info ("Starting tests for umi_tools dedup...")
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
/* Define params /* Define params
@ -23,37 +23,21 @@ include umitools_dedup from '../main.nf'
/* Define input channels /* Define input channels
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
// Meta data // Define test data
testMetaDataBam = [ testData = [
['sample1', "$baseDir/input/sample1.bam"], ['sample1', "$baseDir/input/sample1.bam", "$baseDir/input/sample1.bai"],
['sample2', "$baseDir/input/sample2.bam"], ['sample2', "$baseDir/input/sample2.bam", "$baseDir/input/sample2.bai"],
['sample3', "$baseDir/input/sample3.bam"], ['sample3', "$baseDir/input/sample3.bam", "$baseDir/input/sample3.bai"],
['sample4', "$baseDir/input/sample4.bam"], ['sample4', "$baseDir/input/sample4.bam", "$baseDir/input/sample4.bai"],
['sample5', "$baseDir/input/sample5.bam"], ['sample5', "$baseDir/input/sample5.bam", "$baseDir/input/sample5.bai"],
['sample6', "$baseDir/input/sample6.bam"] ['sample6', "$baseDir/input/sample6.bam", "$baseDir/input/sample6.bai"]
] ]
testMetaDataBai = [ //Define test data input channel
['sample1', "$baseDir/input/sample1.bai"],
['sample2', "$baseDir/input/sample2.bai"],
['sample3', "$baseDir/input/sample3.bai"],
['sample4', "$baseDir/input/sample4.bai"],
['sample5', "$baseDir/input/sample5.bai"],
['sample6', "$baseDir/input/sample6.bai"]
]
//Bam input channel
Channel Channel
.from(testMetaDataBam) .from(testData)
.map { row -> [ row[0], file(row[1], checkIfExists: true) ]} .map { row -> [ row[0], [file(row[1], checkIfExists: true), file(row[2], checkIfExists: true)]]}
.set {ch_test_meta_bam} .set {ch_bam}
//BamBai input channel
Channel
.from(testMetaDataBai)
.map { row -> [ row[0], file(row[1], checkIfExists: true) ] }
.join(ch_test_meta_bam)
.set {ch_test_meta_bambai}
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
/* Run tests /* Run tests
@ -61,7 +45,7 @@ Channel
workflow { workflow {
// Run dedup // Run dedup
umitools_dedup ( ch_test_meta_bambai ) umitools_dedup ( ch_bam )
// Collect file names and view output // Collect file names and view output
umitools_dedup.out.dedupBam | view umitools_dedup.out.dedupBam | view