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'
input:
tuple val(sample_id), path(bai), path(bam)
tuple val(sample_id), path(bam)
output:
tuple val(sample_id), path("*.dedup.bam"), emit: dedupBam
@ -23,25 +23,24 @@ process umitools_dedup {
script:
// Init
internal_prog = "umi_tools dedup"
args = "--log=${sample_id}.dedup.log"
// Check main args string exists and strip whitespace
if(params.umitools_dedup_args) {
ext_args = params.umitools_dedup_args
internal_args += " " + ext_args.trim()
args += " " + ext_args.trim()
}
// 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
if (params.verbose){
println ("[MODULE] umi_tools/dedup exec: " + internal_cl)
println ("[MODULE] umi_tools/dedup exec: " + command)
}
//SHELL
"""
${internal_cl}
${command}
"""
}

View file

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