diff --git a/modules/local/star_align.nf b/modules/local/star_align.nf index d5751084..f471ae3b 100644 --- a/modules/local/star_align.nf +++ b/modules/local/star_align.nf @@ -60,19 +60,36 @@ process STAR_ALIGN { // separate forward from reverse pairs def (forward, reverse) = reads.collate(2).transpose() + + // parse whitelist file(s) + arg_whitelist = "" + decompress_cmd = "" + def whitelistList = whitelist ? (whitelist instanceof List ? whitelist : [whitelist]) : [] + + if (whitelistList) { + if (whitelistList.size() == 1) { + def file = whitelistList[0] + def fileStr = file.toString() + if (fileStr.endsWith('.gz')) { + def uncompressed = file.getBaseName() // strips .gz + decompress_cmd = "gzip -cdf ${file} > ${uncompressed}" + arg_whitelist = "--soloCBwhitelist ${uncompressed}" + } else { + arg_whitelist = "--soloCBwhitelist ${fileStr}" + } + } else { + arg_whitelist = "--soloCBwhitelist ${whitelistList.join(' ')}" + } + } """ - if [[ $whitelist == *.gz ]]; then - gzip -cdf $whitelist > whitelist.uncompressed.txt - else - cp $whitelist whitelist.uncompressed.txt - fi + ${decompress_cmd} STAR \\ --genomeDir $index \\ --readFilesIn ${reverse.join( "," )} ${forward.join( "," )} \\ --runThreadN $task.cpus \\ --outFileNamePrefix $prefix. \\ - --soloCBwhitelist whitelist.uncompressed.txt \\ + $arg_whitelist \\ --soloType $protocol \\ --soloFeatures $star_feature \\ $other_10x_parameters \\ diff --git a/nextflow_schema.json b/nextflow_schema.json index dd945d19..794f1fe0 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -52,8 +52,7 @@ "type": "string", "description": "If not using the 10X Genomics platform, a custom barcode whitelist can be used with `--barcode_whitelist`.", "fa_icon": "fas fa-barcode", - "format": "file-path", - "exists": true + "format": "file-path" }, "aligner": { "type": "string", diff --git a/workflows/scrnaseq.nf b/workflows/scrnaseq.nf index d74346b2..36edfc12 100644 --- a/workflows/scrnaseq.nf +++ b/workflows/scrnaseq.nf @@ -47,7 +47,10 @@ workflow SCRNASEQ { ch_txp2gene = params.txp2gene ? file(params.txp2gene, checkIfExists: true) : [] if (params.barcode_whitelist) { - ch_barcode_whitelist = file(params.barcode_whitelist, checkIfExists: true) + // if multiple files -> create channel with single list that keeps the order of the whitelist files preserved + ch_barcode_whitelist = params.barcode_whitelist.contains(',') ? + params.barcode_whitelist.split(',').collect { file(it.trim(), exists: true) } : + file(params.barcode_whitelist, checkIfExists: true) } else if (protocol_config.containsKey("whitelist")) { ch_barcode_whitelist = file("$projectDir/${protocol_config['whitelist']}", checkIfExists: true) } else {